fix(spurctld): use correct namespace when creating leader election Lease#81
Merged
shiv-tyagi merged 2 commits intoROCm:mainfrom Apr 14, 2026
Merged
Conversation
The Lease object's namespace was set to `leases.resource_url()` which returns the full API path (e.g. "coordination.k8s.io/v1/namespaces/spur/leases") instead of the actual namespace string. This caused a 400 BadRequest on every Lease creation attempt, making leader election non-functional. Pass the namespace through to try_acquire() and use it directly. Made-with: Cursor
Verifies that spurctld with --enable-leader-election creates the K8s Lease, acquires leadership without errors, and the Lease lands in the correct namespace. Made-with: Cursor
bf22f30 to
b1df087
Compare
cfb758a to
87f2b74
Compare
Member
Author
|
This fixes what we have today but I filed #82 to suggest some design improvements. |
powderluv
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
try_acquire()set the LeaseObjectMeta.namespacetoleases.resource_url()which returns the full K8s API path (e.g./apis/coordination.k8s.io/v1/namespaces/spur/leases) instead of just"spur"400 BadRequest("the namespace of the provided object does not match the namespace sent on the request") on every Lease creation attempt, making leader election permanently broken on fresh deploymentsFix
Pass the namespace string through to
try_acquire()and use it directly in the LeaseObjectMetainstead of callingresource_url().Before (main branch)
spurctld stuck in infinite retry loop — never acquires leadership:

After (this PR)
Lease created and acquired on first attempt:

Testing
cargo test)k8s_test.sh) that verifies:--enable-leader-electionspurctld-leaderLease is created in the correct namespace