From 9b217884ac90d8512109177dc151ced0435caafa Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 28 Jan 2022 08:12:05 +0530 Subject: [PATCH] csi: skip validation when installing snapshotter in kubernetes 1.18 we are seeing CRD validation errors when installing with kubectl, adding validate=false to skip the validation and to make tests works with kubernetes 1.18 closes: #9670 Signed-off-by: Madhu Rajanna (cherry picked from commit c40ff244103dbde03c19883399de0f9f78a99e80) --- tests/framework/utils/snapshot.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/framework/utils/snapshot.go b/tests/framework/utils/snapshot.go index c657305e0..fe8f4c9ff 100644 --- a/tests/framework/utils/snapshot.go +++ b/tests/framework/utils/snapshot.go @@ -112,20 +112,33 @@ func (k8sh *K8sHelper) DeleteSnapshotController() error { // snapshotCRD can be used for creating or deleting the snapshot CRD's func (k8sh *K8sHelper) snapshotCRD(action string) error { + // setting validate=false to skip CRD validation during create operation to + // support lower Kubernetes versions. + args := func(crdpath string) []string { + a := []string{ + action, + "-f", + crdpath, + } + if action == "create" { + a = append(a, "--validate=false") + } + return a + } snapshotClassCRD := fmt.Sprintf("%s/%s/%s", repoURL, snapshotterVersion, snapshotClassCRDPath) - _, err := k8sh.Kubectl(action, "-f", snapshotClassCRD) + _, err := k8sh.Kubectl(args(snapshotClassCRD)...) if err != nil { return err } snapshotContentsCRD := fmt.Sprintf("%s/%s/%s", repoURL, snapshotterVersion, volumeSnapshotContentsCRDPath) - _, err = k8sh.Kubectl(action, "-f", snapshotContentsCRD) + _, err = k8sh.Kubectl(args(snapshotContentsCRD)...) if err != nil { return err } snapshotCRD := fmt.Sprintf("%s/%s/%s", repoURL, snapshotterVersion, volumeSnapshotCRDPath) - _, err = k8sh.Kubectl(action, "-f", snapshotCRD) + _, err = k8sh.Kubectl(args(snapshotCRD)...) if err != nil { return err }