-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
kubelet: Make probe to be on for time drift #123898
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -70,6 +70,13 @@ type worker struct { | |
// If set, skip probing. | ||
onHold bool | ||
|
||
// Set to true when time drift is detected for the pod, will be unset | ||
// once container's elapsed start time reaches +ve value. | ||
timeDrift bool | ||
// timeDriftStartTimeInSec contains container's elapsed start time at | ||
// the time of first occurance of time drift. | ||
timeDriftStartTimeInSec float64 | ||
|
||
// proberResultsMetricLabels holds the labels attached to this worker | ||
// for the ProberResults metric by result. | ||
proberResultsSuccessfulMetricLabels metrics.Labels | ||
|
@@ -265,8 +272,21 @@ func (w *worker) doProbe(ctx context.Context) (keepGoing bool) { | |
return false | ||
} | ||
|
||
// Probe disabled for InitialDelaySeconds. | ||
if int32(time.Since(c.State.Running.StartedAt.Time).Seconds()) < w.spec.InitialDelaySeconds { | ||
// Probe disabled for InitialDelaySeconds. This also considers | ||
// time drift scenario (in that case container's started time is | ||
// later than system current time). | ||
startedAtInSecs := time.Since(c.State.Running.StartedAt.Time).Seconds() | ||
if startedAtInSecs <= 0 && !w.timeDrift { | ||
w.timeDrift = true | ||
w.timeDriftStartTimeInSec = startedAtInSecs | ||
} else if startedAtInSecs > 0 { | ||
w.timeDrift = false | ||
} | ||
if startedAtInSecs <= 0 && w.timeDrift && | ||
int32(startedAtInSecs-w.timeDriftStartTimeInSec) < w.spec.InitialDelaySeconds { | ||
return true | ||
} | ||
if startedAtInSecs > 0 && int32(startedAtInSecs) < w.spec.InitialDelaySeconds { | ||
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. Would it make sense to wait 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. @bart0sh good point, but would that happen (i.e. pod startup followed by immediate time drift event before 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. My point was that if 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. ok @bart0sh , added code to wait for |
||
return true | ||
} | ||
|
||
|
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.