From 40cb7133ec8d03a4e4f925a0e5b9e735ad7107c5 Mon Sep 17 00:00:00 2001 From: Rajshree Khare Date: Wed, 25 Jan 2023 15:54:30 +0530 Subject: [PATCH 01/11] first draft added --- helm/csi-vxflexos/templates/controller.yaml | 4 ++++ helm/csi-vxflexos/values.yaml | 2 ++ overrides.mk | 4 ++-- service/controller.go | 13 +++++++++++++ service/envvars.go | 2 ++ service/service.go | 9 +++++++++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/helm/csi-vxflexos/templates/controller.yaml b/helm/csi-vxflexos/templates/controller.yaml index d083f6a3..248e8648 100644 --- a/helm/csi-vxflexos/templates/controller.yaml +++ b/helm/csi-vxflexos/templates/controller.yaml @@ -345,6 +345,10 @@ spec: value: "{{ .Values.controller.healthMonitor.enabled }}" {{- end }} {{- end }} + {{- if eq .Values.controller.approveSDCEnabled true}} + - name: X_CSI_APPROVE_SDC_ENABLED + value: "{{ .Values.controller.approveSDCEnabled }}" + {{- end }} volumeMounts: - name: socket-dir mountPath: /var/run/csi diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index ee36e0ff..c9c2e69b 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -144,6 +144,8 @@ controller: # operator: "Exists" # effect: "NoSchedule" + approveSDCEnabled: true + # "node" allows to configure node specific parameters node: healthMonitor: diff --git a/overrides.mk b/overrides.mk index cd5a113a..c51207ac 100644 --- a/overrides.mk +++ b/overrides.mk @@ -7,10 +7,10 @@ DEFAULT_BASEIMAGE="registry.access.redhat.com/ubi8/ubi-minimal" # digest for 8.6-994 DEFAULT_DIGEST="sha256:c5ffdf5938d73283cec018f2adf59f0ed9f8c376d93e415a27b16c3c6aad6f45" DEFAULT_GOVERSION="1.19.2" -DEFAULT_REGISTRY="sample_registry" +DEFAULT_REGISTRY="amaas-eos-mw1.cec.lab.emc.com:5036" DEFAULT_IMAGENAME="csi-vxflexos" DEFAULT_BUILDSTAGE="final" -DEFAULT_IMAGETAG="" +DEFAULT_IMAGETAG="preapp-guid" # set the BASEIMAGE if needed ifeq ($(BASEIMAGE),) diff --git a/service/controller.go b/service/controller.go index 7c33d231..5256fd2b 100644 --- a/service/controller.go +++ b/service/controller.go @@ -712,6 +712,19 @@ func (s *service) ControllerPublishVolume( return nil, status.Errorf(codes.NotFound, err.Error()) } + // pre-approved guid check + if s.opts.IsApproveSDCEnabled { + // fetch sdc mode set for the system + system := s.systems[systemID] + Log.Infof("systemID.............. %s\n", system.System.ID) + Log.Infof("systemName.............. %s\n", system.System.Name) + Log.Infof("RestrictedSdcModeEnabled.............. %s\n", system.System.RestrictedSdcModeEnabled) + Log.Infof("RestrictedSdcMode.............. %s\n", system.System.RestrictedSdcMode) + //if s.System.RestrictedSdcModeEnabled { + // if s.System.RestrictedSdcMode == "Guid" + // if restrictedSdcModeEnabled==true + } + vc := req.GetVolumeCapability() if vc == nil { return nil, status.Error(codes.InvalidArgument, diff --git a/service/envvars.go b/service/envvars.go index 0193a794..c415ba0f 100644 --- a/service/envvars.go +++ b/service/envvars.go @@ -47,4 +47,6 @@ const ( // EnvSDCPrefix is the name of the environment variable used to set the prefix for SDC name. This is only used by // the Node Service. EnvSDCPrefix = "X_CSI_RENAME_SDC_PREFIX" + + EnvIsApproveSDCEnabled = "X_CSI_APPROVE_SDC_ENABLED" ) diff --git a/service/service.go b/service/service.go index 7ca596bc..49f31e37 100644 --- a/service/service.go +++ b/service/service.go @@ -135,6 +135,7 @@ type Opts struct { IsHealthMonitorEnabled bool // allow driver to make use of the alpha feature gate, CSIVolumeHealth IsSdcRenameEnabled bool // allow driver to enable renaming SDC SdcPrefix string // prefix to be set for SDC name + IsApproveSDCEnabled bool } type service struct { @@ -325,6 +326,7 @@ func (s *service) BeforeServe( "IsHealthMonitorEnabled": s.opts.IsHealthMonitorEnabled, "IsSdcRenameEnabled": s.opts.IsSdcRenameEnabled, "sdcPrefix": s.opts.SdcPrefix, + "IsApproveSDCEnabled": s.opts.IsApproveSDCEnabled, } Log.WithFields(fields).Infof("configured %s", Name) @@ -388,6 +390,13 @@ func (s *service) BeforeServe( if sdcPrefix, ok := csictx.LookupEnv(ctx, EnvSDCPrefix); ok { opts.SdcPrefix = sdcPrefix } + if approveSDC, ok := csictx.LookupEnv(ctx, EnvIsApproveSDCEnabled); ok { + if approveSDC == "true" { + opts.IsApproveSDCEnabled = true + } + } else { + opts.IsApproveSDCEnabled = false + } if s.privDir == "" { s.privDir = defaultPrivDir } From d07f9375acdfb85b333b65575607b6d37c1c757c Mon Sep 17 00:00:00 2001 From: Rajshree Khare Date: Wed, 25 Jan 2023 17:49:29 +0530 Subject: [PATCH 02/11] second draft added --- helm/csi-vxflexos/values.yaml | 2 ++ overrides.mk | 4 ++-- service/controller.go | 28 ++++++++++++++++++++-------- service/envvars.go | 2 ++ 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index c9c2e69b..229a7ff0 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -144,6 +144,8 @@ controller: # operator: "Exists" # effect: "NoSchedule" + # "approveSDCEnabled" defines whether to enable/disable SDC approval + # Default value: false approveSDCEnabled: true # "node" allows to configure node specific parameters diff --git a/overrides.mk b/overrides.mk index c51207ac..cd5a113a 100644 --- a/overrides.mk +++ b/overrides.mk @@ -7,10 +7,10 @@ DEFAULT_BASEIMAGE="registry.access.redhat.com/ubi8/ubi-minimal" # digest for 8.6-994 DEFAULT_DIGEST="sha256:c5ffdf5938d73283cec018f2adf59f0ed9f8c376d93e415a27b16c3c6aad6f45" DEFAULT_GOVERSION="1.19.2" -DEFAULT_REGISTRY="amaas-eos-mw1.cec.lab.emc.com:5036" +DEFAULT_REGISTRY="sample_registry" DEFAULT_IMAGENAME="csi-vxflexos" DEFAULT_BUILDSTAGE="final" -DEFAULT_IMAGETAG="preapp-guid" +DEFAULT_IMAGETAG="" # set the BASEIMAGE if needed ifeq ($(BASEIMAGE),) diff --git a/service/controller.go b/service/controller.go index 5256fd2b..2b9d6ea3 100644 --- a/service/controller.go +++ b/service/controller.go @@ -712,17 +712,29 @@ func (s *service) ControllerPublishVolume( return nil, status.Errorf(codes.NotFound, err.Error()) } - // pre-approved guid check + // support for pre-approved guid + sdc, err := s.systems[systemID].FindSdc("ID", sdcID) + if err != nil { + return nil, status.Errorf(codes.FailedPrecondition, "%s", err) + } if s.opts.IsApproveSDCEnabled { + Log.Infof("Approve SDC enabled") + // fetch sdc mode set for the system system := s.systems[systemID] - Log.Infof("systemID.............. %s\n", system.System.ID) - Log.Infof("systemName.............. %s\n", system.System.Name) - Log.Infof("RestrictedSdcModeEnabled.............. %s\n", system.System.RestrictedSdcModeEnabled) - Log.Infof("RestrictedSdcMode.............. %s\n", system.System.RestrictedSdcMode) - //if s.System.RestrictedSdcModeEnabled { - // if s.System.RestrictedSdcMode == "Guid" - // if restrictedSdcModeEnabled==true + if system.System.RestrictedSdcModeEnabled && system.System.RestrictedSdcMode == "Guid" { + if !sdc.Sdc.SdcApproved { + resp, err := s.systems[systemID].ApproveSdcByGUID(sdc.Sdc.SdcGUID) + if resp == nil && err == nil { + Log.Infof("SDC approved, SDC GUID: %s", sdc.Sdc.SdcGUID) + } else if err != nil { + return nil, status.Errorf(codes.FailedPrecondition, "%s", err) + } + } else { + Log.Infof("SDC already approved, SDC GUID: %s", sdc.Sdc.SdcGUID) + } + + } } vc := req.GetVolumeCapability() diff --git a/service/envvars.go b/service/envvars.go index c415ba0f..a61b06c6 100644 --- a/service/envvars.go +++ b/service/envvars.go @@ -48,5 +48,7 @@ const ( // the Node Service. EnvSDCPrefix = "X_CSI_RENAME_SDC_PREFIX" + // EnvIsApproveSDCEnabled is the name of the environment variable that specifies if the SDC approval is to be + // carried out or not. EnvIsApproveSDCEnabled = "X_CSI_APPROVE_SDC_ENABLED" ) From f824307bfa56281c77d36ae652b0978095356b37 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Wed, 1 Feb 2023 06:41:44 -0500 Subject: [PATCH 03/11] changed the ApproveSdc logic in controllerPubishVolumefn. --- service/controller.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/service/controller.go b/service/controller.go index 2b9d6ea3..51996779 100644 --- a/service/controller.go +++ b/service/controller.go @@ -725,11 +725,19 @@ func (s *service) ControllerPublishVolume( if system.System.RestrictedSdcModeEnabled && system.System.RestrictedSdcMode == "Guid" { if !sdc.Sdc.SdcApproved { resp, err := s.systems[systemID].ApproveSdcByGUID(sdc.Sdc.SdcGUID) - if resp == nil && err == nil { - Log.Infof("SDC approved, SDC GUID: %s", sdc.Sdc.SdcGUID) - } else if err != nil { + + // if resp == nil && err == nil { + // Log.Infof("SDC approved, SDC GUID: %s", sdc.Sdc.SdcGUID) + // } else if err != nil { + // return nil, status.Errorf(codes.FailedPrecondition, "%s", err) + // } + + if err != nil { return nil, status.Errorf(codes.FailedPrecondition, "%s", err) } + + Log.Infof("SDC Approved, SDC Id: %s and SDC GUID: %s", resp.SdcID, sdc.Sdc.SdcGUID) + } else { Log.Infof("SDC already approved, SDC GUID: %s", sdc.Sdc.SdcGUID) } From 242bdd04960c703547bc6e1a6177571dd524cfc1 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Wed, 1 Feb 2023 13:03:19 -0500 Subject: [PATCH 04/11] moved the approveSdc logic to nodeProbe fn. --- service/controller.go | 33 --------------------------------- service/node.go | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/service/controller.go b/service/controller.go index 51996779..7c33d231 100644 --- a/service/controller.go +++ b/service/controller.go @@ -712,39 +712,6 @@ func (s *service) ControllerPublishVolume( return nil, status.Errorf(codes.NotFound, err.Error()) } - // support for pre-approved guid - sdc, err := s.systems[systemID].FindSdc("ID", sdcID) - if err != nil { - return nil, status.Errorf(codes.FailedPrecondition, "%s", err) - } - if s.opts.IsApproveSDCEnabled { - Log.Infof("Approve SDC enabled") - - // fetch sdc mode set for the system - system := s.systems[systemID] - if system.System.RestrictedSdcModeEnabled && system.System.RestrictedSdcMode == "Guid" { - if !sdc.Sdc.SdcApproved { - resp, err := s.systems[systemID].ApproveSdcByGUID(sdc.Sdc.SdcGUID) - - // if resp == nil && err == nil { - // Log.Infof("SDC approved, SDC GUID: %s", sdc.Sdc.SdcGUID) - // } else if err != nil { - // return nil, status.Errorf(codes.FailedPrecondition, "%s", err) - // } - - if err != nil { - return nil, status.Errorf(codes.FailedPrecondition, "%s", err) - } - - Log.Infof("SDC Approved, SDC Id: %s and SDC GUID: %s", resp.SdcID, sdc.Sdc.SdcGUID) - - } else { - Log.Infof("SDC already approved, SDC GUID: %s", sdc.Sdc.SdcGUID) - } - - } - } - vc := req.GetVolumeCapability() if vc == nil { return nil, status.Error(codes.InvalidArgument, diff --git a/service/node.go b/service/node.go index a2d966b2..28b01ea7 100644 --- a/service/node.go +++ b/service/node.go @@ -407,6 +407,14 @@ func (s *service) nodeProbe(ctx context.Context) error { } } + // support for pre-approved guid + if s.opts.IsApproveSDCEnabled { + Log.Infof("Approve SDC enabled") + if err := s.approveSDC(s.opts); err != nil { + return err + } + } + // get all the system names and IDs. s.getSystemName(ctx, connectedSystemID) @@ -420,6 +428,33 @@ func (s *service) nodeProbe(ctx context.Context) error { return nil } +func (s *service) approveSDC(opts Opts) error { + + for _, systemID := range connectedSystemID { + system := s.systems[systemID] + + //fetch SDC details + sdc, err := s.systems[systemID].FindSdc("SdcGUID", opts.SdcGUID) + if err != nil { + return status.Errorf(codes.FailedPrecondition, "%s", err) + } + + //fetch the restrictedSdcMode + if system.System.RestrictedSdcModeEnabled && system.System.RestrictedSdcMode == "Guid" { + if !sdc.Sdc.SdcApproved { + resp, err := system.ApproveSdcByGUID(sdc.Sdc.SdcGUID) + if err != nil { + return status.Errorf(codes.FailedPrecondition, "%s", err) + } + Log.Infof("SDC Approved, SDC Id: %s and SDC GUID: %s", resp.SdcID, sdc.Sdc.SdcGUID) + } else { + Log.Infof("SDC already approved, SDC GUID: %s", sdc.Sdc.SdcGUID) + } + } + } + return nil +} + func (s *service) renameSDC(opts Opts) error { // fetch hostname hostName, ok := os.LookupEnv("HOSTNAME") From e1feb7391ff05c9a5b5c58a6a270915fb13b8535 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Wed, 1 Feb 2023 13:47:00 -0500 Subject: [PATCH 05/11] updated values and templates yamls. --- helm/csi-vxflexos/templates/controller.yaml | 4 ---- helm/csi-vxflexos/templates/node.yaml | 4 ++++ helm/csi-vxflexos/values.yaml | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/helm/csi-vxflexos/templates/controller.yaml b/helm/csi-vxflexos/templates/controller.yaml index 248e8648..d083f6a3 100644 --- a/helm/csi-vxflexos/templates/controller.yaml +++ b/helm/csi-vxflexos/templates/controller.yaml @@ -345,10 +345,6 @@ spec: value: "{{ .Values.controller.healthMonitor.enabled }}" {{- end }} {{- end }} - {{- if eq .Values.controller.approveSDCEnabled true}} - - name: X_CSI_APPROVE_SDC_ENABLED - value: "{{ .Values.controller.approveSDCEnabled }}" - {{- end }} volumeMounts: - name: socket-dir mountPath: /var/run/csi diff --git a/helm/csi-vxflexos/templates/node.yaml b/helm/csi-vxflexos/templates/node.yaml index f64cee92..43747215 100644 --- a/helm/csi-vxflexos/templates/node.yaml +++ b/helm/csi-vxflexos/templates/node.yaml @@ -203,6 +203,10 @@ spec: - name: X_CSI_HEALTH_MONITOR_ENABLED value: "{{ .Values.node.healthMonitor.enabled }}" {{- end }} + {{- if eq .Values.node.approveSDCEnabled true}} + - name: X_CSI_APPROVE_SDC_ENABLED + value: "{{ .Values.node.approveSDCEnabled }}" + {{- end }} {{- if hasKey .Values.node "renameSDC" }} - name: X_CSI_RENAME_SDC_ENABLED value: "{{ .Values.node.renameSDC.enabled }}" diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index 229a7ff0..9d361727 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -144,9 +144,6 @@ controller: # operator: "Exists" # effect: "NoSchedule" - # "approveSDCEnabled" defines whether to enable/disable SDC approval - # Default value: false - approveSDCEnabled: true # "node" allows to configure node specific parameters node: @@ -213,6 +210,10 @@ node: # Default value: none # Examples: "rhel-sdc", "sdc-test" prefix: "sdc-test" + + # "approveSDCEnabled" defines whether to enable/disable SDC approval + # Default value: false + approveSDCEnabled: true # monitoring pod details # These options control the running of the monitoring container From 903baf152a96bd062772d732a076ff98411bfe21 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Thu, 2 Feb 2023 08:50:47 -0500 Subject: [PATCH 06/11] Added required unit tests for the approveSdc --- service/features/get_sdc_instances.json | 2 +- service/features/get_system_instances.json | 4 ++-- service/features/service.feature | 17 +++++++++++++++++ service/step_defs_test.go | 9 +++++++++ service/step_handlers_test.go | 20 ++++++++++++++++++++ 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/service/features/get_sdc_instances.json b/service/features/get_sdc_instances.json index 65c713db..dd27fbae 100644 --- a/service/features/get_sdc_instances.json +++ b/service/features/get_sdc_instances.json @@ -2,7 +2,7 @@ { "versionInfo": null, "perfProfile": "Default", - "sdcApproved": true, + "sdcApproved": false, "osType": "Linux", "mdmConnectionState": "Connected", "memoryAllocationFailure": null, diff --git a/service/features/get_system_instances.json b/service/features/get_system_instances.json index 99a22ea2..9e08206b 100644 --- a/service/features/get_system_instances.json +++ b/service/features/get_system_instances.json @@ -151,8 +151,8 @@ "swid": "", "defaultIsVolumeObfuscated": false, "daysInstalled": 6, - "restrictedSdcModeEnabled": false, - "restrictedSdcMode": "None", + "restrictedSdcModeEnabled": true, + "restrictedSdcMode": "Guid", "maxCapacityInGb": "Unlimited", "capacityTimeLeftInDays": "Unlimited", "enterpriseFeaturesEnabled": true, diff --git a/service/features/service.feature b/service/features/service.feature index 5eb9d6ba..05a6de03 100644 --- a/service/features/service.feature +++ b/service/features/service.feature @@ -972,3 +972,20 @@ Feature: VxFlex OS CSI interface And I call Probe When I call Node Probe Then the error contains "induced error" + + Scenario: Call Probe for approving sdc + Given a VxFlexOS service + And I set approveSDC with approveSDCEnabled "true" + And I call Probe + When I call Node Probe + Then the error contains "none" + + Scenario: Call Probe for approving sdc, invalid guid + Given a VxFlexOS service + And I induce error "ApproveSdcError" + And I set approveSDC with approveSDCEnabled "true" + And I call Probe + When I call Node Probe + Then the error contains "The given GUID is invalid" + + diff --git a/service/step_defs_test.go b/service/step_defs_test.go index 0c632365..92d61df9 100644 --- a/service/step_defs_test.go +++ b/service/step_defs_test.go @@ -992,6 +992,8 @@ func (f *feature) iInduceError(errtype string) error { stepHandlersErrors.NoVolIDSDCError = true case "SetSdcNameError": stepHandlersErrors.SetSdcNameError = true + case "ApproveSdcError": + stepHandlersErrors.ApproveSdcError = true case "NoVolError": stepHandlersErrors.NoVolError = true case "SetVolumeSizeError": @@ -3378,6 +3380,12 @@ func (f *feature) iSetRenameSdcEnabledWithPrefix(renameEnabled string, prefix st f.service.opts.SdcPrefix = prefix return nil } +func (f *feature) iSetApproveSdcEnabled(approveSDCEnabled string) error { + if approveSDCEnabled == "true" { + f.service.opts.IsApproveSDCEnabled = true + } + return nil +} func FeatureContext(s *godog.ScenarioContext) { f := &feature{} @@ -3539,6 +3547,7 @@ func FeatureContext(s *godog.ScenarioContext) { s.Step(`^I call GetReplicationCapabilities$`, f.iCallGetReplicationCapabilities) s.Step(`^a "([^"]*)" replication capabilities structure is returned$`, f.aReplicationCapabilitiesStructureIsReturned) s.Step(`^I set renameSDC with renameEnabled "([^"]*)" prefix "([^"]*)"$`, f.iSetRenameSdcEnabledWithPrefix) + s.Step(`^I set approveSDC with approveSDCEnabled "([^"]*)"`, f.iSetApproveSdcEnabled) s.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) { if f.server != nil { diff --git a/service/step_handlers_test.go b/service/step_handlers_test.go index 40a924ed..65d8ab54 100644 --- a/service/step_handlers_test.go +++ b/service/step_handlers_test.go @@ -50,6 +50,7 @@ var ( GetSystemSdcError bool GetSdcInstancesError bool MapSdcError bool + ApproveSdcError bool RemoveMappedSdcError bool SDCLimitsError bool SIOGatewayVolumeNotFoundError bool @@ -170,6 +171,7 @@ func getHandler() http.Handler { stepHandlersErrors.NoVolIDSDCError = false stepHandlersErrors.NoVolError = false stepHandlersErrors.SetSdcNameError = false + stepHandlersErrors.ApproveSdcError = false sdcMappings = sdcMappings[:0] sdcMappingsID = "" return handler @@ -421,6 +423,24 @@ func handleAction(w http.ResponseWriter, r *http.Request) { setSdcNameSuccess = true + case "approveSdc": + errMsg := "The given GUID is invalid.Please specify GUID in the following format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" + if stepHandlersErrors.ApproveSdcError { + writeError(w, errMsg, http.StatusInternalServerError, codes.Internal) + } + req := types.ApproveSdcParam{} + decoder := json.NewDecoder(r.Body) + err := decoder.Decode(&req) + if err != nil { + log.Printf("error decoding json: %s\n", err.Error()) + } + resp := types.ApproveSdcByGUIDResponse{SdcID: "d0f055a700000000"} + encoder := json.NewEncoder(w) + err = encoder.Encode(resp) + if err != nil { + log.Printf("error encoding json: %s\n", err.Error()) + } + case "addMappedSdc": if stepHandlersErrors.MapSdcError { writeError(w, "induced error", http.StatusRequestTimeout, codes.Internal) From 1b1b2a0a6984ef92e3d424731c680864bdcbf99a Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Thu, 2 Feb 2023 08:55:11 -0500 Subject: [PATCH 07/11] corrected the default value of approveSDCEnabled --- helm/csi-vxflexos/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index 9d361727..1796670e 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -213,7 +213,7 @@ node: # "approveSDCEnabled" defines whether to enable/disable SDC approval # Default value: false - approveSDCEnabled: true + approveSDCEnabled: false # monitoring pod details # These options control the running of the monitoring container From d165c935cda47a88853c4394d98985fb04c2a3d6 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Thu, 2 Feb 2023 09:15:54 -0500 Subject: [PATCH 08/11] removed the extra line in values.yaml --- helm/csi-vxflexos/values.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index 1796670e..9bc44e48 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -144,7 +144,6 @@ controller: # operator: "Exists" # effect: "NoSchedule" - # "node" allows to configure node specific parameters node: healthMonitor: From 74eaf1338181b13ed12333b78e0af6ce8139ecb4 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Thu, 2 Feb 2023 12:27:17 -0500 Subject: [PATCH 09/11] add logs and err messages for non-guid restrictedSdcMode --- service/node.go | 12 +++++++++++- service/service.go | 3 +-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/service/node.go b/service/node.go index 28b01ea7..693b3493 100644 --- a/service/node.go +++ b/service/node.go @@ -440,7 +440,7 @@ func (s *service) approveSDC(opts Opts) error { } //fetch the restrictedSdcMode - if system.System.RestrictedSdcModeEnabled && system.System.RestrictedSdcMode == "Guid" { + if system.System.RestrictedSdcMode == "Guid" { if !sdc.Sdc.SdcApproved { resp, err := system.ApproveSdcByGUID(sdc.Sdc.SdcGUID) if err != nil { @@ -450,7 +450,17 @@ func (s *service) approveSDC(opts Opts) error { } else { Log.Infof("SDC already approved, SDC GUID: %s", sdc.Sdc.SdcGUID) } + } else { + if !sdc.Sdc.SdcApproved { + return status.Errorf(codes.FailedPrecondition, + "Array RestrictedSdcMode is %s, driver only supports GUID RestrictedSdcMode cannot approve SDC %s", + system.System.RestrictedSdcMode, sdc.Sdc.SdcGUID) + } + Log.Warnf("Array RestrictedSdcMode is %s, driver only supports GUID RestrictedSdcMode If SDC becomes restricted again, driver will not be able to approve", + system.System.RestrictedSdcMode) + } + } return nil } diff --git a/service/service.go b/service/service.go index 49f31e37..bf075fe7 100644 --- a/service/service.go +++ b/service/service.go @@ -394,9 +394,8 @@ func (s *service) BeforeServe( if approveSDC == "true" { opts.IsApproveSDCEnabled = true } - } else { - opts.IsApproveSDCEnabled = false } + if s.privDir == "" { s.privDir = defaultPrivDir } From 5dc533c03d13ff4b810bd74503a1ded5419a2d46 Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Thu, 2 Feb 2023 14:24:21 -0500 Subject: [PATCH 10/11] handled the system nil error and changed the node and values yaml --- helm/csi-vxflexos/templates/node.yaml | 4 ++-- helm/csi-vxflexos/values.yaml | 14 ++++++++++---- service/node.go | 4 ++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/helm/csi-vxflexos/templates/node.yaml b/helm/csi-vxflexos/templates/node.yaml index 43747215..2ba5d3c6 100644 --- a/helm/csi-vxflexos/templates/node.yaml +++ b/helm/csi-vxflexos/templates/node.yaml @@ -203,9 +203,9 @@ spec: - name: X_CSI_HEALTH_MONITOR_ENABLED value: "{{ .Values.node.healthMonitor.enabled }}" {{- end }} - {{- if eq .Values.node.approveSDCEnabled true}} + {{- if hasKey .Values.node "approveSDC" }} - name: X_CSI_APPROVE_SDC_ENABLED - value: "{{ .Values.node.approveSDCEnabled }}" + value: "{{ .Values.node.approveSDC.enabled }}" {{- end }} {{- if hasKey .Values.node "renameSDC" }} - name: X_CSI_RENAME_SDC_ENABLED diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index 9bc44e48..64b11459 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -209,10 +209,16 @@ node: # Default value: none # Examples: "rhel-sdc", "sdc-test" prefix: "sdc-test" - - # "approveSDCEnabled" defines whether to enable/disable SDC approval - # Default value: false - approveSDCEnabled: false + + # "approveSDC" defines the approve operation for SDC + # Default value: None + approveSDC: + # enabled: Enable/Disable SDC approval + #Allowed values: + # true: enable approval + # false: disable approval + # Default value: false + enabled: false # monitoring pod details # These options control the running of the monitoring container diff --git a/service/node.go b/service/node.go index 693b3493..d26246bf 100644 --- a/service/node.go +++ b/service/node.go @@ -433,6 +433,10 @@ func (s *service) approveSDC(opts Opts) error { for _, systemID := range connectedSystemID { system := s.systems[systemID] + if system == nil { + return nil + } + //fetch SDC details sdc, err := s.systems[systemID].FindSdc("SdcGUID", opts.SdcGUID) if err != nil { From f92a7d930e5cb72f2ad950ce2f666f7712cc721c Mon Sep 17 00:00:00 2001 From: VamsiSiddu-7 Date: Fri, 3 Feb 2023 00:46:05 -0500 Subject: [PATCH 11/11] fix comments and error messages in values and nodeProbe --- helm/csi-vxflexos/values.yaml | 4 ++-- service/node.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/helm/csi-vxflexos/values.yaml b/helm/csi-vxflexos/values.yaml index 64b11459..c75653ec 100644 --- a/helm/csi-vxflexos/values.yaml +++ b/helm/csi-vxflexos/values.yaml @@ -215,8 +215,8 @@ node: approveSDC: # enabled: Enable/Disable SDC approval #Allowed values: - # true: enable approval - # false: disable approval + # true: Driver will attempt to approve restricted SDC by GUID during setup + # false: Driver will not attempt to approve restricted SDC by GUID during setup # Default value: false enabled: false diff --git a/service/node.go b/service/node.go index d26246bf..ce966e38 100644 --- a/service/node.go +++ b/service/node.go @@ -434,7 +434,7 @@ func (s *service) approveSDC(opts Opts) error { system := s.systems[systemID] if system == nil { - return nil + continue } //fetch SDC details @@ -456,8 +456,7 @@ func (s *service) approveSDC(opts Opts) error { } } else { if !sdc.Sdc.SdcApproved { - return status.Errorf(codes.FailedPrecondition, - "Array RestrictedSdcMode is %s, driver only supports GUID RestrictedSdcMode cannot approve SDC %s", + return status.Errorf(codes.FailedPrecondition, "Array RestrictedSdcMode is %s, driver only supports GUID RestrictedSdcMode cannot approve SDC %s", system.System.RestrictedSdcMode, sdc.Sdc.SdcGUID) } Log.Warnf("Array RestrictedSdcMode is %s, driver only supports GUID RestrictedSdcMode If SDC becomes restricted again, driver will not be able to approve",