-
Notifications
You must be signed in to change notification settings - Fork 297
guest/storage/scsi: Print log warning if GetDevicePath blocks due to wait #2471
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -347,6 +347,9 @@ func GetDevicePath(ctx context.Context, controller, lun uint8, partition uint64) | |
| // Devices matching the given SCSI code should each have a subdirectory | ||
| // under /sys/bus/scsi/devices/<scsiID>/block. | ||
| blockPath := filepath.Join(scsiDevicesPath, scsiID, "block") | ||
| waitStartTime := time.Now() | ||
| logTime := waitStartTime.Add(time.Second * 5) | ||
| logged := false | ||
| var deviceNames []os.DirEntry | ||
| for { | ||
| deviceNames, err = osReadDir(blockPath) | ||
|
|
@@ -358,6 +361,12 @@ func GetDevicePath(ctx context.Context, controller, lun uint8, partition uint64) | |
| case <-ctx.Done(): | ||
| return "", ctx.Err() | ||
| default: | ||
| if !logged && logTime.Before(time.Now()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a thought, why not <-time.After(time.Second * 5) as a case and then just continue. Yes you would get multiple log statements but it feels like thats ok. What if it takes 15 seconds? You would see multiple logs at 5 second intervals. But thats also helpful to see how long it is taking.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that wouldn't work because we will restart the loop on |
||
| log.G(ctx).WithField("blockPath", blockPath).Warn( | ||
| "scsi::GetDevicePath blocked for more than 5 seconds waiting for SCSI device to show up in sysfs", | ||
| ) | ||
| logged = true | ||
| } | ||
| time.Sleep(time.Millisecond * 10) | ||
| continue | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.