Skip to content

Commit

Permalink
fix pontential crash that can happen when NGVS is called with ephemer…
Browse files Browse the repository at this point in the history
…al vol (#376)
  • Loading branch information
JacobGros authored Dec 13, 2024
1 parent e9b2cf0 commit b8062f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
23 changes: 12 additions & 11 deletions service/features/service.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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" |


6 changes: 6 additions & 0 deletions service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion service/step_defs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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")
Expand Down

0 comments on commit b8062f5

Please sign in to comment.