Skip to content

Commit 4fe6b1b

Browse files
authored
Merge pull request #662 from bahaa-ghazal/MEN-4977
chore: Warn about missing `blkid` before establishing SSH connection
2 parents 450878a + 1f52ad8 commit 4fe6b1b

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

cli/debugfs_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ func TestExternalBinaryDependency(t *testing.T) {
6262
assert.Contains(t, err.Error(), "`parted` binary not found on the system")
6363

6464
_, err = imgFilesystemType("foobar")
65-
assert.EqualError(t, err, "`blkid` binary not found on the system")
65+
assert.ErrorIs(t, err, errBlkidNotFound)
6666
}

cli/write.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ func validateInput(c *cli.Context) error {
103103
}
104104

105105
func createRootfsFromSSH(c *cli.Context) (string, error) {
106+
_, err := utils.GetBinaryPath("blkid")
107+
if err != nil {
108+
Log.Warnf("Skipping running fsck on the Artifact: %v", errBlkidNotFound)
109+
}
106110
rootfsFilename, err := getDeviceSnapshot(c)
107111
if err != nil {
108112
return rootfsFilename, cli.NewExitError("SSH error: "+err.Error(), 1)
@@ -112,7 +116,6 @@ func createRootfsFromSSH(c *cli.Context) (string, error) {
112116
fstype, err := imgFilesystemType(rootfsFilename)
113117
if err != nil {
114118
if err == errBlkidNotFound {
115-
Log.Warnf("Skipping running fsck on the Artifact: %v", err)
116119
return rootfsFilename, nil
117120
}
118121
return rootfsFilename, cli.NewExitError(
@@ -343,7 +346,6 @@ func writeRootfs(c *cli.Context) error {
343346
)
344347
}
345348
}
346-
347349
if !c.Bool("no-progress") {
348350
ctx, cancel := context.WithCancel(context.Background())
349351
go reportProgress(ctx, aw.State)
@@ -1005,6 +1007,7 @@ func recvSnapshot(dst io.Writer, src io.Reader) (int64, error) {
10051007
for {
10061008
nr, err := src.Read(buf)
10071009
if err == io.EOF {
1010+
fmt.Println()
10081011
break
10091012
} else if err != nil {
10101013
return written, errors.Wrap(err,

0 commit comments

Comments
 (0)