-
Notifications
You must be signed in to change notification settings - Fork 17
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
[WIP] Dynamiclly set safe time to assume node rebooted seconds #197
Changes from all commits
617924b
f01a339
1410563
46c4744
98b9a51
f47da60
9f47e0a
916e9f1
df5d35a
d200dce
d16195a
9196575
0ca7523
8bdbfa9
6d05fa3
11e21a7
ac1b238
057f2e5
db71444
bf88778
04a6964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,12 +30,13 @@ import ( | |
|
||
// fields names | ||
const ( | ||
peerApiServerTimeout = "PeerApiServerTimeout" | ||
apiServerTimeout = "ApiServerTimeout" | ||
peerDialTimeout = "PeerDialTimeout" | ||
peerRequestTimeout = "PeerRequestTimeout" | ||
apiCheckInterval = "ApiCheckInterval" | ||
peerUpdateInterval = "PeerUpdateInterval" | ||
peerApiServerTimeout = "PeerApiServerTimeout" | ||
apiServerTimeout = "ApiServerTimeout" | ||
peerDialTimeout = "PeerDialTimeout" | ||
peerRequestTimeout = "PeerRequestTimeout" | ||
apiCheckInterval = "ApiCheckInterval" | ||
peerUpdateInterval = "PeerUpdateInterval" | ||
safeTimeToAssumeNodeRebootedSeconds = "SafeTimeToAssumeNodeRebootedSeconds" | ||
) | ||
|
||
// minimal time durations allowed for fields | ||
|
@@ -85,6 +86,7 @@ func (r *SelfNodeRemediationConfig) ValidateUpdate(_ runtime.Object) error { | |
return errors.NewAggregate([]error{ | ||
r.validateTimes(), | ||
r.validateCustomTolerations(), | ||
r.validateMinRebootTime(), | ||
}) | ||
} | ||
|
||
|
@@ -172,3 +174,19 @@ func validateToleration(toleration v1.Toleration) error { | |
} | ||
return nil | ||
} | ||
|
||
func (r *SelfNodeRemediationConfig) validateMinRebootTime() error { | ||
if r.Status.MinSafeTimeToAssumeNodeRebootedSeconds == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. depending a on status field being set is very weird, see comment below There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's depending on the calculated value of Does it bother you because you consider Status fields user informational only ?
Not sure which one do you mean 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was referring to this comment ("below" as "in a comment for a later line of code 😉" ) : #197 (comment) It's weird that validation fails because a status field (or annotation, doesn't matter) isn't set yet, isn't it? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think so, IMO we should consider two main factors:
Hmm good to know ! I didn't even consider the warning when I've added that piece of code - I just needed a customized validator that can has access to the client. |
||
return fmt.Errorf("failed to verify min value of SafeRebootTimeSec, Status.MinSafeTimeToAssumeNodeRebootedSeconds should not be empty") | ||
} | ||
|
||
//allow removing this optional field | ||
if r.Spec.SafeTimeToAssumeNodeRebootedSeconds == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now I understand the change of the minValue from 0 to 1. But IMHO using 0 as indication for "not set" is error prone. The field should be a pointer when it's optional IMHO...? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, I'm just not sure regarding whether this qualifies as an API change or not 🤔 , WDTY ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't consider making a field optional as API change. The other way around I would. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically I don't think we are making the field optional since IIRC it's optional by default in case it doesn't have What I was worried of is changing from |
||
return nil | ||
} | ||
|
||
if r.Status.MinSafeTimeToAssumeNodeRebootedSeconds > r.Spec.SafeTimeToAssumeNodeRebootedSeconds { | ||
return fmt.Errorf("can not set SafeTimeToAssumeNodeRebootedSeconds value below the calculated minimum value of: %d", r.Status.MinSafeTimeToAssumeNodeRebootedSeconds) | ||
} | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
in theory at least this can be considered as an API change. It makes CRs with 0 values invalid...
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.
[Context] I've added this change in order to differentiate between 0 value which is just the default (when field is empty) and 0 value field in by the user (This differentiation was needed in the webhook).
That's a good point, after some thinking I think we are still in the clear though.
Here is my line of thought:
SafeTimeToAssumeNodeRebootedSeconds
.SafeTimeToAssumeNodeRebootedSeconds
(that was set to 0) after an upgrade