hapistrano
hapistrano copied to clipboard
Hapistrano can fail at rollback if `ctoken` points to a release that does not exists
Hapistrano uses ctokens
to know which deployments finished successfully. After that, they're used to rollback to a successful release. However, we're not validating if the path that is generated for the rollback exists and ln
doesn't fail if the target directory/file doesn't exists. Therefore, we should add a validation before that symlink is created. If the file doesn't exist, we should stop the rollback and notify the user.
This could happen if at some point the ctokens
are manually manipulated or if a release is deleted and so are the ctokens.
Example:
/var/project/myproject
/ctokens/
20220102 # Just one ctoken pointing to an non-existing release
/releases/
20220103
20220104
current -> /var/project/myproject/releases/20220104
Executing hap rollback
will cause:
/var/project/myproject
/ctokens/
20220102 # Just one ctoken pointing to an non-existing release
/releases/
20220103
20220104
current -> /var/project/myproject/releases/20220102 # This symlink doesn't exist but `ln` doesn't care and doesn't fail.
The current
symlink points to a directory that doesn't exists. We could face errors later because of this.