-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix Negative Requeue Duration in getStatusCheckDelay #1841
Conversation
78b3af6
to
2eec8c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good but the tests is 5 times more complicated than the code it tests and will be hard to maintain.
How controller runtime handle negative requeue time? maybe it already clip the value to 0 and does the right thing? If it does, we don't need to complicate the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is in the controller_test package, which is good for black box testing. For testing a private function we can use a test using the controllers package.
The fix is trivial but testing is it hard and will take time to get right. I would separate the test to another PR and merge the trivial fix now. |
087ec23
to
97434e6
Compare
@OdedViner please squash the commits |
97434e6
to
0a2f658
Compare
done |
return 0 | ||
} | ||
|
||
return remaining |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simplify this to:
return max(0, remaining)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
b544346
to
81fc221
Compare
…ntrol Reconciler Signed-off-by: Oded Viner <[email protected]>
81fc221
to
8939b10
Compare
This PR fixes an issue in the
getStatusCheckDelay
function where a negative requeue duration could be returned if the scheduled time had already passed. The fix ensures that if the computed remaining time is negative, the function returns 0 to trigger an immediate requeue instead of a negative duration.Changes:
Added a check to prevent negative requeue durations.
If the computed duration is negative, it now returns 0.
This improves the stability of the reconciliation loop and prevents unexpected scheduling behavior.
Fix: #1838