Skip to content
Merged
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
9 changes: 9 additions & 0 deletions internal/guest/storage/scsi/scsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment thread
ambarve marked this conversation as resolved.
logTime := waitStartTime.Add(time.Second * 5)
logged := false
var deviceNames []os.DirEntry
for {
deviceNames, err = osReadDir(blockPath)
Expand All @@ -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()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that wouldn't work because we will restart the loop on default in 10ms, then the timer will restart, right?

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
}
Expand Down