After a conversation with @Anthony about the relation between SID and Hashes that we would like to have, we decided a few things.
Relation between SID and Hashes
The relation between SID and Hashes should keep track of all hashes referenced by the SID and preserve the order of addition. So basically, in the database, SID should reference an array of hash.
Service Deployment
Deploying a service with an existing SID will not delete existing services but only append the new service’s hash to the associated SID array of hashes. Like this, it keeps existing services with the order of deployment.
Return a service from a SID
When a service needs to be returned from a SID, the most recent deployed service will be returned.
Prevent concurrent run of services with same ID
Because of volumes, services with the same SID cannot run at the same time. The function service start have to prevent this behavior and fail with a explicit error for the user.
Delete a SID
When users want to delete a service with a hash, the hash is removed from the SID’s array of hashes as well as the corresponding service.
When users want to delete a service with a SID, the last deployed service’s hash is removed from the SID’s array of hashes as well as the corresponding service.
In both case, if there is no more element in the SID’s array of hashes, then the SID’s array of hashes must be remove from the database.
@krhubert @ilgooz @Anthony what do you think about this? do you have feedback?