Merge pull request #119381 from gjkim42/fix-e2e-tests-overriding-grace-period-when-probe-is-set

Fix e2e tests for overriding timoutGracePeriodSeconds when probe is set
This commit is contained in:
Kubernetes Prow Robot 2023-07-17 16:55:18 -07:00 committed by GitHub
commit a9b3ca34b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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. 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) { 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") cmd := []string{"/bin/sh", "-c", "sleep 1000"}
longGracePeriod := int64(500)
pod.Spec.TerminationGracePeriodSeconds = &longGracePeriod
// probe will fail since pod has no http endpoints // probe will fail since pod has no http endpoints
shortGracePeriod := int64(5) shortGracePeriod := int64(5)
pod.Spec.Containers[0].LivenessProbe = &v1.Probe{ livenessProbe := &v1.Probe{
ProbeHandler: v1.ProbeHandler{ ProbeHandler: v1.ProbeHandler{
HTTPGet: &v1.HTTPGetAction{ HTTPGet: &v1.HTTPGetAction{
Path: "/healthz", Path: "/healthz",
@ -477,10 +474,14 @@ var _ = SIGDescribe("Probing container", func() {
FailureThreshold: 1, FailureThreshold: 1,
TerminationGracePeriodSeconds: &shortGracePeriod, 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 // 10s delay + 10s period + 5s grace period = 25s < 30s << pod-level timeout 500
// add 10s more for kubelet syncing information to apiserver // add defaultObservationTimeout(4min) more for kubelet syncing information
RunLivenessTest(ctx, f, pod, 1, time.Second*40) // to apiserver
RunLivenessTest(ctx, f, pod, 1, time.Second*40+defaultObservationTimeout)
}) })
/* /*
@ -489,20 +490,9 @@ 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. 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) { 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"}
longGracePeriod := int64(500) // probe will fail since pod has no http endpoints
pod.Spec.TerminationGracePeriodSeconds = &longGracePeriod livenessProbe := &v1.Probe{
// 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{ ProbeHandler: v1.ProbeHandler{
Exec: &v1.ExecAction{ Exec: &v1.ExecAction{
Command: []string{"/bin/true"}, Command: []string{"/bin/true"},
@ -511,10 +501,22 @@ var _ = SIGDescribe("Probing container", func() {
InitialDelaySeconds: 15, InitialDelaySeconds: 15,
FailureThreshold: 1, FailureThreshold: 1,
} }
pod := busyBoxPodSpec(nil, livenessProbe, cmd)
longGracePeriod := int64(500)
pod.Spec.TerminationGracePeriodSeconds = &longGracePeriod
shortGracePeriod := int64(5)
pod.Spec.Containers[0].StartupProbe = &v1.Probe{
ProbeHandler: execHandler([]string{"/bin/cat", "/tmp/startup"}),
InitialDelaySeconds: 10,
FailureThreshold: 1,
TerminationGracePeriodSeconds: &shortGracePeriod,
}
// 10s delay + 10s period + 5s grace period = 25s < 30s << pod-level timeout 500 // 10s delay + 10s period + 5s grace period = 25s < 30s << pod-level timeout 500
// add 10s more for kubelet syncing information to apiserver // add defaultObservationTimeout(4min) more for kubelet syncing information
RunLivenessTest(ctx, f, pod, 1, time.Second*40) // to apiserver
RunLivenessTest(ctx, f, pod, 1, time.Second*40+defaultObservationTimeout)
}) })
/* /*