Skip to content

Commit 882f6e1

Browse files
committed
fix: normalize legacy runtime checkpoints
1 parent 76ccb27 commit 882f6e1

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎scripts/install-worker-controller.sh‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ restore_systemd_snapshot() {
15741574
}
15751575

15761576
restore_checkpoint() {
1577-
local target restored_state actual index expected_owner=0 failed=0 checkpoint_release='' drain_env=$rendered_env drain_release='' restore_images=false new_format=false checkpoint_format='' current_temporary='' validated_current_target='' validated_manager_target=''
1577+
local target restored_state actual index runtime_target expected_owner=0 failed=0 checkpoint_release='' drain_env=$rendered_env drain_release='' restore_images=false new_format=false checkpoint_format='' current_temporary='' validated_current_target='' validated_manager_target=''
15781578
local restore_controller_tag_after_start=false
15791579
local format_marker=$checkpoint_dir/format-version image_ids=$checkpoint_dir/image-ids.env
15801580
[[ -n "$checkpoint_dir" && -d "$checkpoint_dir" ]] || return 1
@@ -1654,6 +1654,19 @@ PY
16541654
note 'ROLLBACK_FAILED reason=checkpoint release target is invalid'
16551655
return 1
16561656
fi
1657+
runtime_target=$(canonical_release_target "$checkpoint_release" "$releases_dir" || true)
1658+
if [[ -z "$runtime_target" ]]; then
1659+
if [[ "$checkpoint_release" != "$manager_releases/"* || -L "$checkpoint_release" ]]; then
1660+
note 'ROLLBACK_FAILED reason=checkpoint release target is invalid'
1661+
return 1
1662+
fi
1663+
runtime_target=$releases_dir/$target
1664+
if ! install_release "$target" "$runtime_target" 0 0; then
1665+
note 'ROLLBACK_FAILED reason=checkpoint release target normalization failed'
1666+
return 1
1667+
fi
1668+
fi
1669+
checkpoint_release=$runtime_target
16571670
fi
16581671

16591672
if [[ -e "$checkpoint_dir/manager-target" || -L "$checkpoint_dir/manager-target" ]]; then

‎scripts/test-install-worker-controller.sh‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,6 +1638,14 @@ expect_success "$installer" --rollback >/dev/null
16381638
[[ $(readlink "$root/opt/ci-fleet/manager/current") == "$root/opt/ci-fleet/manager/releases/$legacy_checkpoint_manager_ref" ]] || fail 'legacy checkpoint manager target was not normalized to canonical authority'
16391639
rm -rf "$legacy_checkpoint_manager"
16401640
printf '%s\n' "$root/opt/ci-fleet/manager/releases/$legacy_checkpoint_manager_ref" >"$authority_checkpoint/manager-target"
1641+
legacy_release_fallback=$root/opt/ci-fleet/manager/releases/prior-runtime-fallback
1642+
cp -a "$root/opt/ci-fleet/manager/releases/$legacy_checkpoint_manager_ref" "$legacy_release_fallback"
1643+
rm -rf "$authority_active_release"
1644+
printf '%s\n' "$legacy_release_fallback" >"$authority_checkpoint/release-target"
1645+
printf '%s' "$root/opt/ci-fleet/releases/missing-legacy-runtime" >"$authority_checkpoint/current-link"
1646+
expect_success "$installer" --rollback >/dev/null
1647+
[[ $(readlink "$root/opt/ci-fleet/current") == "$root/opt/ci-fleet/releases/$legacy_checkpoint_manager_ref" ]] || fail 'legacy checkpoint release fallback was not restaged to canonical runtime authority'
1648+
rm -rf "$legacy_release_fallback"
16411649
printf '%s\n' "$incomplete_current" >"$authority_checkpoint/release-target"
16421650
printf '2\n' >"$authority_checkpoint/format-version"
16431651
rm -f "$authority_checkpoint/current-link" "$authority_checkpoint/current-absent"

0 commit comments

Comments
 (0)