Skip to content

Fix deletion of in-use artifacts and namespaces - #429

Merged
stefanprodan merged 4 commits into
mainfrom
fix-gc-current-artifact
Dec 2, 2026
Merged

stefanprodan merged 4 commits into
mainfrom
fix-gc-current-artifact

Conversation

@stefanprodan

@stefanprodan stefanprodan commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Fixes: #427

  • Exclude the current artifact from garbage collection, whatever its age and the retention policy
  • Skip pruning of ExternalArtifacts and managed namespaces taken over by another ArtifactGenerator
  • Delete the ExternalArtifact object before its storage, so that a rejected deletion doesn't leave it without its artifact
  • Prevent ArtifactGenerators that publish the same ExternalArtifact from removing each other's artifacts: the busy one is marked as DependencyNotReady and requeued
  • Document how to move an ExternalArtifact between ArtifactGenerators

Behavior changes:

  • Pruning ExternalArtifacts requires the get verb on the ServiceAccount, in addition to delete
  • Namespaces labeled by a previous ArtifactGenerator are not pruned until they are applied again

Closes: #428

The garbage collector was given a wildcard filename, which it compares
literally, so the current artifact was never excluded. When a
reconciliation took longer than the retention TTL, the artifacts it
had just built were deleted while the ExternalArtifacts were Ready.

Pass the filename of the current artifact instead.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Dropping an output, or deleting the generator, removed the
ExternalArtifact and its storage even when another ArtifactGenerator
had taken it over. The storage was also removed when the API server
rejected the deletion of the object, leaving it without its artifact.

Verify the owner before pruning and delete the object before its
storage, guarding the deletion against a concurrent takeover. The
owner is matched by source reference too, so that recreated generators
can still prune. Reading the owner requires the get verb, while the
delete verb is no longer required for taken over objects.

Document how to move an ExternalArtifact between generators.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
When two ArtifactGenerators published the same ExternalArtifact, the
garbage collection or pruning of one could remove the artifact that
the other had just built or published.

Hold a lock per ExternalArtifact until the end of the reconciliation.
When an ExternalArtifact is locked by another generator, mark the
object as not ready and requeue it, instead of blocking the worker.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Dropping a managed namespace, or deleting the generator, with pruning
enabled deleted the namespace and everything in it, even when another
ArtifactGenerator had taken it over.

Verify the owner label before deleting. Replace the deletion made with
the SSA manager with a direct call that has the same exclusions and
propagation policy, guarded by preconditions, so that a change made
after the verification results in a conflict that is retried.

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
@stefanprodan

Copy link
Copy Markdown
Member Author

I'll backport this by hand to v2.3.x due to conflicts.

@stefanprodan stefanprodan added the bug Something isn't working label Dec 1, 2026

@matheuscscp matheuscscp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stefanprodan
stefanprodan merged commit c851ac8 into main Dec 2, 2026
6 checks passed
@stefanprodan
stefanprodan deleted the fix-gc-current-artifact branch December 2, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArtifactGenerator deletes its current artifacts when a reconciliation takes longer than the retention TTL

2 participants