Skip to content

fix: treat already-fully-promoted target as success (idempotent) - #225

Merged
matthiasL-scality merged 2 commits into
mainfrom
PTFE-3537/idempotent-promote
Sep 21, 2026
Merged

matthiasL-scality merged 2 commits into
mainfrom
PTFE-3537/idempotent-promote

Conversation

@matthiasL-scality

@matthiasL-scality matthiasL-scality commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When a workflow fails after a successful promote step, retrying the workflow caused the promote to always fail with `FAILED: target already fully promoted` (introduced in feat: allow resuming a partial promote without manual cleanup #223).
  • Root cause: `.final_status` was copied as part of the regular batch — since S3 lists lexicographically, files starting with `.` arrive first, so `.final_status` could be written to the target before all other artifacts were copied. A promote interrupted after that point would appear complete but be incomplete.

This PR fixes both issues:

  1. `.final_status` is now copied last, outside the main batch, as a reliable completion seal. Its presence on the target guarantees the promote finished in full.
  2. A fully-promoted target is treated as idempotent success — if `.final_status` is already there, the promote returns `BUILD COPIED` immediately, so workflow retries are not blocked.

Fixes PTFE-3537.

Behaviour

Scenario Before After
Target empty success success (unchanged)
Target partially promoted (no `.final_status`) resume resume (unchanged)
Target fully promoted (`.final_status` present) `FAILED` `BUILD COPIED` (idempotent)
`.final_status` was a reliable seal ❌ could be written early ✅ always written last

Test plan

  • `test_copy_idempotent_when_target_already_fully_promoted` — second promote on a complete target returns `BUILD COPIED`
  • `test_resume_already_complete_promote` — same scenario from the resume angle
  • `test_resume_promote_interrupted_before_final_status` — new test: target has all artifacts but no `.final_status`; promote completes successfully
  • All existing tests (empty target, partial resume, multipart copy, cross-bucket, ingress) remain green

🤖 Generated with Claude Code

When a workflow fails after a successful promote step, retrying
the workflow caused the promote to fail with "target already fully
promoted" because the target already had a .final_status.

Treat this case as idempotent success so that workflow retries are
not blocked by a promote that already completed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@matthiasL-scality
matthiasL-scality requested a review from a team as a code owner September 21, 2026 06:00
@claude

claude Bot commented Sep 21, 2026

Copy link
Copy Markdown

LGTM

Review by Claude Code

Previously .final_status was copied as part of the regular batch.
Since S3 lists objects lexicographically, files starting with '.'
arrived first, meaning .final_status could be written to the target
before all other artifacts were copied.  A promote interrupted after
that point would look fully promoted but be incomplete.

Copy .final_status outside the main batch and only after all other
objects have been successfully transferred.  Its presence on the
target now reliably means the promote completed in full.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude

claude Bot commented Sep 21, 2026

Copy link
Copy Markdown

LGTM

Review by Claude Code

@matthiasL-scality
matthiasL-scality merged commit 9195f4e into main Sep 21, 2026
5 checks passed
@matthiasL-scality
matthiasL-scality deleted the PTFE-3537/idempotent-promote branch September 21, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant