Skip to content

Commit

Permalink
Merge pull request kubernetes#118548 from thockin/remove-warn-dup-vol…
Browse files Browse the repository at this point in the history
…ume-names

Remove unreachable warning on volume name dup
  • Loading branch information
k8s-ci-robot committed Jun 9, 2023
2 parents 577d524 + 151509f commit d93e1e9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 31 deletions.
12 changes: 0 additions & 12 deletions pkg/api/pod/warnings.go
Expand Up @@ -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)
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()))
Expand Down
14 changes: 0 additions & 14 deletions pkg/api/pod/warnings_test.go
Expand Up @@ -263,20 +263,6 @@ func TestWarnings(t *testing.T) {
`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",
template: &api.PodTemplateSpec{Spec: api.PodSpec{
Expand Down
8 changes: 4 additions & 4 deletions pkg/registry/batch/cronjob/strategy_test.go
Expand Up @@ -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()
if len(resetFields) != 2 {
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()

now := metav1.Now()
Expand Down Expand Up @@ -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()
now := metav1.Now()

Expand Down Expand Up @@ -380,7 +380,7 @@ func TestJobStrategy_WarningsOnUpdate(t *testing.T) {
JobTemplate: batch.JobTemplateSpec{
Spec: batch.JobSpec{
Template: api.PodTemplateSpec{
Spec: api.PodSpec{Volumes: []api.Volume{{Name: "volume-name"}, {Name: "volume-name"}}},
Spec: api.PodSpec{ImagePullSecrets: []api.LocalObjectReference{{Name: ""}}},
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/batch/job/strategy_test.go
Expand Up @@ -813,7 +813,7 @@ func TestJobStrategy_WarningsOnUpdate(t *testing.T) {
Spec: batch.JobSpec{
Selector: validSelector,
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),
Parallelism: pointer.Int32Ptr(1),
Expand Down

0 comments on commit d93e1e9

Please sign in to comment.