Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Possible solutions open cases #884

Open
wants to merge 1 commit into
base: stable/v23.04
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions frontend/csi/node_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,28 @@ var (
publishedISCSISessions, currentISCSISessions utils.ISCSISessions
)

func attemptLock(ctx context.Context, lockContext string) bool {
startTime := time.Now()
utils.Lock(ctx, lockContext, lockID)

// Fail if the gRPC call came in a long time ago to avoid kubelet 120s timeout
if time.Since(startTime) > defaultNodeReconciliationPeriod {
return false
}

return true
}

func (p *Plugin) NodeStageVolume(
ctx context.Context, req *csi.NodeStageVolumeRequest,
) (*csi.NodeStageVolumeResponse, error) {
lockContext := "NodeStageVolume-" + req.GetVolumeId()
utils.Lock(ctx, lockContext, lockID)
defer utils.Unlock(ctx, lockContext, lockID)

if !attemptLock(ctx, lockContext) {
return nil, status.Error(codes.Aborted, "too long since request start time")
}

fields := LogFields{"Method": "NodeStageVolume", "Type": "CSI_Node"}
ctx = SetContextWorkflow(ctx, WorkflowNodeStage)
ctx = GenerateRequestContextForLayer(ctx, LogLayerCSIFrontend)
Expand Down Expand Up @@ -86,9 +101,12 @@ func (p *Plugin) nodeUnstageVolume(
ctx context.Context, req *csi.NodeUnstageVolumeRequest, force bool,
) (*csi.NodeUnstageVolumeResponse, error) {
lockContext := "NodeUnstageVolume-" + req.GetVolumeId()
utils.Lock(ctx, lockContext, lockID)
defer utils.Unlock(ctx, lockContext, lockID)

if !attemptLock(ctx, lockContext) {
return nil, status.Error(codes.Aborted, "too long since request start time")
}

fields := LogFields{
"Method": "NodeUnstageVolume",
"Type": "CSI_Node",
Expand Down Expand Up @@ -165,9 +183,12 @@ func (p *Plugin) NodePublishVolume(
ctx context.Context, req *csi.NodePublishVolumeRequest,
) (*csi.NodePublishVolumeResponse, error) {
lockContext := "NodePublishVolume-" + req.GetVolumeId()
utils.Lock(ctx, lockContext, lockID)
defer utils.Unlock(ctx, lockContext, lockID)

if !attemptLock(ctx, lockContext) {
return nil, status.Error(codes.Aborted, "too long since request start time")
}

ctx = SetContextWorkflow(ctx, WorkflowNodePublish)
ctx = GenerateRequestContextForLayer(ctx, LogLayerCSIFrontend)

Expand Down Expand Up @@ -203,9 +224,12 @@ func (p *Plugin) NodeUnpublishVolume(
ctx context.Context, req *csi.NodeUnpublishVolumeRequest,
) (*csi.NodeUnpublishVolumeResponse, error) {
lockContext := "NodeUnpublishVolume-" + req.GetVolumeId()
utils.Lock(ctx, lockContext, lockID)
defer utils.Unlock(ctx, lockContext, lockID)

if !attemptLock(ctx, lockContext) {
return nil, status.Error(codes.Aborted, "too long since request start time")
}

ctx = SetContextWorkflow(ctx, WorkflowNodeUnpublish)
fields := LogFields{"Method": "NodeUnpublishVolume", "Type": "CSI_Node"}
Logc(ctx).WithFields(fields).Debug(">>>> NodeUnpublishVolume")
Expand Down
3 changes: 1 addition & 2 deletions utils/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"time"

"github.com/cenkalti/backoff/v4"
log "github.com/sirupsen/logrus"
"golang.org/x/net/context"

. "github.com/netapp/trident/logging"
Expand Down Expand Up @@ -318,7 +317,7 @@ func GetDeviceNameFromMount(ctx context.Context, mountpath string) (string, int,

// In the case of a iscsi trace debug, log info about session and what devices are present
func listAllISCSIDevices(ctx context.Context) {
if !IsLevelEnabled(log.TraceLevel) {
if GetDefaultLogLevel() != "trace" {
// Don't even run the commands if trace logging is not enabled
return
}
Expand Down
11 changes: 9 additions & 2 deletions utils/mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ func IsMounted(ctx context.Context, sourceDevice, mountpoint, mountOptions strin
Logc(ctx).WithFields(logFields).Debug(">>>> mount_linux.IsMounted")
defer Logc(ctx).WithFields(logFields).Debug("<<<< mount_linux.IsMounted")

rawPath, err := filepath.EvalSymlinks(sourceDevice)
if err != nil {
Logc(ctx).Error(err)
rawPath = ""
}
rawPath = strings.TrimPrefix(rawPath, "/dev/")

sourceDevice = strings.TrimPrefix(sourceDevice, "/dev/")

// Ensure at least one arg was specified
Expand Down Expand Up @@ -90,7 +97,7 @@ func IsMounted(ctx context.Context, sourceDevice, mountpoint, mountOptions strin

if strings.HasPrefix(procMount.MountSource, "/dev/") {
procSourceDevice = strings.TrimPrefix(procMount.MountSource, "/dev/")
if sourceDevice != procSourceDevice {
if sourceDevice != procSourceDevice && rawPath != procSourceDevice {
// Resolve any symlinks to get the real device
procSourceDevice, err = filepath.EvalSymlinks(procMount.MountSource)
if err != nil {
Expand All @@ -101,7 +108,7 @@ func IsMounted(ctx context.Context, sourceDevice, mountpoint, mountOptions strin
}
}

if sourceDevice != procSourceDevice {
if sourceDevice != procSourceDevice && rawPath != procSourceDevice {
continue
} else {
Logc(ctx).Debugf("Device found: %v", sourceDevice)
Expand Down