Skip to content

Commit

Permalink
Merge pull request kubernetes#119381 from gjkim42/fix-e2e-tests-overr…
Browse files Browse the repository at this point in the history
…iding-grace-period-when-probe-is-set

Fix e2e tests for overriding timoutGracePeriodSeconds when probe is set
  • Loading branch information
k8s-ci-robot committed Jul 17, 2023
2 parents 7049708 + 48eee4e commit a9b3ca3
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions test/e2e/common/node/container_probe.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,13 +460,10 @@ var _ = SIGDescribe("Probing container", func() {
Description: A pod with a long terminationGracePeriod is created with a shorter livenessProbe-level terminationGracePeriodSeconds. We confirm the shorter termination period is used.
*/
ginkgo.It("should override timeoutGracePeriodSeconds when LivenessProbe field is set [NodeConformance]", func(ctx context.Context) {
pod := e2epod.NewAgnhostPod(f.Namespace.Name, "liveness-override-"+string(uuid.NewUUID()), nil, nil, nil, "/bin/sh", "-c", "sleep 1000")
longGracePeriod := int64(500)
pod.Spec.TerminationGracePeriodSeconds = &longGracePeriod

cmd := []string{"/bin/sh", "-c", "sleep 1000"}
// probe will fail since pod has no http endpoints
shortGracePeriod := int64(5)
pod.Spec.Containers[0].LivenessProbe = &v1.Probe{
livenessProbe := &v1.Probe{
ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{
Path: "/healthz",
Expand All @@ -477,10 +474,14 @@ var _ = SIGDescribe("Probing container", func() {
FailureThreshold: 1,
TerminationGracePeriodSeconds: &shortGracePeriod,
}
pod := busyBoxPodSpec(nil, livenessProbe, cmd)
longGracePeriod := int64(500)
pod.Spec.TerminationGracePeriodSeconds = &longGracePeriod

// 10s delay + 10s period + 5s grace period = 25s < 30s << pod-level timeout 500
// add 10s more for kubelet syncing information to apiserver
RunLivenessTest(ctx, f, pod, 1, time.Second*40)
// add defaultObservationTimeout(4min) more for kubelet syncing information
// to apiserver
RunLivenessTest(ctx, f, pod, 1, time.Second*40+defaultObservationTimeout)
})

/*
Expand All @@ -489,32 +490,33 @@ var _ = SIGDescribe("Probing container", func() {
Description: A pod with a long terminationGracePeriod is created with a shorter startupProbe-level terminationGracePeriodSeconds. We confirm the shorter termination period is used.
*/
ginkgo.It("should override timeoutGracePeriodSeconds when StartupProbe field is set [NodeConformance]", func(ctx context.Context) {
pod := e2epod.NewAgnhostPod(f.Namespace.Name, "startup-override-"+string(uuid.NewUUID()), nil, nil, nil, "/bin/sh", "-c", "sleep 1000")
cmd := []string{"/bin/sh", "-c", "sleep 1000"}
// probe will fail since pod has no http endpoints
livenessProbe := &v1.Probe{
ProbeHandler: v1.ProbeHandler{
Exec: &v1.ExecAction{
Command: []string{"/bin/true"},
},
},
InitialDelaySeconds: 15,
FailureThreshold: 1,
}
pod := busyBoxPodSpec(nil, livenessProbe, cmd)
longGracePeriod := int64(500)
pod.Spec.TerminationGracePeriodSeconds = &longGracePeriod

// startup probe will fail since pod will sleep for 1000s before becoming ready
shortGracePeriod := int64(5)
pod.Spec.Containers[0].StartupProbe = &v1.Probe{
ProbeHandler: execHandler([]string{"/bin/cat", "/tmp/startup"}),
InitialDelaySeconds: 10,
FailureThreshold: 1,
TerminationGracePeriodSeconds: &shortGracePeriod,
}
// liveness probe always succeeds
pod.Spec.Containers[0].LivenessProbe = &v1.Probe{
ProbeHandler: v1.ProbeHandler{
Exec: &v1.ExecAction{
Command: []string{"/bin/true"},
},
},
InitialDelaySeconds: 15,
FailureThreshold: 1,
}

// 10s delay + 10s period + 5s grace period = 25s < 30s << pod-level timeout 500
// add 10s more for kubelet syncing information to apiserver
RunLivenessTest(ctx, f, pod, 1, time.Second*40)
// add defaultObservationTimeout(4min) more for kubelet syncing information
// to apiserver
RunLivenessTest(ctx, f, pod, 1, time.Second*40+defaultObservationTimeout)
})

/*
Expand Down

0 comments on commit a9b3ca3

Please sign in to comment.