diff --git a/src/csi/driver/node.go b/src/csi/driver/node.go index 4e734ea4..6c717377 100644 --- a/src/csi/driver/node.go +++ b/src/csi/driver/node.go @@ -173,6 +173,12 @@ func (d *Driver) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) ( } log.Infof("Get NodeId %s", nodeBytes) + if d.nodeName == "" { + return &csi.NodeGetInfoResponse{ + NodeId: string(nodeBytes), + }, nil + } + // Get topology info from Node labels topology, err := d.k8sUtils.GetNodeTopology(d.nodeName) if err != nil { diff --git a/src/utils/k8sutils/k8sutils.go b/src/utils/k8sutils/k8sutils.go index d24ad679..75712b7e 100644 --- a/src/utils/k8sutils/k8sutils.go +++ b/src/utils/k8sutils/k8sutils.go @@ -62,7 +62,7 @@ func (k *KubeClient) GetNodeTopology(nodeName string) (map[string]string, error) topology := make(map[string]string) for key, value := range k8sNode.Labels { - if match, err := regexp.MatchString(topologyRegx, key); err !=nil && match { + if match, err := regexp.MatchString(topologyRegx, key); err == nil && match { topology[key] = value } } diff --git a/yamls/deploy/huawei-csi-rbac.yaml b/yamls/deploy/huawei-csi-rbac.yaml index f90380a2..6e81156d 100644 --- a/yamls/deploy/huawei-csi-rbac.yaml +++ b/yamls/deploy/huawei-csi-rbac.yaml @@ -100,6 +100,9 @@ rules: - apiGroups: [""] resources: ["events"] verbs: ["get", "list", "watch", "create", "update", "patch"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get"] --- kind: ClusterRoleBinding diff --git a/yamls/deploy/huawei-csi-resize-rbac.yaml b/yamls/deploy/huawei-csi-resize-rbac.yaml index 57e11aee..3ca0f90b 100644 --- a/yamls/deploy/huawei-csi-resize-rbac.yaml +++ b/yamls/deploy/huawei-csi-resize-rbac.yaml @@ -164,6 +164,9 @@ rules: - apiGroups: [""] resources: ["events"] verbs: ["get", "list", "watch", "create", "update", "patch"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get"] --- kind: ClusterRoleBinding diff --git a/yamls/deploy/huawei-csi-resize-snapshot-rbac.yaml b/yamls/deploy/huawei-csi-resize-snapshot-rbac.yaml index 0a189402..779bf7a1 100644 --- a/yamls/deploy/huawei-csi-resize-snapshot-rbac.yaml +++ b/yamls/deploy/huawei-csi-resize-snapshot-rbac.yaml @@ -298,6 +298,9 @@ rules: - apiGroups: [""] resources: ["events"] verbs: ["get", "list", "watch", "create", "update", "patch"] + - apiGroups: [""] + resources: ["nodes"] + verbs: ["get"] --- kind: ClusterRoleBinding