From 4e1714d55cf257b903ce1c2b3adcbbee69167241 Mon Sep 17 00:00:00 2001 From: Divyen Patel Date: Thu, 16 Apr 2020 11:27:51 -0700 Subject: [PATCH] removed mounting vsphere csi conf secret in vsphere-csi-node daemonset --- .../vanilla/deploy/vsphere-csi-node-ds.yaml | 19 +++++++++++-------- .../vanilla/deploy/vsphere-csi-node-ds.yaml | 19 +++++++++++-------- pkg/common/config/config.go | 5 +++-- pkg/csi/service/node.go | 8 ++++++++ 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/manifests/vsphere-67u3/vanilla/deploy/vsphere-csi-node-ds.yaml b/manifests/vsphere-67u3/vanilla/deploy/vsphere-csi-node-ds.yaml index 285272a015..eb85feba3c 100644 --- a/manifests/vsphere-67u3/vanilla/deploy/vsphere-csi-node-ds.yaml +++ b/manifests/vsphere-67u3/vanilla/deploy/vsphere-csi-node-ds.yaml @@ -55,8 +55,9 @@ spec: value: "node" - name: X_CSI_SPEC_REQ_VALIDATION value: "false" - - name: VSPHERE_CSI_CONFIG - value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag + # needed only for topology aware setups + #- name: VSPHERE_CSI_CONFIG + # value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag - name: X_CSI_DEBUG value: "true" - name: LOGGER_LEVEL @@ -67,9 +68,10 @@ spec: add: ["SYS_ADMIN"] allowPrivilegeEscalation: true volumeMounts: - - name: vsphere-config-volume - mountPath: /etc/cloud - readOnly: true + # needed only for topology aware setups + #- name: vsphere-config-volume + # mountPath: /etc/cloud + # readOnly: true - name: plugin-dir mountPath: /csi - name: pods-mount-dir @@ -102,9 +104,10 @@ spec: - name: plugin-dir mountPath: /csi volumes: - - name: vsphere-config-volume - secret: - secretName: vsphere-config-secret + # needed only for topology aware setups + #- name: vsphere-config-volume + # secret: + # secretName: vsphere-config-secret - name: registration-dir hostPath: path: /var/lib/kubelet/plugins_registry diff --git a/manifests/vsphere-7.0/vanilla/deploy/vsphere-csi-node-ds.yaml b/manifests/vsphere-7.0/vanilla/deploy/vsphere-csi-node-ds.yaml index 285272a015..eb85feba3c 100644 --- a/manifests/vsphere-7.0/vanilla/deploy/vsphere-csi-node-ds.yaml +++ b/manifests/vsphere-7.0/vanilla/deploy/vsphere-csi-node-ds.yaml @@ -55,8 +55,9 @@ spec: value: "node" - name: X_CSI_SPEC_REQ_VALIDATION value: "false" - - name: VSPHERE_CSI_CONFIG - value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag + # needed only for topology aware setups + #- name: VSPHERE_CSI_CONFIG + # value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag - name: X_CSI_DEBUG value: "true" - name: LOGGER_LEVEL @@ -67,9 +68,10 @@ spec: add: ["SYS_ADMIN"] allowPrivilegeEscalation: true volumeMounts: - - name: vsphere-config-volume - mountPath: /etc/cloud - readOnly: true + # needed only for topology aware setups + #- name: vsphere-config-volume + # mountPath: /etc/cloud + # readOnly: true - name: plugin-dir mountPath: /csi - name: pods-mount-dir @@ -102,9 +104,10 @@ spec: - name: plugin-dir mountPath: /csi volumes: - - name: vsphere-config-volume - secret: - secretName: vsphere-config-secret + # needed only for topology aware setups + #- name: vsphere-config-volume + # secret: + # secretName: vsphere-config-secret - name: registration-dir hostPath: path: /var/lib/kubelet/plugins_registry diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index b2af2b9cfc..090f852635 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -315,10 +315,11 @@ func GetCnsconfig(ctx context.Context, cfgPath string) (*Config, error) { var cfg *Config //Read in the vsphere.conf if it exists if _, err := os.Stat(cfgPath); os.IsNotExist(err) { + log.Infof("Could not stat %s, reading config params from env", cfgPath) // config from Env var only cfg = &Config{} - if err := FromEnv(ctx, cfg); err != nil { - log.Errorf("Error reading vsphere.conf\n") + if fromEnvErr := FromEnv(ctx, cfg); fromEnvErr != nil { + log.Errorf("Failed to get config params from env. Err: %v", fromEnvErr) return cfg, err } } else { diff --git a/pkg/csi/service/node.go b/pkg/csi/service/node.go index be5a71c2e2..f79c98a317 100644 --- a/pkg/csi/service/node.go +++ b/pkg/csi/service/node.go @@ -44,6 +44,7 @@ import ( "k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/resizefs" "k8s.io/kubernetes/pkg/volume/util/fs" + cnsvsphere "sigs.k8s.io/vsphere-csi-driver/pkg/common/cns-lib/vsphere" cnsconfig "sigs.k8s.io/vsphere-csi-driver/pkg/common/config" "sigs.k8s.io/vsphere-csi-driver/pkg/csi/service/common" @@ -652,6 +653,12 @@ func (s *service) NodeGetInfo( } cfg, err := cnsconfig.GetCnsconfig(ctx, cfgPath) if err != nil { + if os.IsNotExist(err) { + log.Infof("Config file not provided to node daemonset. Assuming non-topology aware cluster.") + return &csi.NodeGetInfoResponse{ + NodeId: nodeID, + }, nil + } log.Errorf("failed to read cnsconfig. Error: %v", err) return nil, status.Errorf(codes.Internal, err.Error()) } @@ -659,6 +666,7 @@ func (s *service) NodeGetInfo( topology := &csi.Topology{} if cfg.Labels.Zone != "" && cfg.Labels.Region != "" { + log.Infof("Config file provided to node daemonset with zones and regions. Assuming topology aware cluster.") vcenterconfig, err := cnsvsphere.GetVirtualCenterConfig(cfg) if err != nil { log.Errorf("failed to get VirtualCenterConfig from cns config. err=%v", err)