Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leader election conflict with csi-resizer bug fix #14

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

torredil
Copy link
Member

@torredil torredil commented Oct 3, 2023

Issue #, if available:

Description of changes:

This PR introduces modifications to ensure that the volumemodifier container sidecar initializes the controller service only if it is in the same pod as the csi-resizer leader. This determination is made by monitoring the leases object. If the controller service is running but the pod is not the leader, the controller service will be stopped.

Pod name will be supplied via downward API:

- name: POD_NAME
           valueFrom:
             fieldRef:
               fieldPath: metadata.name

Additionally, the following clusterrole will be necessary:

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: ebs-external-modifier-role
  labels:
    {{- include "aws-ebs-csi-driver.labels" . | nindent 4 }}
rules:
  - apiGroups: [ "coordination.k8s.io" ]
    resources: [ "leases" ]
    verbs: [ "get", "list", "watch", "update", "patch" ]
  {{- with .Values.sidecars.attacher.additionalClusterRoleRules }}
    {{- . | toYaml | nindent 2 }}
  {{- end }}

Testing:

$ kubectl get leases -n kube-system
NAME                                       HOLDER                                                                  AGE
external-resizer-ebs-csi-aws-com           ebs-csi-controller-79cb7bc657-ch4zd                                     20m

$ kubectl logs  ebs-csi-controller-79cb7bc657-ch4zd -n kube-system -c volumemodifier   
I1003 14:37:53.657602       1 main.go:74] Version : v0.1.1
I1003 14:37:53.665513       1 common.go:111] Probing CSI driver for readiness
I1003 14:37:53.677936       1 main.go:116] CSI driver name: "ebs.csi.aws.com"
I1003 14:37:54.142566       1 main.go:179] "Starting controller" podName="ebs-csi-controller-79cb7bc657-ch4zd" currentLeader="ebs-csi-controller-79cb7bc657-ch4zd"
I1003 14:37:54.142627       1 controller.go:95] "Starting external modifier" name="ebs.csi.aws.com"

$ kubectl delete leases external-resizer-ebs-csi-aws-com -n kube-system

$ kubectl get leases -n kube-system
 external-resizer-ebs-csi-aws-com           ebs-csi-controller-79cb7bc657-lr6rw                                     1s

$ kubectl logs  ebs-csi-controller-79cb7bc657-lr6rw -n kube-system -c volumemodifier   
I1003 14:40:51.085418       1 main.go:74] Version : v0.1.1
I1003 14:40:51.087163       1 common.go:111] Probing CSI driver for readiness
I1003 14:40:51.090251       1 main.go:116] CSI driver name: "ebs.csi.aws.com"
I1003 15:02:30.527414       1 main.go:179] "Starting controller" podName="ebs-csi-controller-79cb7bc657-lr6rw" currentLeader="ebs-csi-controller-79cb7bc657-lr6rw"
I1003 15:02:30.527479       1 controller.go:95] "Starting external modifier" name="ebs.csi.aws.com"

$ kubectl logs ebs-csi-controller-79cb7bc657-ch4zd -n kube-system -c volumemodifier  
I1003 15:02:31.443715       1 main.go:74] Version : v0.1.1
I1003 15:02:31.450041       1 common.go:111] Probing CSI driver for readiness
I1003 15:02:31.469327       1 main.go:116] CSI driver name: "ebs.csi.aws.com"

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@torredil
Copy link
Member Author

torredil commented Oct 3, 2023

cc: @ConnorJC3 @AndrewSirenko

cmd/main.go Outdated Show resolved Hide resolved
ConnorJC3
ConnorJC3 previously approved these changes Oct 4, 2023
Copy link
Contributor

@ConnorJC3 ConnorJC3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

pkg/controller/controller.go Outdated Show resolved Hide resolved
@ConnorJC3
Copy link
Contributor

Also, can we put "Closes" in the PR description in front of the issues in the Issue #, if available: section (so this PR will auto-link to them)?

ConnorJC3
ConnorJC3 previously approved these changes Oct 4, 2023
Copy link
Contributor

@ConnorJC3 ConnorJC3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@AndrewSirenko
Copy link
Contributor

/lgtm

@AndrewSirenko
Copy link
Contributor

/approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Leader election conflict with csi-resizer
3 participants