Skip to content

Conversation

@ash01ish
Copy link

When a test exits unexpectedly after creating resources, those resources aren't cleaned up. When the test is run again, it detects the existing resources but returns an error instead of cleaning them up, leaving them stale indefinitely.

This change modifies the tryCreateResource method to not return an error when a resource already exists, but instead continue with the operation. This ensures that pre-existing resources are properly cleaned up at the end of the test.

Fixes #2351

Explanation

Related issue

Proposed Changes

Checklist

  • [x ] I have read the contributing guidelines.
  • [x ] I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • [ x] This is a bug fix and I have added unit tests that prove my fix is effective.

Further Comments

@ash01ish ash01ish force-pushed the fix-stale-resource-cleanup branch from ff40554 to 51cc5af Compare April 17, 2025 17:05
@ash01ish ash01ish changed the title fix: handle existing resources gracefully in create operation #2351 fix: handle existing resources gracefully in create operation #2351 Apr 17, 2025
@ash01ish ash01ish marked this pull request as ready for review April 17, 2025 17:06
@ash01ish ash01ish requested a review from a team as a code owner April 17, 2025 17:06
…#2351

When a test exits unexpectedly after creating resources, those resources
aren't cleaned up. When the test is run again, it detects the existing
resources but returns an error instead of cleaning them up, leaving them
stale indefinitely.

This change modifies the tryCreateResource method to not return an error
when a resource already exists, but instead continue with the operation.
This ensures that pre-existing resources are properly cleaned up at the
end of the test.

Fixes kyverno#2351

Signed-off-by: Ashish Thirunagari <53890434+ash01ish@users.noreply.github.com>
@ash01ish ash01ish force-pushed the fix-stale-resource-cleanup branch from 51cc5af to f7bc1a7 Compare April 21, 2025 11:05
@eddycharly
Copy link
Member

Thanks for your contribution !
Unfortunately i don't think this is a valid approach for create. The operation clearly indicates that the resource should not exist and be created, allowing an existing resource to be present doesn't sound right to me.

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.

[Bug] stale resource not cleaned up

2 participants