fix(scheduler): respect HAMI_NODELOCK_EXPIRE env when --node-lock-timeout flag is absent - #2743
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Siraryansingh The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe scheduler passes its Cobra command to ChangesScheduler timeout precedence
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The scheduler now honors the explicit node-lock timeout flag before the environment setting and default, with no actionable merge-blocking risk remaining after normal checks and review. Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
hey, just wanted to give some context on how i found this. i was going through the open issues and #2692 caught my eye. i traced the flow from the helm chart ( the fix is small - just pass the i saw that #2721 and #2722 tried to fix the same issue. i came across it independently while looking through open bugs - happy to answer any questions about the approach or the code. also adding an AI disclosure since the guidelines require it: i used gemini to help navigate the codebase and understand the flag registration flow, but the root cause analysis and fix were done by me with AI assistance. i can explain any part of the change if needed. |
| // explicitly passed on the command line. When the flag is absent, the value | ||
| // parsed from the HAMI_NODELOCK_EXPIRE environment variable (set by the | ||
| // Helm chart's scheduler.nodeLockExpire) in nodelock.init() is preserved. | ||
| if cmd.Flags().Changed("node-lock-timeout") { |
There was a problem hiding this comment.
no test for the fix, the listed nodelock test does not cover this branch. extract it into a helper taking a bool and add a regression test for flag set, env only, neither.
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 7 files with indirect coverage changes 🚀 New features to boost your workflow:
|
…-timeout flag is not passed The --node-lock-timeout flag's default value (5m) unconditionally overwrites the NodeLockTimeout set by nodelock.init() from the HAMI_NODELOCK_EXPIRE environment variable. This makes the Helm chart's scheduler.nodeLockExpire setting completely ineffective — the timeout is always 5 minutes regardless of the env var value. Use cobra's Flags().Changed() to detect whether the user explicitly passed --node-lock-timeout on the command line. When the flag is absent, preserve the value already parsed from HAMI_NODELOCK_EXPIRE. Precedence after this fix: 1. --node-lock-timeout flag (highest, explicit CLI) 2. HAMI_NODELOCK_EXPIRE env var (Helm chart / container env) 3. Built-in default of 5 minutes (lowest) Fixes Project-HAMi#2692 Signed-off-by: Aryan Singh <aryansingh.as1012@gmail.com>
bb59ec4 to
f3a4f92
Compare
|
@mesutoezdil thanks for the review. I extracted the resolution logic into
All tests in |
|
This is being closed because it does not comply with the contribution guidelines. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The Helm chart has
scheduler.nodeLockExpirewhich setsHAMI_NODELOCK_EXPIREenv var on the scheduler pod. The nodelock package reads this ininit()and setsNodeLockTimeoutcorrectly. But then instart(), we do:config.NodeLockTimeoutcomes from the--node-lock-timeoutcobra flag which defaults to 5m. Since cobra always fills in the default even when the flag isn't passed, this line overwrites whatever the env var set. Soscheduler.nodeLockExpirein the Helm chart literally does nothing.I used
cmd.Flags().Changed("node-lock-timeout")to check if the flag was actually passed by the user. If it was, use the flag value. If not, keep whateverinit()set from the env var.After this fix the precedence is:
--node-lock-timeoutflag (if explicitly passed)HAMI_NODELOCK_EXPIREenv varFixes #2692
AI Disclosure: I used Gemini to help explore the codebase and understand the cobra flag flow, but I identified the root cause myself by tracing through
nodelock.goinit ->main.gostart. The fix and testing were done with AI assistance.How was this tested?
go build ./cmd/scheduler/...passesgo test ./pkg/util/nodelock/... -run TestSetupNodeLockTimeoutpassesSummary by CodeRabbit
Bug Fixes
Tests