fix: discard the build record git:sync starts when nothing is built
cmd-git-sync calls dokku_setup_build_capture before the clone/fetch, because it cannot know whether there is anything to deploy until it has fetched. Both paths that then decline to build - a plain `git:sync` with no build flag, and a `--build-if-changes` poll that finds the remote unchanged - returned without ever finalizing that record. The record stayed at status=running forever, which has three consequences on an app polled on a timer: - PruneAppBuilds only runs from builds-record-finalize, so nothing prunes the ticks while the app is idle; they accumulate without bound, invisibly, because builds:list caps output at the retention count. - The next real deploy's ReapAbandonedBuilds finalizes each of them as status=failed, exit_code=-1, with finished_at stamped at the moment of reaping - indistinguishable on disk from a build that really failed, and with a duration that grew to the polling interval. - That same deploy's prune then keeps the newest records by started_at, which after an idle stretch are the ticks, deleting the last real deploy's record and log. Add a builds-record-discard trigger that removes a non-terminal record and its log, and call it from both no-op paths in cmd-git-sync. The trigger leaves missing and already-terminal records alone, so it can never delete real history. Fixes #9030 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
aa39920cc7
commit
dc27668e09
10 files changed
+188
-1
No files matched your search
@@ -395,6 +395,59 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "$SMOKE_TEST_APP_MASTER_SHA"
|
||||
|
||||
# the no-op tick must not add a record of its own, and must leave the
|
||||
# succeeded record of the build above untouched
|
||||
run /bin/bash -c "ls $DOKKU_LIB_ROOT/data/builds/$TEST_APP/*.json 2>/dev/null | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "1"
|
||||
|
||||
run /bin/bash -c "dokku builds:list $TEST_APP --format json"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains '"status":"succeeded"'
|
||||
assert_output_not_contains '"display_status":"abandoned"'
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [no build leaves no build record]" {
|
||||
run /bin/bash -c "rm -rf $DOKKU_LIB_ROOT/data/builds/$TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
# a sync with no build flag builds nothing, so it should record nothing
|
||||
run /bin/bash -c "dokku git:sync $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "ls $DOKKU_LIB_ROOT/data/builds/$TEST_APP/*.json 2>/dev/null | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "0"
|
||||
|
||||
# and neither should a --build-if-changes poll that finds no changes
|
||||
run /bin/bash -c "dokku git:sync --build-if-changes $TEST_APP https://github.com/dokku/smoke-test-app.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output_contains "Skipping build as no changes were detected"
|
||||
|
||||
run /bin/bash -c "ls $DOKKU_LIB_ROOT/data/builds/$TEST_APP/*.json 2>/dev/null | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "0"
|
||||
|
||||
run /bin/bash -c "ls $DOKKU_LIB_ROOT/data/builds/$TEST_APP/*.log 2>/dev/null | wc -l"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
assert_output "0"
|
||||
}
|
||||
|
||||
@test "(git) git:sync new [--build branch]" {
|
||||
|
||||
Reference in new issue
Block a user