Skip to content

fix: handle existing resources gracefully in create operation #2351 #2353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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 <[email protected]>
@ash01ish ash01ish force-pushed the fix-stale-resource-cleanup branch from 51cc5af to f7bc1a7 Compare April 21, 2025 11:05
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
1 participant