-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add mechanism to override drainability status #6196
Add mechanism to override drainability status #6196
Conversation
/assign x13n |
71d2546
to
8b9f8a1
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.
Just minor comments, this looks like a reasonable mechanism.
}, | ||
"override no match": { | ||
rules: Rules{ | ||
fakeRule{drainability.Status{ |
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.
nit: How about drainability.NewDrainableStatus(drainability.OverridingOnly(drainability.SkipDrain))
? Or is it not really easier to read?
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.
I think they're both quite readable. I would argue the opposite and say that the constructors in the drainability package are unnecessary boilerplate. Since drainability.Status
is already exported, the following are identical:
status := drainability.NewBlockedStatus(reason, err)
status := &drainability.Status{
Reason: reason,
Error: err,
}
The latter is better because it's explicit about parameters and requires no additional boilerplate when new fields are added to the struct.
} | ||
for _, candidate := range candidates { | ||
for _, override := range candidate.Overrides { | ||
if status.Outcome == override { |
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.
Maybe worth logging the fact that override happened? At least at V(5)
? This logic becomes non-trivial with this change, so some observability wouldn't hurt.
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.
Great idea. Added a Name() to the Rule interface to make this log more useful.
3fbaa8f
to
a0d56b3
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: artemvmin, x13n The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The interface changed in kubernetes#6196 but the Rules class didn't
The interface changed in kubernetes#6196 but the Rules class didn't
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds a mechanism for one rule to selectively override other rules. This allows for custom rules that override some outcomes (e.g. BlockDrain -> DrainOk) while not overriding others (e.g. SkipDrain).
Does this PR introduce a user-facing change?