From 875d2d432d553b76409103cebc8e62d8155ab8a7 Mon Sep 17 00:00:00 2001 From: Tingmao Wang Date: Wed, 9 Jul 2025 18:11:55 +0100 Subject: [PATCH] guest/storage/scsi: Print log warning if GetDevicePath blocks due to wait When there is a problem with SCSI devices, this makes it easy to see why the GCS is not responding to the message. Signed-off-by: Tingmao Wang --- internal/guest/storage/scsi/scsi.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/guest/storage/scsi/scsi.go b/internal/guest/storage/scsi/scsi.go index d063bd971a..ec62636590 100644 --- a/internal/guest/storage/scsi/scsi.go +++ b/internal/guest/storage/scsi/scsi.go @@ -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//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()) { + 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 }