mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 15:58:37 +00:00
reset resultRun on pod restart
This commit is contained in:
parent
6f7eac63c2
commit
2c866a7aaa
@ -224,6 +224,7 @@ func (w *worker) doProbe() (keepGoing bool) {
|
||||
// chance of hitting #21751, where running `docker exec` when a
|
||||
// container is being stopped may lead to corrupted container state.
|
||||
w.onHold = true
|
||||
w.resultRun = 1
|
||||
}
|
||||
|
||||
return true
|
||||
|
@ -341,3 +341,44 @@ func TestOnHoldOnLivenessCheckFailure(t *testing.T) {
|
||||
t.Errorf("Prober should not be on hold anymore")
|
||||
}
|
||||
}
|
||||
|
||||
func TestResultRunOnLivenessCheckFailure(t *testing.T) {
|
||||
m := newTestManager()
|
||||
w := newTestWorker(m, liveness, v1.Probe{SuccessThreshold: 1, FailureThreshold: 3})
|
||||
m.statusManager.SetPodStatus(w.pod, getTestRunningStatus())
|
||||
|
||||
m.prober.exec = fakeExecProber{probe.Success, nil}
|
||||
msg := "inital probe success"
|
||||
expectContinue(t, w, w.doProbe(), msg)
|
||||
expectResult(t, w, results.Success, msg)
|
||||
if w.resultRun != 1 {
|
||||
t.Errorf("Prober resultRun should 1")
|
||||
}
|
||||
|
||||
m.prober.exec = fakeExecProber{probe.Failure, nil}
|
||||
msg = "probe failure, result success"
|
||||
expectContinue(t, w, w.doProbe(), msg)
|
||||
expectResult(t, w, results.Success, msg)
|
||||
if w.resultRun != 1 {
|
||||
t.Errorf("Prober resultRun should 1")
|
||||
}
|
||||
|
||||
m.prober.exec = fakeExecProber{probe.Failure, nil}
|
||||
msg = "2nd probe failure, result success"
|
||||
expectContinue(t, w, w.doProbe(), msg)
|
||||
expectResult(t, w, results.Success, msg)
|
||||
if w.resultRun != 2 {
|
||||
t.Errorf("Prober resultRun should be 2")
|
||||
}
|
||||
|
||||
// Exceeding FailureThreshold should cause resultRun to
|
||||
// reset to 1 so that the probe on the restarted pod
|
||||
// also gets FailureThreshold attempts to succeed.
|
||||
m.prober.exec = fakeExecProber{probe.Failure, nil}
|
||||
msg = "3rd probe failure, result failure"
|
||||
expectContinue(t, w, w.doProbe(), msg)
|
||||
expectResult(t, w, results.Failure, msg)
|
||||
if w.resultRun != 1 {
|
||||
t.Errorf("Prober resultRun should be reset to 1")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user