mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 04:27:54 +00:00
Merge pull request #118548 from thockin/remove-warn-dup-volume-names
Remove unreachable warning on volume name dup
This commit is contained in:
commit
d93e1e95ff
@ -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()))
|
||||
|
@ -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{
|
||||
|
@ -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()
|
||||
@ -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()
|
||||
|
||||
@ -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: ""}}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user