Skip to content
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

fix: print debug logs when lima disk command fails #270

Merged
Merged
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions pkg/disk/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ func (m *userDataDiskManager) limaDiskExists() bool {

func (m *userDataDiskManager) createLimaDisk() error {
cmd := m.lcc.CreateWithoutStdio("disk", "create", diskName, "--size", diskSize)
return cmd.Run()
if logs, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to create disk, debug logs:\n%s", logs)
}
return nil
}

func (m *userDataDiskManager) attachPersistentDiskToLimaDisk() error {
Expand Down Expand Up @@ -165,5 +168,8 @@ func (m *userDataDiskManager) limaDiskIsLocked() bool {

func (m *userDataDiskManager) unlockLimaDisk() error {
cmd := m.lcc.CreateWithoutStdio("disk", "unlock", diskName)
return cmd.Run()
if logs, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to unlock disk, debug logs:\n%s", logs)
}
return nil
}
6 changes: 3 additions & 3 deletions pkg/disk/disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestUserDataDiskManager_InitializeUserDataDisk(t *testing.T) {
cmd.EXPECT().Output().Return([]byte(""), nil)

lcc.EXPECT().CreateWithoutStdio(mockCreateArgs).Return(cmd)
cmd.EXPECT().Run().Return(nil)
cmd.EXPECT().CombinedOutput().Return(nil, nil)

dfs.EXPECT().Stat(finch.UserDataDiskPath(homeDir)).Return(nil, fs.ErrNotExist)
dfs.EXPECT().Stat(path.Dir(finch.UserDataDiskPath(homeDir))).Return(nil, nil)
Expand Down Expand Up @@ -107,7 +107,7 @@ func TestUserDataDiskManager_InitializeUserDataDisk(t *testing.T) {
cmd.EXPECT().Output().Return([]byte(""), nil)

lcc.EXPECT().CreateWithoutStdio(mockCreateArgs).Return(cmd)
cmd.EXPECT().Run().Return(nil)
cmd.EXPECT().CombinedOutput().Return(nil, nil)

dfs.EXPECT().Stat(finch.UserDataDiskPath(homeDir)).Return(nil, nil)

Expand All @@ -130,7 +130,7 @@ func TestUserDataDiskManager_InitializeUserDataDisk(t *testing.T) {

dfs.EXPECT().Stat(lockPath).Return(nil, nil)
lcc.EXPECT().CreateWithoutStdio(mockUnlockArgs).Return(cmd)
cmd.EXPECT().Run().Return(nil)
cmd.EXPECT().CombinedOutput().Return(nil, nil)
},
},
}
Expand Down