From cc089c0400c2abdc5601eea0436f7c2e66083124 Mon Sep 17 00:00:00 2001 From: Jiawei Wang Date: Thu, 20 May 2021 10:58:45 -0700 Subject: [PATCH] Add warning for deprecated and removed plugin --- pkg/api/pod/warnings.go | 19 +++++++++++++-- pkg/api/pod/warnings_test.go | 47 +++++++++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/pkg/api/pod/warnings.go b/pkg/api/pod/warnings.go index e1f93e85dec..2275914e20b 100644 --- a/pkg/api/pod/warnings.go +++ b/pkg/api/pod/warnings.go @@ -167,10 +167,25 @@ func warningsForPodSpecAndMeta(fieldPath *field.Path, podSpec *api.PodSpec, meta } } - // removed volume plugins + // deprecated and removed volume plugins for i, v := range podSpec.Volumes { if v.PhotonPersistentDisk != nil { - warnings = append(warnings, fmt.Sprintf("%s: non-functional in v1.16+", fieldPath.Child("spec", "volumes").Index(i).Child("photonPersistentDisk"))) + warnings = append(warnings, fmt.Sprintf("%s: deprecated in v1.11, non-functional in v1.16+", fieldPath.Child("spec", "volumes").Index(i).Child("photonPersistentDisk"))) + } + if v.GitRepo != nil { + warnings = append(warnings, fmt.Sprintf("%s: deprecated in v1.11", fieldPath.Child("spec", "volumes").Index(i).Child("gitRepo"))) + } + if v.ScaleIO != nil { + warnings = append(warnings, fmt.Sprintf("%s: deprecated in v1.16, non-functional in v1.22+", fieldPath.Child("spec", "volumes").Index(i).Child("scaleIO"))) + } + if v.Flocker != nil { + warnings = append(warnings, fmt.Sprintf("%s: deprecated in v1.22, support removal is planned in v1.26", fieldPath.Child("spec", "volumes").Index(i).Child("flocker"))) + } + if v.StorageOS != nil { + warnings = append(warnings, fmt.Sprintf("%s: deprecated in v1.22, support removal is planned in v1.26", fieldPath.Child("spec", "volumes").Index(i).Child("storageOS"))) + } + if v.Quobyte != nil { + warnings = append(warnings, fmt.Sprintf("%s: deprecated in v1.22, support removal is planned in v1.26", fieldPath.Child("spec", "volumes").Index(i).Child("quobyte"))) } } diff --git a/pkg/api/pod/warnings_test.go b/pkg/api/pod/warnings_test.go index bfb59dfeb9a..644e0d86290 100644 --- a/pkg/api/pod/warnings_test.go +++ b/pkg/api/pod/warnings_test.go @@ -158,7 +158,52 @@ func TestWarnings(t *testing.T) { {Name: "p", VolumeSource: api.VolumeSource{PhotonPersistentDisk: &api.PhotonPersistentDiskVolumeSource{}}}, }}, }, - expected: []string{`spec.volumes[0].photonPersistentDisk: non-functional in v1.16+`}, + expected: []string{`spec.volumes[0].photonPersistentDisk: deprecated in v1.11, non-functional in v1.16+`}, + }, + { + name: "gitRepo", + template: &api.PodTemplateSpec{Spec: api.PodSpec{ + Volumes: []api.Volume{ + {Name: "s", VolumeSource: api.VolumeSource{GitRepo: &api.GitRepoVolumeSource{}}}, + }}, + }, + expected: []string{`spec.volumes[0].gitRepo: deprecated in v1.11`}, + }, + { + name: "scaleIO", + template: &api.PodTemplateSpec{Spec: api.PodSpec{ + Volumes: []api.Volume{ + {Name: "s", VolumeSource: api.VolumeSource{ScaleIO: &api.ScaleIOVolumeSource{}}}, + }}, + }, + expected: []string{`spec.volumes[0].scaleIO: deprecated in v1.16, non-functional in v1.22+`}, + }, + { + name: "flocker", + template: &api.PodTemplateSpec{Spec: api.PodSpec{ + Volumes: []api.Volume{ + {Name: "s", VolumeSource: api.VolumeSource{Flocker: &api.FlockerVolumeSource{}}}, + }}, + }, + expected: []string{`spec.volumes[0].flocker: deprecated in v1.22, support removal is planned in v1.26`}, + }, + { + name: "storageOS", + template: &api.PodTemplateSpec{Spec: api.PodSpec{ + Volumes: []api.Volume{ + {Name: "s", VolumeSource: api.VolumeSource{StorageOS: &api.StorageOSVolumeSource{}}}, + }}, + }, + expected: []string{`spec.volumes[0].storageOS: deprecated in v1.22, support removal is planned in v1.26`}, + }, + { + name: "quobyte", + template: &api.PodTemplateSpec{Spec: api.PodSpec{ + Volumes: []api.Volume{ + {Name: "s", VolumeSource: api.VolumeSource{Quobyte: &api.QuobyteVolumeSource{}}}, + }}, + }, + expected: []string{`spec.volumes[0].quobyte: deprecated in v1.22, support removal is planned in v1.26`}, }, { name: "duplicate hostAlias",