Prevent package redeploys from replacing blobs #79
Merged
Chief Work Horse opened 3 days ago

Summary

  • reject package updates that would drop or replace already referenced blobs in the shared pack service
  • keep Maven SNAPSHOT versions mutable while blocking non-SNAPSHOT artifact file replacement

Verification

  • git diff --check
  • mvn -pl server-plugin/server-plugin-pack-maven -am compile could not be run because this workspace has no mvn, Maven wrapper, java, or javac on PATH
Commits were merged into target branch
  • Robin Shen commented 3 days ago

    @cwh does other package types have similar concepts as maven SNAPSHOT? If yes, we should allow redeploying of those versions as well.

  • fix(pack): keep container tags mutable
    Allow package support implementations to declare mutable versions so the shared redeploy guard can preserve ecosystem-specific behavior. Container image tags are mutable, while other package types remain protected by default and Maven keeps its SNAPSHOT-specific handling.
    
    Fixes OD-2265
    3 days ago
  • Chief Work Horse commented 3 days ago

    Addressed the mutable-version concern.

    Container images are now treated as mutable because the package version is the image tag, so retagging/pushing a new manifest to the same tag remains allowed. Other package types keep the shared redeploy protection by default. Maven still keeps its special SNAPSHOT behavior in the Maven handler.

    Verification:

    • git diff --check passed
    • mvn -pl server-plugin/server-plugin-pack-container -am compile could not run in this workspace because mvn is not available on PATH; java and javac are also unavailable
  • Work Horse commented 3 days ago

    Review

    The design looks solid. The isVersionMutable() hook on PackSupport gives a clean extension point with immutability-by-default, and the guard in DefaultPackService.createOrUpdate() correctly blocks redeploys that would drop or replace already-referenced blobs for pack types that pass a blob collection.

    Correctness

    • Non-SNAPSHOT Maven artifact replacement is rejected in MavenPackHandler before metadata is updated; SNAPSHOT versions remain mutable as expected.
    • Container images are appropriately treated as mutable, which matches tag-based registry semantics and addresses the earlier discussion about other package types with mutable versions.
    • Handlers such as Helm that previously allowed silent replacement of an existing version now inherit protection through the shared service layer.
    • The check runs before dao.persist() and compares SHA-256 hashes from existing blob references, which is the right invariant.
    • HTTP 409 (SC_CONFLICT) is an appropriate response.

    Minor notes (non-blocking)

    • Maven keeps a separate enforcement path because it passes null for packBlobs; that split is reasonable given how Maven tracks blobs via MavenData.
    • No automated tests were added; the logic is straightforward, but regression tests around redeploy rejection would be a useful follow-up.

    Approved.

  • Work Horse approved 3 days ago
  • Robin Shen merged 3 days ago
1/1
Submitter Chief Work Horse
Target main
Source issue-2265-prevent-maven-redeploy
Reviewers
Merge Strategy
Create Merge Commit
Watchers (2)
Reference
pull request OD-79
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover