Skip to content

Commit 8d4a20c

Browse files
authored
Minor fixes to SCSI mount operation (#1798)
During a recent refactor SCSI mount operation code removed a retry logic that is needed when examining the filesystem type on a SCSI device. Retry is needed because sometimes attempting to open a SCSI devices immediately after attaching it results in ENXIO/ENOENT errors. This adds the retry logic back. Names of some images used in the tests had changed, this commit updates those names too. Signed-off-by: Amit Barve <[email protected]>
1 parent 8a094ae commit 8d4a20c

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

ext4/tar2ext4/tar2ext4.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/Microsoft/hcsshim/ext4/dmverity"
1414
"github.com/Microsoft/hcsshim/ext4/internal/compactext4"
1515
"github.com/Microsoft/hcsshim/ext4/internal/format"
16+
"github.com/Microsoft/hcsshim/internal/log"
1617
"github.com/pkg/errors"
1718
)
1819

@@ -259,6 +260,9 @@ func IsDeviceExt4(devicePath string) bool {
259260
// ReadExt4SuperBlock will check the superblock magic number for us,
260261
// so we know if no error is returned, this is an ext4 device.
261262
_, err := ReadExt4SuperBlock(devicePath)
263+
if err != nil {
264+
log.L.Warnf("failed to read Ext4 superblock: %s", err)
265+
}
262266
return err == nil
263267
}
264268

internal/guest/storage/scsi/scsi.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,15 @@ func Mount(
223223
// as the mountType unless `Filesystem` was given.
224224
deviceFS, err = _getDeviceFsType(source)
225225
if err != nil {
226-
if config.Filesystem == "" || !errors.Is(err, ErrUnknownFilesystem) {
227-
return fmt.Errorf("getting device's filesystem: %w", err)
226+
// TODO (ambarve): add better retry logic, SCSI mounts sometimes return ENONENT or
227+
// ENXIO error if we try to open those devices immediately after mount. retry after a
228+
// few milliseconds.
229+
log.G(ctx).WithError(err).Trace("get device filesystem failed, retrying in 500ms")
230+
time.Sleep(500 * time.Millisecond)
231+
if deviceFS, err = _getDeviceFsType(source); err != nil {
232+
if config.Filesystem == "" || !errors.Is(err, ErrUnknownFilesystem) {
233+
return fmt.Errorf("getting device's filesystem: %w", err)
234+
}
228235
}
229236
}
230237
log.G(ctx).WithField("filesystem", deviceFS).Debug("filesystem found on device")

test/cri-containerd/container_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,9 +916,9 @@ func Test_Container_NFSMount_LCOW(t *testing.T) {
916916
defer stopContainer(t, client, ctx, containerID)
917917

918918
execHelper := func(ctrID string, cmd []string) {
919+
t.Helper()
919920
stdout, stderr, errcode := execContainer(t, client, ctx, ctrID, cmd)
920921
if errcode != 0 {
921-
t.Helper()
922922
t.Logf("stdout: %s \n\n stderr: %s\n\n", stdout, stderr)
923923
t.Fatalf("failed to run '%v'\n: errcode: %d", cmd, errcode)
924924
}

test/cri-containerd/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const (
6262
alpineAspnetUpgrade = "mcr.microsoft.com/dotnet/core/aspnet:3.1.2-alpine3.11"
6363

6464
imageWindowsProcessDump = "cplatpublic.azurecr.io/crashdump:latest"
65-
imageWindowsArgsEscaped = "cplatpublic.azurecr.io/argsescaped:latest"
65+
imageWindowsArgsEscaped = "cplatpublic.azurecr.io/args-escaped-test-image-ns:latest"
6666
imageWindowsTimezone = "cplatpublic.azurecr.io/timezone:latest"
6767

6868
imageJobContainerHNS = "cplatpublic.azurecr.io/jobcontainer_hns:latest"

0 commit comments

Comments
 (0)