mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	add feature gate
This commit is contained in:
		@@ -1482,7 +1482,10 @@ func (jm *Controller) manageJob(ctx context.Context, job *batch.Job, activePods
 | 
				
			|||||||
					if completionIndex != unknownCompletionIndex {
 | 
										if completionIndex != unknownCompletionIndex {
 | 
				
			||||||
						template = podTemplate.DeepCopy()
 | 
											template = podTemplate.DeepCopy()
 | 
				
			||||||
						addCompletionIndexAnnotation(template, completionIndex)
 | 
											addCompletionIndexAnnotation(template, completionIndex)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
											if feature.DefaultFeatureGate.Enabled(features.PodIndexLabel) {
 | 
				
			||||||
							addCompletionIndexLabel(template, completionIndex)
 | 
												addCompletionIndexLabel(template, completionIndex)
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
						template.Spec.Hostname = fmt.Sprintf("%s-%d", job.Name, completionIndex)
 | 
											template.Spec.Hostname = fmt.Sprintf("%s-%d", job.Name, completionIndex)
 | 
				
			||||||
						generateName = podGenerateNameWithIndex(job.Name, completionIndex)
 | 
											generateName = podGenerateNameWithIndex(job.Name, completionIndex)
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -962,7 +962,9 @@ func checkIndexedJobPods(t *testing.T, control *controller.FakePodControl, wantI
 | 
				
			|||||||
	gotIndexes := sets.New[int]()
 | 
						gotIndexes := sets.New[int]()
 | 
				
			||||||
	for _, p := range control.Templates {
 | 
						for _, p := range control.Templates {
 | 
				
			||||||
		checkJobCompletionEnvVariable(t, &p.Spec)
 | 
							checkJobCompletionEnvVariable(t, &p.Spec)
 | 
				
			||||||
 | 
							if feature.DefaultFeatureGate.Enabled(features.PodIndexLabel) {
 | 
				
			||||||
			checkJobCompletionLabel(t, &p)
 | 
								checkJobCompletionLabel(t, &p)
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		ix := getCompletionIndex(p.Annotations)
 | 
							ix := getCompletionIndex(p.Annotations)
 | 
				
			||||||
		if ix == -1 {
 | 
							if ix == -1 {
 | 
				
			||||||
			t.Errorf("Created pod %s didn't have completion index", p.Name)
 | 
								t.Errorf("Created pod %s didn't have completion index", p.Name)
 | 
				
			||||||
@@ -4395,6 +4397,7 @@ func TestFinalizersRemovedExpectations(t *testing.T) {
 | 
				
			|||||||
		t.Errorf("Timeout waiting for expectations (-want, +got):\n%s", diff)
 | 
							t.Errorf("Timeout waiting for expectations (-want, +got):\n%s", diff)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func checkJobCompletionLabel(t *testing.T, p *v1.PodTemplateSpec) {
 | 
					func checkJobCompletionLabel(t *testing.T, p *v1.PodTemplateSpec) {
 | 
				
			||||||
	t.Helper()
 | 
						t.Helper()
 | 
				
			||||||
	labels := p.GetLabels()
 | 
						labels := p.GetLabels()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -843,6 +843,13 @@ const (
 | 
				
			|||||||
	//
 | 
						//
 | 
				
			||||||
	// Enables In-Place Pod Vertical Scaling
 | 
						// Enables In-Place Pod Vertical Scaling
 | 
				
			||||||
	InPlacePodVerticalScaling featuregate.Feature = "InPlacePodVerticalScaling"
 | 
						InPlacePodVerticalScaling featuregate.Feature = "InPlacePodVerticalScaling"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// owner: @danielvegamyhre
 | 
				
			||||||
 | 
						// kep: https://kep.k8s.io/4017
 | 
				
			||||||
 | 
						// beta: v1.28
 | 
				
			||||||
 | 
						//
 | 
				
			||||||
 | 
						// Set pod completion index as a pod label for Indexed Jobs and StatefulSets.
 | 
				
			||||||
 | 
						PodIndexLabel featuregate.Feature = "PodIndexLabel"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
@@ -1072,6 +1079,8 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	InPlacePodVerticalScaling: {Default: false, PreRelease: featuregate.Alpha},
 | 
						InPlacePodVerticalScaling: {Default: false, PreRelease: featuregate.Alpha},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						PodIndexLabel: {Default: true, PreRelease: featuregate.Beta},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// inherited features from generic apiserver, relisted here to get a conflict if it is changed
 | 
						// inherited features from generic apiserver, relisted here to get a conflict if it is changed
 | 
				
			||||||
	// unintentionally on either side:
 | 
						// unintentionally on either side:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user