Merge pull request #118548 from thockin/remove-warn-dup-volume-names
Remove unreachable warning on volume name dup
This commit is contained in:
		| @@ -195,18 +195,6 @@ func warningsForPodSpecAndMeta(fieldPath *field.Path, podSpec *api.PodSpec, meta | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	// duplicate volume names (#78266, #58477) |  | ||||||
| 	if len(podSpec.Volumes) > 1 { |  | ||||||
| 		items := sets.NewString() |  | ||||||
| 		for i, item := range podSpec.Volumes { |  | ||||||
| 			if items.Has(item.Name) { |  | ||||||
| 				warnings = append(warnings, fmt.Sprintf("%s: duplicate name %q", fieldPath.Child("spec", "volumes").Index(i).Child("name"), item.Name)) |  | ||||||
| 			} else { |  | ||||||
| 				items.Insert(item.Name) |  | ||||||
| 			} |  | ||||||
| 		} |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	// fractional memory/ephemeral-storage requests/limits (#79950, #49442, #18538) | 	// fractional memory/ephemeral-storage requests/limits (#79950, #49442, #18538) | ||||||
| 	if value, ok := podSpec.Overhead[api.ResourceMemory]; ok && value.MilliValue()%int64(1000) != int64(0) { | 	if value, ok := podSpec.Overhead[api.ResourceMemory]; ok && value.MilliValue()%int64(1000) != int64(0) { | ||||||
| 		warnings = append(warnings, fmt.Sprintf("%s: fractional byte value %q is invalid, must be an integer", fieldPath.Child("spec", "overhead").Key(string(api.ResourceMemory)), value.String())) | 		warnings = append(warnings, fmt.Sprintf("%s: fractional byte value %q is invalid, must be an integer", fieldPath.Child("spec", "overhead").Key(string(api.ResourceMemory)), value.String())) | ||||||
|   | |||||||
| @@ -263,20 +263,6 @@ func TestWarnings(t *testing.T) { | |||||||
| 				`spec.imagePullSecrets[0].name: invalid empty name ""`, | 				`spec.imagePullSecrets[0].name: invalid empty name ""`, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ |  | ||||||
| 			name: "duplicate volume", |  | ||||||
| 			template: &api.PodTemplateSpec{Spec: api.PodSpec{ |  | ||||||
| 				Volumes: []api.Volume{ |  | ||||||
| 					{Name: "a"}, |  | ||||||
| 					{Name: "a"}, |  | ||||||
| 					{Name: "a"}, |  | ||||||
| 				}}, |  | ||||||
| 			}, |  | ||||||
| 			expected: []string{ |  | ||||||
| 				`spec.volumes[1].name: duplicate name "a"`, |  | ||||||
| 				`spec.volumes[2].name: duplicate name "a"`, |  | ||||||
| 			}, |  | ||||||
| 		}, |  | ||||||
| 		{ | 		{ | ||||||
| 			name: "duplicate env", | 			name: "duplicate env", | ||||||
| 			template: &api.PodTemplateSpec{Spec: api.PodSpec{ | 			template: &api.PodTemplateSpec{Spec: api.PodSpec{ | ||||||
|   | |||||||
| @@ -222,14 +222,14 @@ func TestStrategy_ResetFields(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func TestJobStatusStrategy_ResetFields(t *testing.T) { | func TestCronJobStatusStrategy_ResetFields(t *testing.T) { | ||||||
| 	resetFields := StatusStrategy.GetResetFields() | 	resetFields := StatusStrategy.GetResetFields() | ||||||
| 	if len(resetFields) != 2 { | 	if len(resetFields) != 2 { | ||||||
| 		t.Errorf("ResetFields should have 2 elements, but have %d", len(resetFields)) | 		t.Errorf("ResetFields should have 2 elements, but have %d", len(resetFields)) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func TestJobStrategy_WarningsOnCreate(t *testing.T) { | func TestCronJobStrategy_WarningsOnCreate(t *testing.T) { | ||||||
| 	ctx := genericapirequest.NewDefaultContext() | 	ctx := genericapirequest.NewDefaultContext() | ||||||
|  |  | ||||||
| 	now := metav1.Now() | 	now := metav1.Now() | ||||||
| @@ -291,7 +291,7 @@ func TestJobStrategy_WarningsOnCreate(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
| func TestJobStrategy_WarningsOnUpdate(t *testing.T) { | func TestCronJobStrategy_WarningsOnUpdate(t *testing.T) { | ||||||
| 	ctx := genericapirequest.NewDefaultContext() | 	ctx := genericapirequest.NewDefaultContext() | ||||||
| 	now := metav1.Now() | 	now := metav1.Now() | ||||||
|  |  | ||||||
| @@ -380,7 +380,7 @@ func TestJobStrategy_WarningsOnUpdate(t *testing.T) { | |||||||
| 					JobTemplate: batch.JobTemplateSpec{ | 					JobTemplate: batch.JobTemplateSpec{ | ||||||
| 						Spec: batch.JobSpec{ | 						Spec: batch.JobSpec{ | ||||||
| 							Template: api.PodTemplateSpec{ | 							Template: api.PodTemplateSpec{ | ||||||
| 								Spec: api.PodSpec{Volumes: []api.Volume{{Name: "volume-name"}, {Name: "volume-name"}}}, | 								Spec: api.PodSpec{ImagePullSecrets: []api.LocalObjectReference{{Name: ""}}}, | ||||||
| 							}, | 							}, | ||||||
| 						}, | 						}, | ||||||
| 					}, | 					}, | ||||||
|   | |||||||
| @@ -813,7 +813,7 @@ func TestJobStrategy_WarningsOnUpdate(t *testing.T) { | |||||||
| 				Spec: batch.JobSpec{ | 				Spec: batch.JobSpec{ | ||||||
| 					Selector: validSelector, | 					Selector: validSelector, | ||||||
| 					Template: api.PodTemplateSpec{ | 					Template: api.PodTemplateSpec{ | ||||||
| 						Spec: api.PodSpec{Volumes: []api.Volume{{Name: "volume-name"}, {Name: "volume-name"}}}, | 						Spec: api.PodSpec{ImagePullSecrets: []api.LocalObjectReference{{Name: ""}}}, | ||||||
| 					}, | 					}, | ||||||
| 					ManualSelector: pointer.BoolPtr(true), | 					ManualSelector: pointer.BoolPtr(true), | ||||||
| 					Parallelism:    pointer.Int32Ptr(1), | 					Parallelism:    pointer.Int32Ptr(1), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot