Skip to content

Commit

Permalink
Removed RBAC for Nodes, updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Danil-Grigorev committed Feb 3, 2020
1 parent 1c61d6a commit 8847215
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 61 deletions.
3 changes: 1 addition & 2 deletions cmd/csi-attacher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,11 @@ func main() {
}
if supportsAttach {
pvLister := factory.Core().V1().PersistentVolumes().Lister()
nodeLister := factory.Core().V1().Nodes().Lister()
vaLister := factory.Storage().V1beta1().VolumeAttachments().Lister()
csiNodeLister := factory.Storage().V1beta1().CSINodes().Lister()
volAttacher := attacher.NewAttacher(csiConn)
CSIVolumeLister := attacher.NewVolumeLister(csiConn)
handler = controller.NewCSIHandler(clientset, csiAttacher, volAttacher, CSIVolumeLister, pvLister, nodeLister, csiNodeLister, vaLister, timeout, supportsReadOnly, csitrans.New())
handler = controller.NewCSIHandler(clientset, csiAttacher, volAttacher, CSIVolumeLister, pvLister, csiNodeLister, vaLister, timeout, supportsReadOnly, csitrans.New())
klog.V(2).Infof("CSI driver supports ControllerPublishUnpublish, using real CSI handler")
} else {
handler = controller.NewTrivialHandler(clientset)
Expand Down
5 changes: 1 addition & 4 deletions deploy/kubernetes/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ metadata:
namespace: default

---
# Attacher must be able to work with PVs, nodes and VolumeAttachments
# Attacher must be able to work with PVs, CSINodes and VolumeAttachments
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand All @@ -25,9 +25,6 @@ rules:
- apiGroups: [""]
resources: ["persistentvolumes"]
verbs: ["get", "list", "watch", "update", "patch"]
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "list", "watch"]
- apiGroups: ["storage.k8s.io"]
resources: ["csinodes"]
verbs: ["get", "list", "watch"]
Expand Down
7 changes: 2 additions & 5 deletions pkg/controller/csi_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ type csiHandler struct {
attacher attacher.Attacher
CSIVolumeLister VolumeLister
pvLister corelisters.PersistentVolumeLister
nodeLister corelisters.NodeLister
csiNodeLister storagelisters.CSINodeLister
vaLister storagelisters.VolumeAttachmentLister
vaQueue, pvQueue workqueue.RateLimitingInterface
Expand All @@ -82,7 +81,6 @@ func NewCSIHandler(
attacher attacher.Attacher,
CSIVolumeLister VolumeLister,
pvLister corelisters.PersistentVolumeLister,
nodeLister corelisters.NodeLister,
csiNodeLister storagelisters.CSINodeLister,
vaLister storagelisters.VolumeAttachmentLister,
timeout *time.Duration,
Expand All @@ -95,7 +93,6 @@ func NewCSIHandler(
attacher: attacher,
CSIVolumeLister: CSIVolumeLister,
pvLister: pvLister,
nodeLister: nodeLister,
csiNodeLister: csiNodeLister,
vaLister: vaLister,
timeout: *timeout,
Expand Down Expand Up @@ -682,7 +679,7 @@ func (h *csiHandler) getCredentialsFromPV(csiSource *v1.CSIPersistentVolumeSourc
return credentials, nil
}

// getNodeID finds node ID from Node API object. If caller wants, it can find
// getNodeID finds node ID from CSINode API object. If caller wants, it can find
// node ID stored in VolumeAttachment annotation.
func (h *csiHandler) getNodeID(driver string, nodeName string, va *storage.VolumeAttachment) (string, error) {
// Try to find CSINode first.
Expand All @@ -709,7 +706,7 @@ func (h *csiHandler) getNodeID(driver string, nodeName string, va *storage.Volum
return nodeID, nil
}

// return nodeLister.Get error
// return csiNodeLister.Get error
return "", err
}

Expand Down
Loading

0 comments on commit 8847215

Please sign in to comment.