Skip to content

Handle new objects uniformly#72

Merged
karanthukral merged 3 commits intoreddit:mainfrom
seatgeek:colinodell-fix-generatedname-race-condition
Jul 18, 2025
Merged

Handle new objects uniformly#72
karanthukral merged 3 commits intoreddit:mainfrom
seatgeek:colinodell-fix-generatedname-race-condition

Conversation

@colinodell
Copy link
Copy Markdown
Contributor

@colinodell colinodell commented Jul 17, 2025

Closes #71

💸 TL;DR

This fixes the race condition described in #71 and eliminates two unnecessary client calls for new objects using generatedName

📜 Details

Prior to this PR, new objects using generatedName followed a different code path from those not using this feature. That code path contained a potential race condition if the Get() method immediately following the Create() failed to return the newly-created object. Aligning how we handle both types of new objects avoids this problem.

🧪 Testing Steps / Validation

  • Ran the existing test suite
  • Added a new test covering the creation of generatedName objects
    • Confirmed it passes both with and without my changes, thus confirming no change in overall behavior
  • Tested the changes locally via Kind

(Note that I was unable to replicate the race condition with envtest - only Kind - thus no regression test for the race condition)

✅ Checks

  • CI tests (if present) are passing
  • Adheres to code style for repo
  • Contributor License Agreement (CLA) completed if not a Reddit employee

@colinodell colinodell requested a review from a team as a code owner July 17, 2025 21:19
@colinodell colinodell requested a review from karanthukral July 17, 2025 21:19
@karanthukral
Copy link
Copy Markdown
Contributor

@colinodell thanks for putting up this PR, I'll get this reviewed today

Copy link
Copy Markdown
Contributor

@karanthukral karanthukral left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution

@karanthukral
Copy link
Copy Markdown
Contributor

@colinodell Can I ask you to just update this branch with main, and I'll take care of getting it merged and tagged

@colinodell
Copy link
Copy Markdown
Contributor Author

Updating now. Thanks for the quick review!

@karanthukral karanthukral merged commit 465e493 into reddit:main Jul 18, 2025
1 check passed
@colinodell colinodell deleted the colinodell-fix-generatedname-race-condition branch July 18, 2025 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Race condition causing orphaned resources when using generateName

3 participants