From 8a51dc7019d3bec2ec0660b77c715b996946da7e Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Tue, 17 Aug 2021 20:24:00 +1200 Subject: [PATCH 1/6] [docs] Update the apiVersions (#1622) (#1623) TokenReview, SubjectAccessReview v1beta1 apiVersions are removed in 1.22. This PR updates the docs for the same. Co-authored-by: Anusha Ramineni --- ...ne-webhook-authenticator-and-authorizer.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/keystone-auth/using-keystone-webhook-authenticator-and-authorizer.md b/docs/keystone-auth/using-keystone-webhook-authenticator-and-authorizer.md index c69d1c7037..aa13f2d678 100644 --- a/docs/keystone-auth/using-keystone-webhook-authenticator-and-authorizer.md +++ b/docs/keystone-auth/using-keystone-webhook-authenticator-and-authorizer.md @@ -297,7 +297,7 @@ $ kubectl apply -f examples/webhook/keystone-service.yaml $ kubectl run curl --rm -it --restart=Never --image curlimages/curl -- \ -k -XPOST https://k8s-keystone-auth-service.kube-system:8443/webhook -d ' { - "apiVersion": "authentication.k8s.io/v1beta1", + "apiVersion": "authentication.k8s.io/v1", "kind": "TokenReview", "metadata": { "creationTimestamp": null @@ -316,7 +316,7 @@ $ kubectl apply -f examples/webhook/keystone-service.yaml ```shell { - "apiVersion": "authentication.k8s.io/v1beta1", + "apiVersion": "authentication.k8s.io/v1", "kind": "TokenReview", "metadata": { "creationTimestamp": null @@ -370,18 +370,18 @@ $ kubectl apply -f examples/webhook/keystone-service.yaml $ kubectl run curl --rm -it --restart=Never --image curlimages/curl -- \ -k -XPOST https://k8s-keystone-auth-service.kube-system:8443/webhook -d ' { - "apiVersion": "authorization.k8s.io/v1beta1", + "apiVersion": "authorization.k8s.io/v1", "kind": "SubjectAccessReview", "spec": { "resourceAttributes": { "namespace": "default", "verb": "get", - "group": "", + "groups": "", "resource": "pods", "name": "pod1" }, "user": "demo", - "group": ["423d41d3a02f4b77b4a9bbfbc3a1b3c6"], + "groups": ["423d41d3a02f4b77b4a9bbfbc3a1b3c6"], "extra": { "alpha.kubernetes.io/identity/project/id": ["423d41d3a02f4b77b4a9bbfbc3a1b3c6"], "alpha.kubernetes.io/identity/project/name": ["demo"], @@ -395,7 +395,7 @@ $ kubectl apply -f examples/webhook/keystone-service.yaml ```shell { - "apiVersion": "authorization.k8s.io/v1beta1", + "apiVersion": "authorization.k8s.io/v1", "kind": "SubjectAccessReview", "status": { "allowed": true @@ -409,18 +409,18 @@ $ kubectl apply -f examples/webhook/keystone-service.yaml $ kubectl run curl --rm -it --restart=Never --image curlimages/curl -- \ -k -XPOST https://k8s-keystone-auth-service.kube-system:8443/webhook -d ' { - "apiVersion": "authorization.k8s.io/v1beta1", + "apiVersion": "authorization.k8s.io/v1", "kind": "SubjectAccessReview", "spec": { "resourceAttributes": { "namespace": "default", "verb": "create", - "group": "", + "groups": "", "resource": "pods", "name": "pod1" }, "user": "demo", - "group": ["423d41d3a02f4b77b4a9bbfbc3a1b3c6"], + "groups": ["423d41d3a02f4b77b4a9bbfbc3a1b3c6"], "extra": { "alpha.kubernetes.io/identity/project/id": ["423d41d3a02f4b77b4a9bbfbc3a1b3c6"], "alpha.kubernetes.io/identity/project/name": ["demo"], @@ -434,7 +434,7 @@ $ kubectl apply -f examples/webhook/keystone-service.yaml ```shell { - "apiVersion": "authorization.k8s.io/v1beta1", + "apiVersion": "authorization.k8s.io/v1", "kind": "SubjectAccessReview", "status": { "allowed": false From dbe149722c734419dc9e90f187e44646975829a2 Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Tue, 17 Aug 2021 22:38:00 +1200 Subject: [PATCH 2/6] [manila-csi-plugin] pass CreateVolumeRequest.parameters as Volume.volume_context (#1616) (#1624) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * validator: added Validator.Fields exposing recognized field names * options: added NodeVolumeContextFields() to expose nodeVolumeCtxValidator.Fields * CreateVolume: pass all recognized CreateVolumeRequest.parameters fields as Volume.volume_context Co-authored-by: Róbert Vašek --- pkg/csi/manila/controllerserver.go | 22 +++++++++++---- pkg/csi/manila/options/shareoptions.go | 4 +++ pkg/csi/manila/validator/validator.go | 13 +++++++++ pkg/csi/manila/validator/validator_test.go | 31 ++++++++++++++++++++++ 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/pkg/csi/manila/controllerserver.go b/pkg/csi/manila/controllerserver.go index 4cf8a0cd39..116b000944 100644 --- a/pkg/csi/manila/controllerserver.go +++ b/pkg/csi/manila/controllerserver.go @@ -61,6 +61,18 @@ func getVolumeCreator(source *csi.VolumeContentSource, shareOpts *options.Contro return nil, status.Error(codes.InvalidArgument, "invalid volume content source") } +func filterParametersForVolumeContext(params map[string]string, recognizedFields []string) map[string]string { + volCtx := make(map[string]string) + + for _, fieldName := range recognizedFields { + if val, ok := params[fieldName]; ok { + volCtx[fieldName] = val + } + } + + return volCtx +} + func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVolumeRequest) (*csi.CreateVolumeResponse, error) { if err := validateCreateVolumeRequest(req); err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) @@ -150,17 +162,17 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol accessibleTopology = req.GetAccessibilityRequirements().GetPreferred() } + volCtx := filterParametersForVolumeContext(params, options.NodeVolumeContextFields()) + volCtx["shareID"] = share.ID + volCtx["shareAccessID"] = accessRight.ID + return &csi.CreateVolumeResponse{ Volume: &csi.Volume{ VolumeId: share.ID, ContentSource: req.GetVolumeContentSource(), AccessibleTopology: accessibleTopology, CapacityBytes: int64(sizeInGiB) * bytesInGiB, - VolumeContext: map[string]string{ - "shareID": share.ID, - "shareAccessID": accessRight.ID, - "cephfs-mounter": shareOpts.CephfsMounter, - }, + VolumeContext: volCtx, }, }, nil } diff --git a/pkg/csi/manila/options/shareoptions.go b/pkg/csi/manila/options/shareoptions.go index ceab39a8c1..a3b539a793 100644 --- a/pkg/csi/manila/options/shareoptions.go +++ b/pkg/csi/manila/options/shareoptions.go @@ -70,3 +70,7 @@ func NewNodeVolumeContext(data map[string]string) (*NodeVolumeContext, error) { return opts, nil } + +func NodeVolumeContextFields() []string { + return nodeVolumeCtxValidator.Fields +} diff --git a/pkg/csi/manila/validator/validator.go b/pkg/csi/manila/validator/validator.go index 96d9981d0a..e4240e26f4 100644 --- a/pkg/csi/manila/validator/validator.go +++ b/pkg/csi/manila/validator/validator.go @@ -48,6 +48,9 @@ type Validator struct { nameIdxMap nameIndexMap idxNameMap indexNameMap + // Field names in the struct. + Fields []string + valueExprs *valueExpressions depsMap dependenciesMap preclsMap preclusionsMap @@ -67,6 +70,7 @@ func New(stringStruct interface{}) *Validator { t: t, nameIdxMap: nameIdxMap, idxNameMap: idxNameMap, + Fields: buildFieldNames(idxNameMap), valueExprs: buildValueExpressions(t, idxNameMap, nameIdxMap), depsMap: buildDependenciesMap(t, idxNameMap, nameIdxMap), preclsMap: buildPreclusionsMap(t, idxNameMap, nameIdxMap), @@ -74,6 +78,15 @@ func New(stringStruct interface{}) *Validator { } } +func buildFieldNames(m indexNameMap) []string { + s := make([]string, 0, len(m)) + for _, fieldName := range m { + s = append(s, string(fieldName)) + } + + return s +} + // Populate validates input data and populates the output struct. func (v *Validator) Populate(data map[string]string, out interface{}) error { if reflect.TypeOf(out).Elem() != v.t { diff --git a/pkg/csi/manila/validator/validator_test.go b/pkg/csi/manila/validator/validator_test.go index 1d38db7575..c6643c45fd 100644 --- a/pkg/csi/manila/validator/validator_test.go +++ b/pkg/csi/manila/validator/validator_test.go @@ -193,3 +193,34 @@ func TestMatches(t *testing.T) { t.Error(`matches:"true|false" violated, should succeed on matching parameter`) } } + +func TestFieldNames(t *testing.T) { + type s struct { + A string `name:"a"` + B string `name:"b"` + } + + v := New(&s{}) + + expected := []string{"a", "b"} + + findElem := func(x string, xs []string) bool { + for _, e := range xs { + if e == x { + return true + } + } + return false + } + + if len(expected) != len(v.Fields) { + t.Errorf("expected number of entries %d (%v), got %d (%v)", + len(expected), expected, len(v.Fields), v.Fields) + } + + for i := range v.Fields { + if !findElem(v.Fields[i], expected) { + t.Error("found unexpected field", v.Fields[i], "; expected fields", expected, "actual fields", v.Fields) + } + } +} From 7de8a84dbb5a2449c0b8ba4fb9a00f2b4f0811dc Mon Sep 17 00:00:00 2001 From: Lingxian Kong Date: Wed, 18 Aug 2021 21:20:08 +1200 Subject: [PATCH 3/6] [All] Update CPO docker image tag to v1.22.0 (#1626) --- charts/cinder-csi-plugin/Chart.yaml | 4 ++-- charts/manila-csi-plugin/Chart.yaml | 4 ++-- charts/openstack-cloud-controller-manager/Chart.yaml | 4 ++-- examples/webhook/keystone-deployment.yaml | 2 +- manifests/barbican-kms/pod.yaml | 2 +- manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml | 2 +- manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml | 2 +- .../openstack-cloud-controller-manager-ds.yaml | 2 +- .../openstack-cloud-controller-manager-pod.yaml | 2 +- manifests/magnum-auto-healer/magnum-auto-healer.yaml | 2 +- manifests/manila-csi-plugin/csi-controllerplugin.yaml | 2 +- manifests/manila-csi-plugin/csi-nodeplugin.yaml | 2 +- 12 files changed, 15 insertions(+), 15 deletions(-) diff --git a/charts/cinder-csi-plugin/Chart.yaml b/charts/cinder-csi-plugin/Chart.yaml index 99db4944f6..fa4f815454 100644 --- a/charts/cinder-csi-plugin/Chart.yaml +++ b/charts/cinder-csi-plugin/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 -appVersion: latest +appVersion: v1.22.0 description: Cinder CSI Chart for OpenStack name: openstack-cinder-csi -version: 1.4.8 +version: 1.4.9 home: https://github.com/kubernetes/cloud-provider-openstack icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png maintainers: diff --git a/charts/manila-csi-plugin/Chart.yaml b/charts/manila-csi-plugin/Chart.yaml index 35342c7e8c..e036aebf51 100644 --- a/charts/manila-csi-plugin/Chart.yaml +++ b/charts/manila-csi-plugin/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v1 -appVersion: latest +appVersion: v1.22.0 description: Manila CSI Chart for OpenStack name: openstack-manila-csi -version: 1.3.2 +version: 1.3.3 home: http://github.com/kubernetes/cloud-provider-openstack icon: https://github.com/kubernetes/kubernetes/blob/master/logo/logo.png maintainers: diff --git a/charts/openstack-cloud-controller-manager/Chart.yaml b/charts/openstack-cloud-controller-manager/Chart.yaml index f8936935d1..7a92ad6355 100644 --- a/charts/openstack-cloud-controller-manager/Chart.yaml +++ b/charts/openstack-cloud-controller-manager/Chart.yaml @@ -1,10 +1,10 @@ apiVersion: v1 -appVersion: "latest" +appVersion: v1.22.0 description: Openstack Cloud Controller Manager Helm Chart icon: https://object-storage-ca-ymq-1.vexxhost.net/swift/v1/6e4619c416ff4bd19e1c087f27a43eea/www-images-prod/openstack-logo/OpenStack-Logo-Vertical.png home: https://github.com/kubernetes/cloud-provider-openstack name: openstack-cloud-controller-manager -version: 1.1.1 +version: 1.1.2 maintainers: - name: morremeyer email: kubernetes@maurice-meyer.de diff --git a/examples/webhook/keystone-deployment.yaml b/examples/webhook/keystone-deployment.yaml index 902318bcb9..4dd96bcd76 100644 --- a/examples/webhook/keystone-deployment.yaml +++ b/examples/webhook/keystone-deployment.yaml @@ -18,7 +18,7 @@ spec: serviceAccountName: k8s-keystone containers: - name: k8s-keystone-auth - image: k8scloudprovider/k8s-keystone-auth:latest + image: k8scloudprovider/k8s-keystone-auth:v1.22.0 args: - ./bin/k8s-keystone-auth - --tls-cert-file diff --git a/manifests/barbican-kms/pod.yaml b/manifests/barbican-kms/pod.yaml index c0e8a20c9a..8e68d66bd4 100644 --- a/manifests/barbican-kms/pod.yaml +++ b/manifests/barbican-kms/pod.yaml @@ -5,7 +5,7 @@ metadata: spec: containers: - name: barbican-kms - image: docker.io/k8scloudprovider/barbican-kms-plugin:latest + image: docker.io/k8scloudprovider/barbican-kms-plugin:v1.22.0 args: - "--socketpath=/kms/kms.sock" - "--cloud-config=/etc/kubernetes/cloud-config" diff --git a/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml b/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml index 51dfde8c92..f0d43853d3 100644 --- a/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml +++ b/manifests/cinder-csi-plugin/cinder-csi-controllerplugin.yaml @@ -99,7 +99,7 @@ spec: - mountPath: /var/lib/csi/sockets/pluginproxy/ name: socket-dir - name: cinder-csi-plugin - image: docker.io/k8scloudprovider/cinder-csi-plugin:latest + image: docker.io/k8scloudprovider/cinder-csi-plugin:v1.22.0 args: - /bin/cinder-csi-plugin - "--endpoint=$(CSI_ENDPOINT)" diff --git a/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml b/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml index 0642480cd8..f63e4dfc7a 100644 --- a/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml +++ b/manifests/cinder-csi-plugin/cinder-csi-nodeplugin.yaml @@ -53,7 +53,7 @@ spec: capabilities: add: ["SYS_ADMIN"] allowPrivilegeEscalation: true - image: docker.io/k8scloudprovider/cinder-csi-plugin:latest + image: docker.io/k8scloudprovider/cinder-csi-plugin:v1.22.0 args: - /bin/cinder-csi-plugin - "--endpoint=$(CSI_ENDPOINT)" diff --git a/manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml b/manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml index cd1af8cb61..d3ab9e7aa1 100644 --- a/manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml +++ b/manifests/controller-manager/openstack-cloud-controller-manager-ds.yaml @@ -36,7 +36,7 @@ spec: serviceAccountName: cloud-controller-manager containers: - name: openstack-cloud-controller-manager - image: docker.io/k8scloudprovider/openstack-cloud-controller-manager:latest + image: docker.io/k8scloudprovider/openstack-cloud-controller-manager:v1.22.0 args: - /bin/openstack-cloud-controller-manager - --v=1 diff --git a/manifests/controller-manager/openstack-cloud-controller-manager-pod.yaml b/manifests/controller-manager/openstack-cloud-controller-manager-pod.yaml index b3f643dee4..8f9a14b430 100644 --- a/manifests/controller-manager/openstack-cloud-controller-manager-pod.yaml +++ b/manifests/controller-manager/openstack-cloud-controller-manager-pod.yaml @@ -11,7 +11,7 @@ metadata: spec: containers: - name: openstack-cloud-controller-manager - image: docker.io/k8scloudprovider/openstack-cloud-controller-manager:latest + image: docker.io/k8scloudprovider/openstack-cloud-controller-manager:v1.22.0 args: - /bin/openstack-cloud-controller-manager - --v=1 diff --git a/manifests/magnum-auto-healer/magnum-auto-healer.yaml b/manifests/magnum-auto-healer/magnum-auto-healer.yaml index b750498b87..481a11f29e 100644 --- a/manifests/magnum-auto-healer/magnum-auto-healer.yaml +++ b/manifests/magnum-auto-healer/magnum-auto-healer.yaml @@ -88,7 +88,7 @@ spec: node-role.kubernetes.io/master: "" containers: - name: magnum-auto-healer - image: docker.io/k8scloudprovider/magnum-auto-healer:latest + image: docker.io/k8scloudprovider/magnum-auto-healer:v1.22.0 imagePullPolicy: Always args: - /bin/magnum-auto-healer diff --git a/manifests/manila-csi-plugin/csi-controllerplugin.yaml b/manifests/manila-csi-plugin/csi-controllerplugin.yaml index 4218013f7b..254a5ceeab 100644 --- a/manifests/manila-csi-plugin/csi-controllerplugin.yaml +++ b/manifests/manila-csi-plugin/csi-controllerplugin.yaml @@ -77,7 +77,7 @@ spec: capabilities: add: ["SYS_ADMIN"] allowPrivilegeEscalation: true - image: "k8scloudprovider/manila-csi-plugin:latest" + image: "k8scloudprovider/manila-csi-plugin:v1.22.0" command: ["/bin/sh", "-c", '/bin/manila-csi-plugin --nodeid=$(NODE_ID) diff --git a/manifests/manila-csi-plugin/csi-nodeplugin.yaml b/manifests/manila-csi-plugin/csi-nodeplugin.yaml index b9606d0ded..2f4e9da8c1 100644 --- a/manifests/manila-csi-plugin/csi-nodeplugin.yaml +++ b/manifests/manila-csi-plugin/csi-nodeplugin.yaml @@ -50,7 +50,7 @@ spec: capabilities: add: ["SYS_ADMIN"] allowPrivilegeEscalation: true - image: "k8scloudprovider/manila-csi-plugin:latest" + image: "k8scloudprovider/manila-csi-plugin:v1.22.0" command: ["/bin/sh", "-c", '/bin/manila-csi-plugin --nodeid=$(NODE_ID) From a6a2bea4f376281887c7bcc2d1f612611e5f3dac Mon Sep 17 00:00:00 2001 From: Anusha Ramineni Date: Wed, 18 Aug 2021 16:39:17 +0530 Subject: [PATCH 4/6] Update mount-utils to 0.22.0 --- go.mod | 2 +- go.sum | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d31b00f5a8..59bc55aa4f 100644 --- a/go.mod +++ b/go.mod @@ -73,7 +73,7 @@ replace ( k8s.io/kubelet => k8s.io/kubelet v0.22.0 k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.22.0 k8s.io/metrics => k8s.io/metrics v0.22.0 - k8s.io/mount-utils => k8s.io/mount-utils v0.21.1 + k8s.io/mount-utils => k8s.io/mount-utils v0.22.0 k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.22.0 k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.22.0 k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.22.0 diff --git a/go.sum b/go.sum index 465aa145b5..a368cc2bc0 100644 --- a/go.sum +++ b/go.sum @@ -1049,7 +1049,6 @@ k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.2.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= -k8s.io/klog/v2 v2.8.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= k8s.io/klog/v2 v2.9.0 h1:D7HV+n1V57XeZ0m6tdRkfknthUaM06VFbWldOFh8kzM= k8s.io/klog/v2 v2.9.0/go.mod h1:hy9LJ/NvuK+iVyP4Ehqva4HxZG/oXyIS3n3Jmire4Ec= k8s.io/kube-aggregator v0.22.0/go.mod h1:zHTepg0Q4tKzru7Pwg1QYHWrU/wrvIXM8hUdDAH66qg= @@ -1066,8 +1065,8 @@ k8s.io/kubernetes v1.22.0 h1:zROjVlA1qSthvMnP7XeCzkRaqkE28CY3w+PM8qC0ZaA= k8s.io/kubernetes v1.22.0/go.mod h1:IGQZrV02n2IBp52+/YwLVMurCEQPKXJ/k8hU3mqEOuA= k8s.io/legacy-cloud-providers v0.22.0/go.mod h1:2tKlbeA9r0OYnBHyqHcnO1EoAeqYXw2IZH99DYwwErM= k8s.io/metrics v0.22.0/go.mod h1:eYnwafAUNLLpVmY/msoq0RKIKH5C4TzfjKnMZ0Xrt3A= -k8s.io/mount-utils v0.21.1 h1:uYf6zlKaaoUcPhWn6MElLkWf/f7UQgtkPZteumgwDbA= -k8s.io/mount-utils v0.21.1/go.mod h1:dwXbIPxKtTjrBEaX1aK/CMEf1KZ8GzMHpe3NEBfdFXI= +k8s.io/mount-utils v0.22.0 h1:yNUW+1HO+ZhYDEZ7a/14Un7nqW8Md4zeuLnenGCGDi4= +k8s.io/mount-utils v0.22.0/go.mod h1:gUi5ht+05KHYc/vJ9q9wbvG3MCYBeOsB5FdTyM60Pzo= k8s.io/pod-security-admission v0.22.0/go.mod h1:xKTKO4nzxLDROM+RRndSU7kCZc2XcBYRKLYS+gYuqfo= k8s.io/sample-apiserver v0.22.0/go.mod h1:Bkl0f9E1Moxwjvqct7kzDlTvNUTavsworU5FTPlVooA= k8s.io/system-validators v1.5.0/go.mod h1:bPldcLgkIUK22ALflnsXk8pvkTEndYdNuaHH6gRrl0Q= From 4f6a9317ba7acb96cbd522dd3803d641504e0f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Va=C5=A1ek?= Date: Tue, 2 Nov 2021 10:46:58 +0100 Subject: [PATCH 5/6] [manila-csi-plugin] ControllerExpandVolume: fix bad key for deleting from pendingVolumes (#1667) (#1675) * [manila-csi-plugin] in ControllerExpandVolume fix bad key for pendingVolumes.Delete /closes kubernetes/cloud-provider-openstack#1666 * [manila-csi-plugin] use share.Name to identify volumes in pendingVolumes.Delete Co-authored-by: Alexis Ries <42094254+alexisries@users.noreply.github.com> --- pkg/csi/manila/controllerserver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/csi/manila/controllerserver.go b/pkg/csi/manila/controllerserver.go index 116b000944..5f575715c2 100644 --- a/pkg/csi/manila/controllerserver.go +++ b/pkg/csi/manila/controllerserver.go @@ -445,7 +445,7 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi } // Check for pending operations on this volume - if _, isPending := pendingVolumes.LoadOrStore(req.GetVolumeId(), true); isPending { + if _, isPending := pendingVolumes.LoadOrStore(share.Name, true); isPending { return nil, status.Errorf(codes.Aborted, "volume %s is already being processed", share.Name) } defer pendingVolumes.Delete(share.Name) From f17fda8a7e2e373f98a61c26e8ac8f4eec735ee1 Mon Sep 17 00:00:00 2001 From: ji chen Date: Fri, 13 May 2022 09:53:48 +0800 Subject: [PATCH 6/6] [cinder-csi-plugin]add 'force-create' into tag param to support force create (#1831) --- pkg/autohealing/cmd/root.go | 2 +- pkg/csi/cinder/controllerserver.go | 5 ++++- pkg/csi/cinder/controllerserver_test.go | 2 ++ pkg/csi/cinder/openstack/openstack_snapshots.go | 6 +++--- pkg/util/blockdevice/blockdevice_unsupported.go | 1 + 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/autohealing/cmd/root.go b/pkg/autohealing/cmd/root.go index ce79e67eca..44e3d3390d 100644 --- a/pkg/autohealing/cmd/root.go +++ b/pkg/autohealing/cmd/root.go @@ -77,7 +77,7 @@ var rootCmd = &cobra.Command{ Name: "k8s-auto-healer", }) - sigCh := make(chan os.Signal) + sigCh := make(chan os.Signal, 1) signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM) <-sigCh }, diff --git a/pkg/csi/cinder/controllerserver.go b/pkg/csi/cinder/controllerserver.go index d45f24ed26..04554ac7b7 100644 --- a/pkg/csi/cinder/controllerserver.go +++ b/pkg/csi/cinder/controllerserver.go @@ -365,7 +365,10 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS properties := map[string]string{cinderCSIClusterIDKey: cs.Driver.cluster} // see https://github.com/kubernetes-csi/external-snapshotter/pull/375/ - for _, mKey := range []string{"csi.storage.k8s.io/volumesnapshot/name", "csi.storage.k8s.io/volumesnapshot/namespace", "csi.storage.k8s.io/volumesnapshotcontent/name"} { + // Also, we don't want to tag every param but we still want to send the + // 'force-create' flag to openstack layer so that we will honor the + // force create functions + for _, mKey := range []string{"csi.storage.k8s.io/volumesnapshot/name", "csi.storage.k8s.io/volumesnapshot/namespace", "csi.storage.k8s.io/volumesnapshotcontent/name", openstack.SnapshotForceCreate} { if v, ok := req.Parameters[mKey]; ok { properties[mKey] = v } diff --git a/pkg/csi/cinder/controllerserver_test.go b/pkg/csi/cinder/controllerserver_test.go index bf7563f92b..3a44a59a2b 100644 --- a/pkg/csi/cinder/controllerserver_test.go +++ b/pkg/csi/cinder/controllerserver_test.go @@ -441,6 +441,7 @@ func TestCreateSnapshotWithExtraMetadata(t *testing.T) { "csi.storage.k8s.io/volumesnapshot/name": FakeSnapshotName, "csi.storage.k8s.io/volumesnapshotcontent/name": FakeSnapshotContentName, "csi.storage.k8s.io/volumesnapshot/namespace": FakeSnapshotNamespace, + openstack.SnapshotForceCreate: "true", } osmock.On("CreateSnapshot", FakeSnapshotName, FakeVolID, &properties).Return(&FakeSnapshotRes, nil) @@ -458,6 +459,7 @@ func TestCreateSnapshotWithExtraMetadata(t *testing.T) { "csi.storage.k8s.io/volumesnapshot/name": FakeSnapshotName, "csi.storage.k8s.io/volumesnapshotcontent/name": FakeSnapshotContentName, "csi.storage.k8s.io/volumesnapshot/namespace": FakeSnapshotNamespace, + openstack.SnapshotForceCreate: "true", }, } diff --git a/pkg/csi/cinder/openstack/openstack_snapshots.go b/pkg/csi/cinder/openstack/openstack_snapshots.go index 478b5bfde4..1e1a54ac28 100644 --- a/pkg/csi/cinder/openstack/openstack_snapshots.go +++ b/pkg/csi/cinder/openstack/openstack_snapshots.go @@ -37,7 +37,7 @@ const ( snapReadySteps = 10 snapshotDescription = "Created by OpenStack Cinder CSI driver" - snapshotForceCreate = "force-create" + SnapshotForceCreate = "force-create" ) // CreateSnapshot issues a request to take a Snapshot of the specified Volume with the corresponding ID and @@ -47,14 +47,14 @@ func (os *OpenStack) CreateSnapshot(name, volID string, tags *map[string]string) force := false // if no flag given, then force will be false by default // if flag it given , check it - if item, ok := (*tags)[snapshotForceCreate]; ok { + if item, ok := (*tags)[SnapshotForceCreate]; ok { var err error force, err = strconv.ParseBool(item) if err != nil { klog.V(5).Infof("Make force create flag to false due to: %v", err) } - delete(*tags, snapshotForceCreate) + delete(*tags, SnapshotForceCreate) } // Force the creation of snapshot even the Volume is in in-use state opts := &snapshots.CreateOpts{ diff --git a/pkg/util/blockdevice/blockdevice_unsupported.go b/pkg/util/blockdevice/blockdevice_unsupported.go index a19150574f..a75c69be7b 100644 --- a/pkg/util/blockdevice/blockdevice_unsupported.go +++ b/pkg/util/blockdevice/blockdevice_unsupported.go @@ -1,3 +1,4 @@ +//go:build !linux // +build !linux /*