From c1c3fabb0b05bbe46d01d062684c175abb65e9b4 Mon Sep 17 00:00:00 2001 From: ostempel Date: Mon, 18 Nov 2024 10:34:43 +0100 Subject: [PATCH] fix reconciling of shoot --- example/pod.yaml | 39 ++++++++++++++++++ example/pvc.yaml | 48 +++++++++++++++++++++++ pkg/controller/csi-driver-lvm/actuator.go | 8 ++-- 3 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 example/pod.yaml create mode 100644 example/pvc.yaml diff --git a/example/pod.yaml b/example/pod.yaml new file mode 100644 index 0000000..7fe7961 --- /dev/null +++ b/example/pod.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + name: volume-test + namespace: default +spec: + containers: + - name: volume-test + image: nginx:stable-alpine + imagePullPolicy: IfNotPresent + volumeMounts: + - name: linear + mountPath: /linear + - name: mirror + mountPath: /mirror + - name: striped + mountPath: /striped + - name: default + mountPath: /default + ports: + - containerPort: 80 + resources: + limits: + cpu: 100m + memory: 100M + volumes: + - name: linear + persistentVolumeClaim: + claimName: csi-pvc-linear + - name: mirror + persistentVolumeClaim: + claimName: csi-pvc-mirror + - name: striped + persistentVolumeClaim: + claimName: csi-pvc-striped + - name: default + persistentVolumeClaim: + claimName: csi-pvc-default \ No newline at end of file diff --git a/example/pvc.yaml b/example/pvc.yaml new file mode 100644 index 0000000..2fd7c88 --- /dev/null +++ b/example/pvc.yaml @@ -0,0 +1,48 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: csi-pvc-linear +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Mi + storageClassName: csi-driver-lvm-linear +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: csi-pvc-striped +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Mi + storageClassName: csi-driver-lvm-striped +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: csi-pvc-mirror +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Mi + storageClassName: csi-driver-lvm-mirror +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: csi-pvc-default +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Mi + storageClassName: csi-lvm \ No newline at end of file diff --git a/pkg/controller/csi-driver-lvm/actuator.go b/pkg/controller/csi-driver-lvm/actuator.go index 02a4009..e9c9221 100644 --- a/pkg/controller/csi-driver-lvm/actuator.go +++ b/pkg/controller/csi-driver-lvm/actuator.go @@ -188,7 +188,7 @@ func (a *actuator) controllerObjects(namespace string) ([]client.Object, error) }, { APIGroups: []string{"storage.k8s.io"}, - Resources: []string{"storageclaess"}, + Resources: []string{"storageclasses"}, Verbs: []string{"get", "list", "watch"}, }, { @@ -779,7 +779,7 @@ func (a *actuator) isOldCsiLvmExisting(ctx context.Context, shootNamespace strin err = shootClient.Get(ctx, client.ObjectKeyFromObject(namespace), namespace) if err == nil { - return true, nil + return true, fmt.Errorf("old csi-lvm namespace is existing") } else if !apierrors.IsNotFound(err) { return true, fmt.Errorf("error while getting old csi-lvm namespace: %w", err) } @@ -793,9 +793,9 @@ func (a *actuator) isOldCsiLvmExisting(ctx context.Context, shootNamespace strin err = shootClient.Get(ctx, client.ObjectKeyFromObject(storageClass), storageClass, &client.GetOptions{}) if err == nil { if storageClass.Provisioner == provisioner { - return true, nil + return false, nil } else { - return false, fmt.Errorf("old csi-lvm storageclass is existing ") + return true, fmt.Errorf("old csi-lvm storageclass is existing") } } else if !apierrors.IsNotFound(err) { return true, fmt.Errorf("error while getting old csi-lvm storageclass: %w", err)