From 6aeff13def37a7ba476aa5afd90c588747662cc4 Mon Sep 17 00:00:00 2001 From: Gunju Kim Date: Tue, 18 Jul 2023 00:52:57 +0900 Subject: [PATCH] Never drop the `terminationGracePeriodSeconds` of a probe --- pkg/api/pod/util.go | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/pkg/api/pod/util.go b/pkg/api/pod/util.go index 3d33c50d034..ebc0a6b3d9c 100644 --- a/pkg/api/pod/util.go +++ b/pkg/api/pod/util.go @@ -516,20 +516,6 @@ func dropDisabledFields( } } - if !probeGracePeriodInUse(oldPodSpec) { - // Set pod-level terminationGracePeriodSeconds to nil if the feature is disabled and it is not used - VisitContainers(podSpec, AllContainers, func(c *api.Container, containerType ContainerType) bool { - if c.LivenessProbe != nil { - c.LivenessProbe.TerminationGracePeriodSeconds = nil - } - if c.StartupProbe != nil { - c.StartupProbe.TerminationGracePeriodSeconds = nil - } - // cannot be set for readiness probes - return true - }) - } - // If the feature is disabled and not in use, drop the hostUsers field. if !utilfeature.DefaultFeatureGate.Enabled(features.UserNamespacesSupport) && !hostUsersInUse(oldPodSpec) { // Drop the field in podSpec only if SecurityContext is not nil. @@ -827,27 +813,6 @@ func appArmorInUse(podAnnotations map[string]string) bool { return false } -// probeGracePeriodInUse returns true if the pod spec is non-nil and has a probe that makes use -// of the probe-level terminationGracePeriodSeconds feature -func probeGracePeriodInUse(podSpec *api.PodSpec) bool { - if podSpec == nil { - return false - } - - var inUse bool - VisitContainers(podSpec, AllContainers, func(c *api.Container, containerType ContainerType) bool { - // cannot be set for readiness probes - if (c.LivenessProbe != nil && c.LivenessProbe.TerminationGracePeriodSeconds != nil) || - (c.StartupProbe != nil && c.StartupProbe.TerminationGracePeriodSeconds != nil) { - inUse = true - return false - } - return true - }) - - return inUse -} - // schedulingGatesInUse returns true if the pod spec is non-nil and it has SchedulingGates field set. func schedulingGatesInUse(podSpec *api.PodSpec) bool { if podSpec == nil {