Skip to content

Commit dfc3c8c

Browse files
authored
add nvme fault points
Add NVMe fault points for fault injection testing
1 parent 008c083 commit dfc3c8c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

frontend/csi/node_server.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,6 +2866,10 @@ func (p *Plugin) nodeStageNVMeVolume(
28662866
}
28672867

28682868
if isLUKS {
2869+
if err := betweenAttachAndLUKSPassphrase.Inject(); err != nil {
2870+
return err
2871+
}
2872+
28692873
luksDevice := luks.NewDevice(publishInfo.DevicePath, req.VolumeContext["internalName"], p.command)
28702874

28712875
// Ensure we update the passphrase in case it has never been set before
@@ -2886,11 +2890,15 @@ func (p *Plugin) nodeStageNVMeVolume(
28862890
return err
28872891
}
28882892

2893+
if err := afterInitialTrackingInfoWrite.Inject(); err != nil {
2894+
return err
2895+
}
2896+
28892897
p.nvmeHandler.AddPublishedNVMeSession(&publishedNVMeSessions, publishInfo)
28902898
return nil
28912899
}
28922900

2893-
// nodeUnstageNVMEVolume unstages volume for nvme driver.
2901+
// nodeUnstageNVMeVolume unstages volume for nvme driver.
28942902
// - Get the device from tracking info OR from "nvme netapp ontapdevices".
28952903
// - Flush the device using "nvme flush /dev/<nvme-device>"
28962904
// - If the subsystem has <= 1 Namespaces connected to it, then disconnect.

utils/nvme/nvme.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/spf13/afero"
1414
"go.uber.org/multierr"
1515

16+
"github.com/netapp/trident/internal/fiji"
1617
. "github.com/netapp/trident/logging"
1718
"github.com/netapp/trident/pkg/convert"
1819
"github.com/netapp/trident/utils/devices"
@@ -25,6 +26,8 @@ import (
2526

2627
const NVMeAttachTimeout = 20 * time.Second
2728

29+
var beforeNVMeFlushDevice = fiji.Register("beforeNVMeFlushDevice", "nvme")
30+
2831
func NewNVMeSubsystem(nqn string, command exec.Command, fs afero.Fs) *NVMeSubsystem {
2932
return NewNVMeSubsystemDetailed(nqn, "", []Path{}, command, fs)
3033
}
@@ -177,6 +180,10 @@ func (d *NVMeDevice) GetPath() string {
177180

178181
// FlushDevice flushes any ongoing IOs on the device.
179182
func (d *NVMeDevice) FlushDevice(ctx context.Context, ignoreErrors, force bool) error {
183+
if err := beforeNVMeFlushDevice.Inject(); err != nil {
184+
return err
185+
}
186+
180187
// Force is set in forced detach use case. We don't flush in that scenario and return success.
181188
if force {
182189
return nil

utils/nvme/nvme_linux.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/spf13/afero"
1515

16+
"github.com/netapp/trident/internal/fiji"
1617
. "github.com/netapp/trident/logging"
1718
sa "github.com/netapp/trident/storage_attribute"
1819
"github.com/netapp/trident/utils/errors"
@@ -23,6 +24,8 @@ var (
2324
transport = "tcp"
2425
nvmeNQNRegex = regexp.MustCompile(`^nvme([0-9]+)n([0-9]+)$`)
2526
nvmeRegex = regexp.MustCompile(`^nvme([0-9]+)$`)
27+
28+
beforeNVMeDisconnect = fiji.Register("beforeNVMeDisconnect", "nvme_linux")
2629
)
2730

2831
const (
@@ -162,6 +165,10 @@ func (s *NVMeSubsystem) DisconnectSubsystemFromHost(ctx context.Context) error {
162165
Logc(ctx).Debug(">>>> nvme_linux.DisconnectSubsystemFromHost")
163166
defer Logc(ctx).Debug("<<<< nvme_linux.DisconnectSubsystemFromHost")
164167

168+
if err := beforeNVMeDisconnect.Inject(); err != nil {
169+
return err
170+
}
171+
165172
_, err := s.command.Execute(ctx, "nvme", "disconnect", "-n", s.NQN)
166173
if err != nil {
167174
Logc(ctx).WithError(err).Errorf("Failed to disconnect subsystem %s.", s.NQN)

0 commit comments

Comments
 (0)