fix: release deploy locks on exit and honor apps:lock
A deploy that exited before releasing its lock, such as after a failed build, left `.deploy.lock` behind, so `apps:locked` reported a lock nothing held and the build record stayed running. The lock is now released and the record finalized whenever the deploy exits. `apps:lock` never actually blocked deploys, as it only created the file deploys lock. It now creates its own lock that git pushes, `ps:rebuild`, `git:sync`, and the `git:from-*` commands refuse to deploy past, and `apps:locked` only reports a lock when the app was locked via `apps:lock` or a deploy is in progress. Locks created by `apps:lock` in older versions are migrated on install.
This commit is contained in:
17 files changed
+535
-69
No files matched your search
@@ -90,6 +90,30 @@ wait_for() {
|
||||
assert_output_contains "lock held"
|
||||
}
|
||||
|
||||
@test "(deploy-lock) the lock file is removed when the holder exits without releasing it" {
|
||||
run /bin/bash -c "$(lock_script "holder-a" "acquire_advisory_lock '$LOCK_FILE' exclusive 'waiting' 'lock held'; exit 1")"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_failure
|
||||
|
||||
run /bin/bash -c "[[ ! -e '$LOCK_FILE' ]]"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(deploy-lock) the lock file is removed when the holder is terminated" {
|
||||
start_lock_holder "holder-a"
|
||||
|
||||
kill -TERM "${LOCK_PIDS[0]}"
|
||||
wait_for "! kill -0 ${LOCK_PIDS[0]} 2>/dev/null"
|
||||
|
||||
run /bin/bash -c "[[ ! -e '$LOCK_FILE' ]]"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "(deploy-lock) release only removes the lock file it holds" {
|
||||
start_lock_holder "holder-a"
|
||||
|
||||
|
||||
Reference in new issue
Block a user