Skip to content

Commit

Permalink
fix reconciling of shoot
Browse files Browse the repository at this point in the history
  • Loading branch information
ostempel committed Nov 18, 2024
1 parent 751bd21 commit 8f8b40d
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 5 deletions.
39 changes: 39 additions & 0 deletions example/pod.yaml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions example/pvc.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
k8s.io/apimachinery v0.31.1
k8s.io/code-generator v0.31.1
k8s.io/component-base v0.31.1
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
sigs.k8s.io/controller-runtime v0.17.5
)

Expand Down Expand Up @@ -122,7 +123,6 @@ require (
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubelet v0.29.5 // indirect
k8s.io/metrics v0.29.5 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20231015215740-bf15e44028f9 // indirect
sigs.k8s.io/controller-tools v0.14.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/csi-driver-lvm/actuator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
{
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down

0 comments on commit 8f8b40d

Please sign in to comment.