ProbeTerminationGracePeriod promote to GA
This commit is contained in:
		| @@ -495,7 +495,7 @@ func dropDisabledFields( | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if !utilfeature.DefaultFeatureGate.Enabled(features.ProbeTerminationGracePeriod) && !probeGracePeriodInUse(oldPodSpec) { | 	if !probeGracePeriodInUse(oldPodSpec) { | ||||||
| 		// Set pod-level terminationGracePeriodSeconds to nil if the feature is disabled and it is not used | 		// 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 { | 		VisitContainers(podSpec, AllContainers, func(c *api.Container, containerType ContainerType) bool { | ||||||
| 			if c.LivenessProbe != nil { | 			if c.LivenessProbe != nil { | ||||||
|   | |||||||
| @@ -944,107 +944,6 @@ func TestDropDynamicResourceAllocation(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func TestDropProbeGracePeriod(t *testing.T) { |  | ||||||
| 	podWithProbeGracePeriod := func() *api.Pod { |  | ||||||
| 		livenessGracePeriod := int64(10) |  | ||||||
| 		livenessProbe := api.Probe{TerminationGracePeriodSeconds: &livenessGracePeriod} |  | ||||||
| 		startupGracePeriod := int64(10) |  | ||||||
| 		startupProbe := api.Probe{TerminationGracePeriodSeconds: &startupGracePeriod} |  | ||||||
| 		return &api.Pod{ |  | ||||||
| 			Spec: api.PodSpec{ |  | ||||||
| 				RestartPolicy: api.RestartPolicyNever, |  | ||||||
| 				Containers:    []api.Container{{Name: "container1", Image: "testimage", LivenessProbe: &livenessProbe, StartupProbe: &startupProbe}}, |  | ||||||
| 			}, |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| 	podWithoutProbeGracePeriod := func() *api.Pod { |  | ||||||
| 		p := podWithProbeGracePeriod() |  | ||||||
| 		p.Spec.Containers[0].LivenessProbe.TerminationGracePeriodSeconds = nil |  | ||||||
| 		p.Spec.Containers[0].StartupProbe.TerminationGracePeriodSeconds = nil |  | ||||||
| 		return p |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	podInfo := []struct { |  | ||||||
| 		description    string |  | ||||||
| 		hasGracePeriod bool |  | ||||||
| 		pod            func() *api.Pod |  | ||||||
| 	}{ |  | ||||||
| 		{ |  | ||||||
| 			description:    "has probe-level terminationGracePeriod", |  | ||||||
| 			hasGracePeriod: true, |  | ||||||
| 			pod:            podWithProbeGracePeriod, |  | ||||||
| 		}, |  | ||||||
| 		{ |  | ||||||
| 			description:    "does not have probe-level terminationGracePeriod", |  | ||||||
| 			hasGracePeriod: false, |  | ||||||
| 			pod:            podWithoutProbeGracePeriod, |  | ||||||
| 		}, |  | ||||||
| 		{ |  | ||||||
| 			description:    "only has liveness probe-level terminationGracePeriod", |  | ||||||
| 			hasGracePeriod: true, |  | ||||||
| 			pod: func() *api.Pod { |  | ||||||
| 				p := podWithProbeGracePeriod() |  | ||||||
| 				p.Spec.Containers[0].StartupProbe.TerminationGracePeriodSeconds = nil |  | ||||||
| 				return p |  | ||||||
| 			}, |  | ||||||
| 		}, |  | ||||||
| 		{ |  | ||||||
| 			description:    "is nil", |  | ||||||
| 			hasGracePeriod: false, |  | ||||||
| 			pod:            func() *api.Pod { return nil }, |  | ||||||
| 		}, |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	for _, enabled := range []bool{true, false} { |  | ||||||
| 		for _, oldPodInfo := range podInfo { |  | ||||||
| 			for _, newPodInfo := range podInfo { |  | ||||||
| 				oldPodHasGracePeriod, oldPod := oldPodInfo.hasGracePeriod, oldPodInfo.pod() |  | ||||||
| 				newPodHasGracePeriod, newPod := newPodInfo.hasGracePeriod, newPodInfo.pod() |  | ||||||
| 				if newPod == nil { |  | ||||||
| 					continue |  | ||||||
| 				} |  | ||||||
|  |  | ||||||
| 				t.Run(fmt.Sprintf("feature enabled=%v, old pod %v, new pod %v", enabled, oldPodInfo.description, newPodInfo.description), func(t *testing.T) { |  | ||||||
| 					defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ProbeTerminationGracePeriod, enabled)() |  | ||||||
|  |  | ||||||
| 					var oldPodSpec *api.PodSpec |  | ||||||
| 					if oldPod != nil { |  | ||||||
| 						oldPodSpec = &oldPod.Spec |  | ||||||
| 					} |  | ||||||
| 					dropDisabledFields(&newPod.Spec, nil, oldPodSpec, nil) |  | ||||||
|  |  | ||||||
| 					// old pod should never be changed |  | ||||||
| 					if !reflect.DeepEqual(oldPod, oldPodInfo.pod()) { |  | ||||||
| 						t.Errorf("old pod changed: %v", cmp.Diff(oldPod, oldPodInfo.pod())) |  | ||||||
| 					} |  | ||||||
|  |  | ||||||
| 					switch { |  | ||||||
| 					case enabled || oldPodHasGracePeriod: |  | ||||||
| 						// new pod should not be changed if the feature is enabled, or if the old pod had terminationGracePeriod |  | ||||||
| 						if !reflect.DeepEqual(newPod, newPodInfo.pod()) { |  | ||||||
| 							t.Errorf("new pod changed: %v", cmp.Diff(newPod, newPodInfo.pod())) |  | ||||||
| 						} |  | ||||||
| 					case newPodHasGracePeriod: |  | ||||||
| 						// new pod should be changed |  | ||||||
| 						if reflect.DeepEqual(newPod, newPodInfo.pod()) { |  | ||||||
| 							t.Errorf("new pod was not changed") |  | ||||||
| 						} |  | ||||||
| 						// new pod should not have terminationGracePeriod |  | ||||||
| 						if !reflect.DeepEqual(newPod, podWithoutProbeGracePeriod()) { |  | ||||||
| 							t.Errorf("new pod had probe-level terminationGracePeriod: %v", cmp.Diff(newPod, podWithoutProbeGracePeriod())) |  | ||||||
| 						} |  | ||||||
| 					default: |  | ||||||
| 						// new pod should not need to be changed |  | ||||||
| 						if !reflect.DeepEqual(newPod, newPodInfo.pod()) { |  | ||||||
| 							t.Errorf("new pod changed: %v", cmp.Diff(newPod, newPodInfo.pod())) |  | ||||||
| 						} |  | ||||||
| 					} |  | ||||||
| 				}) |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func TestValidatePodDeletionCostOption(t *testing.T) { | func TestValidatePodDeletionCostOption(t *testing.T) { | ||||||
| 	testCases := []struct { | 	testCases := []struct { | ||||||
| 		name                            string | 		name                            string | ||||||
|   | |||||||
| @@ -6554,8 +6554,6 @@ func TestValidateProbe(t *testing.T) { | |||||||
| } | } | ||||||
|  |  | ||||||
| func Test_validateProbe(t *testing.T) { | func Test_validateProbe(t *testing.T) { | ||||||
| 	defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ProbeTerminationGracePeriod, true)() |  | ||||||
|  |  | ||||||
| 	fldPath := field.NewPath("test") | 	fldPath := field.NewPath("test") | ||||||
| 	type args struct { | 	type args struct { | ||||||
| 		probe   *core.Probe | 		probe   *core.Probe | ||||||
|   | |||||||
| @@ -627,9 +627,10 @@ const ( | |||||||
| 	// Enable users to specify when a Pod is ready for scheduling. | 	// Enable users to specify when a Pod is ready for scheduling. | ||||||
| 	PodSchedulingReadiness featuregate.Feature = "PodSchedulingReadiness" | 	PodSchedulingReadiness featuregate.Feature = "PodSchedulingReadiness" | ||||||
|  |  | ||||||
| 	// owner: @ehashman | 	// owner: @rphillips | ||||||
| 	// alpha: v1.21 | 	// alpha: v1.21 | ||||||
| 	// beta: v1.22 | 	// beta: v1.22 | ||||||
|  | 	// ga: v1.28 | ||||||
| 	// | 	// | ||||||
| 	// Allows user to override pod-level terminationGracePeriod for probes | 	// Allows user to override pod-level terminationGracePeriod for probes | ||||||
| 	ProbeTerminationGracePeriod featuregate.Feature = "ProbeTerminationGracePeriod" | 	ProbeTerminationGracePeriod featuregate.Feature = "ProbeTerminationGracePeriod" | ||||||
| @@ -1021,7 +1022,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS | |||||||
|  |  | ||||||
| 	PodSchedulingReadiness: {Default: true, PreRelease: featuregate.Beta}, | 	PodSchedulingReadiness: {Default: true, PreRelease: featuregate.Beta}, | ||||||
|  |  | ||||||
| 	ProbeTerminationGracePeriod: {Default: true, PreRelease: featuregate.Beta}, // Default to true in beta 1.25 | 	ProbeTerminationGracePeriod: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.29 | ||||||
|  |  | ||||||
| 	ProcMountType: {Default: false, PreRelease: featuregate.Alpha}, | 	ProcMountType: {Default: false, PreRelease: featuregate.Alpha}, | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ryan Phillips
					Ryan Phillips