Skip to content

Commit 61510ae

Browse files
authored
nodeUnstageNVMeVolume idempotentcy changes
Idempotency changes for NVMe unstage
1 parent c4eb26c commit 61510ae

File tree

6 files changed

+20
-8
lines changed

6 files changed

+20
-8
lines changed

frontend/csi/node_server.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ var (
9393
betweenAttachAndLUKSPassphrase = fiji.Register("betweenAttachAndLUKSPassphrase", "node_server")
9494
duringIscsiLogout = fiji.Register("duringIscsiLogout", "node_server")
9595
afterInitialTrackingInfoWrite = fiji.Register("afterInitialTrackingInfoWrite", "node_server")
96+
afterNvmeLuksDeviceClosed = fiji.Register("afterNvmeLuksDeviceClosed", "node_server")
97+
afterNvmeDisconnect = fiji.Register("afterNvmeDisconnect", "node_server")
9698
)
9799

98100
const (
@@ -2930,8 +2932,8 @@ func (p *Plugin) nodeUnstageNVMeVolume(
29302932

29312933
luksMapperPath, err = p.devices.GetLUKSDeviceForMultipathDevice(devicePath)
29322934
if err != nil {
2933-
Logc(ctx).WithFields(fields).WithError(err).Error("Failed to get LUKS device path from device path.")
2934-
return &csi.NodeUnstageVolumeResponse{}, err
2935+
Logc(ctx).WithFields(fields).WithError(err).Debug("Failed to get LUKS device path from device path. " +
2936+
"Device may already be removed.")
29352937
}
29362938

29372939
if luksMapperPath != "" {
@@ -2943,6 +2945,9 @@ func (p *Plugin) nodeUnstageNVMeVolume(
29432945
}
29442946
Logc(ctx).WithFields(fields).WithError(err).Debug("LUKS close wait time exceeded, continuing with device removal.")
29452947
}
2948+
if err := afterNvmeLuksDeviceClosed.Inject(); err != nil {
2949+
return nil, err
2950+
}
29462951
}
29472952
}
29482953

@@ -2994,6 +2999,9 @@ func (p *Plugin) nodeUnstageNVMeVolume(
29942999
).WithError(err).Debug("Error disconnecting subsystem.")
29953000
}
29963001
}
3002+
if err := afterNvmeDisconnect.Inject(); err != nil {
3003+
return nil, err
3004+
}
29973005

29983006
volumeId, stagingTargetPath, err := p.getVolumeIdAndStagingPath(req)
29993007
if err != nil {

utils/nvme/nvme.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (s *NVMeSubsystem) GetNamespaceCount(ctx context.Context) (int, error) {
154154
return count, nil
155155
}
156156

157-
func (s *NVMeSubsystem) GetNVMeDevice(ctx context.Context, nsUUID string) (NVMeDeviceInterface, error) {
157+
func (s *NVMeSubsystem) GetNVMeDevice(ctx context.Context, nsUUID string) (*NVMeDevice, error) {
158158
Logc(ctx).Debug(">>>> nvme.GetNVMeDevice")
159159
defer Logc(ctx).Debug("<<<< nvme.GetNVMeDevice")
160160

utils/nvme/nvme_darwin.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (s *NVMeSubsystem) GetNVMeDeviceCountAt(ctx context.Context, path string) (
7171
return 0, errors.UnsupportedError("GetNVMeDeviceCountAt is not supported for darwin")
7272
}
7373

74-
func (s *NVMeSubsystem) GetNVMeDeviceAt(ctx context.Context, nsUUID string) (NVMeDeviceInterface, error) {
74+
func (s *NVMeSubsystem) GetNVMeDeviceAt(ctx context.Context, nsUUID string) (*NVMeDevice, error) {
7575
Logc(ctx).Debug(">>>> nvme_darwin.GetNVMeDeviceAt")
7676
defer Logc(ctx).Debug("<<<< nvme_darwin.GetNVMeDeviceAt")
7777
return nil, errors.UnsupportedError("GetNVMeDeviceAt is not supported for darwin")

utils/nvme/nvme_linux.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"encoding/json"
88
"fmt"
9+
"os"
910
"regexp"
1011
"strings"
1112
"time"
@@ -307,12 +308,15 @@ func (s *NVMeSubsystem) GetNVMeDeviceCountAt(ctx context.Context, path string) (
307308
return count, nil
308309
}
309310

310-
func (s *NVMeSubsystem) GetNVMeDeviceAt(ctx context.Context, nsUUID string) (NVMeDeviceInterface, error) {
311+
func (s *NVMeSubsystem) GetNVMeDeviceAt(ctx context.Context, nsUUID string) (*NVMeDevice, error) {
311312
Logc(ctx).Trace(">>>> nvme_linux.GetNVMeDeviceAt")
312313
defer Logc(ctx).Trace("<<<< nvme_linux.GetNVMeDeviceAt")
313314

314315
pathContents, err := afero.ReadDir(s.osFs, s.Name)
315316
if err != nil {
317+
if os.IsNotExist(err) {
318+
return nil, errors.NotFoundError("NVMe directory %s not found: %v", s.Name, err)
319+
}
316320
return nil, fmt.Errorf("failed to open %s directory, %v", s.Name, err)
317321
}
318322

utils/nvme/nvme_types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ type NVMeSubsystemInterface interface {
142142
ConnectSubsystemToHost(ctx context.Context, IP string) error
143143
DisconnectSubsystemFromHost(ctx context.Context) error
144144
GetNamespaceCountForSubsDevice(ctx context.Context) (int, error)
145-
GetNVMeDevice(ctx context.Context, nsUUID string) (NVMeDeviceInterface, error)
146-
GetNVMeDeviceAt(ctx context.Context, nsUUID string) (NVMeDeviceInterface, error)
145+
GetNVMeDevice(ctx context.Context, nsUUID string) (*NVMeDevice, error)
146+
GetNVMeDeviceAt(ctx context.Context, nsUUID string) (*NVMeDevice, error)
147147
GetNVMeDeviceCountAt(ctx context.Context, path string) (int, error)
148148
}
149149

utils/nvme/nvme_windows.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (s *NVMeSubsystem) GetNVMeDeviceCountAt(ctx context.Context, path string) (
7070
return 0, errors.UnsupportedError("GetNVMeDeviceCountAt is not supported for windows")
7171
}
7272

73-
func (s *NVMeSubsystem) GetNVMeDeviceAt(ctx context.Context, nsUUID string) (NVMeDeviceInterface, error) {
73+
func (s *NVMeSubsystem) GetNVMeDeviceAt(ctx context.Context, nsUUID string) (*NVMeDevice, error) {
7474
Logc(ctx).Debug(">>>> nvme_windows.GetNVMeDeviceAt")
7575
defer Logc(ctx).Debug("<<<< nvme_windows.GetNVMeDeviceAt")
7676
return nil, errors.UnsupportedError("GetNVMeDeviceAt is not supported for windows")

0 commit comments

Comments
 (0)