From b8062f5729d318fc6a7abef6d9d72009efb7cfe3 Mon Sep 17 00:00:00 2001 From: JacobGros Date: Fri, 13 Dec 2024 15:19:05 -0500 Subject: [PATCH] fix pontential crash that can happen when NGVS is called with ephemeral vol (#376) --- service/features/service.feature | 23 ++++++++++++----------- service/node.go | 6 ++++++ service/step_defs_test.go | 5 ++++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/service/features/service.feature b/service/features/service.feature index ab1797d2..5aaae654 100644 --- a/service/features/service.feature +++ b/service/features/service.feature @@ -1125,16 +1125,17 @@ Feature: VxFlex OS CSI interface And a correct NodeGetVolumeStats Response is returned Examples: - | error | errormsg | - | "none" | "none" | - | "BadVolIDError" | "id must be a hexadecimal" | - | "NoVolIDError" | "no volume ID provided" | - | "BadMountPathError" | "none" | - | "NoMountPathError" | "no volume Path provided" | - | "NoVolIDSDCError" | "none" | - | "GOFSMockGetMountsError" | "none" | - | "NoVolError" | "none" | - | "NoSysNameError" | "systemID is not found" | + | error | errormsg | + | "none" | "none" | + | "BadVolIDError" | "id must be a hexadecimal" | + | "NoVolIDError" | "no volume ID provided" | + | "BadMountPathError" | "none" | + | "NoMountPathError" | "no volume Path provided" | + | "NoVolIDSDCError" | "none" | + | "GOFSMockGetMountsError" | "none" | + | "NoVolError" | "none" | + | "NoSysNameError" | "systemID is not found" | + | "WrongSystemError" | "is not configured in the driver" | Scenario: Call getSystemNameMatchingError, should get error in log but no error returned Given a VxFlexOS service @@ -1552,4 +1553,4 @@ Feature: VxFlex OS CSI interface | systemid | nasserver | error | errorMsg | | "15dbbf5617523655" | "63ec8e0d-4551-29a7-e79c-b202f2b914f3" | "" | "none" | | "15dbbf5617523655" | "invalid-nas-server" | "NasNotFoundError" | "NAS server not found" | - \ No newline at end of file + diff --git a/service/node.go b/service/node.go index 816500f4..a3e21cb8 100644 --- a/service/node.go +++ b/service/node.go @@ -830,6 +830,12 @@ func (s *service) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolume "systemID is not found in the request and there is no default system") } + // make sure systemID we get is managed by the driver + if err := s.requireProbe(ctx, systemID); err != nil { + Log.Infof("System: %s is not managed by driver; volume stats will not be collected", systemID) + return nil, err + } + _, err := s.getSDCMappedVol(volID, systemID, 30) if err != nil { // volume not known to SDC, next check if it exists at all diff --git a/service/step_defs_test.go b/service/step_defs_test.go index 0931b2c6..e7d4d9ff 100644 --- a/service/step_defs_test.go +++ b/service/step_defs_test.go @@ -3348,6 +3348,9 @@ func (f *feature) iCallNodeGetVolumeStats() error { if stepHandlersErrors.NoSysNameError { f.service.opts.defaultSystemID = "" } + if stepHandlersErrors.WrongSystemError { + VolumeID = "wrongsystem-435645643" + } req := &csi.NodeGetVolumeStatsRequest{VolumeId: VolumeID, VolumePath: VolumePath} @@ -3357,7 +3360,7 @@ func (f *feature) iCallNodeGetVolumeStats() error { } func (f *feature) aCorrectNodeGetVolumeStatsResponse() error { - if stepHandlersErrors.NoVolIDError || stepHandlersErrors.NoMountPathError || stepHandlersErrors.BadVolIDError || stepHandlersErrors.NoSysNameError { + if stepHandlersErrors.NoVolIDError || stepHandlersErrors.NoMountPathError || stepHandlersErrors.BadVolIDError || stepHandlersErrors.NoSysNameError || stepHandlersErrors.WrongSystemError { // errors and no responses should be returned in these instances if f.nodeGetVolumeStatsResponse == nil { fmt.Printf("Response check passed\n")