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

disk-resize: Don't try to resize disk if there is no free space #3734

Merged
merged 1 commit into from
Jul 3, 2023
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
28 changes: 11 additions & 17 deletions pkg/crc/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,17 @@ func growRootFileSystem(sshRunner *crcssh.Runner, preset crcPreset.Preset) error
return err
}

if err := runGrowpart(sshRunner, rootPart); err != nil {
return err
// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Growing %s partition", rootPart), "/usr/bin/growpart", rootPart[:len("/dev/.da")], rootPart[len("/dev/.da"):]); err != nil {
var exitErr *ssh.ExitError
if !errors.As(err, &exitErr) {
return err
}
if exitErr.ExitStatus() != 1 {
return err
}
logging.Debugf("No free space after %s, nothing to do", rootPart)
return nil
}

if preset == crcPreset.Microshift {
Expand Down Expand Up @@ -160,21 +169,6 @@ func getrootPartition(sshRunner *crcssh.Runner, preset crcPreset.Preset) (string
return rootPart, nil
}

func runGrowpart(sshRunner *crcssh.Runner, rootPart string) error {
// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Growing %s partition", rootPart), "/usr/bin/growpart", rootPart[:len("/dev/.da")], rootPart[len("/dev/.da"):]); err != nil {
var exitErr *ssh.ExitError
if !errors.As(err, &exitErr) {
return err
}
if exitErr.ExitStatus() != 1 {
return err
}
logging.Debugf("No free space after %s, nothing to do", rootPart)
}
return nil
}

func growLVForMicroshift(sshRunner *crcssh.Runner, lvFullName string, rootPart string) error {
if _, _, err := sshRunner.RunPrivileged("Resizing the physical volume(PV)", "/usr/sbin/pvresize", "--devices", rootPart, rootPart); err != nil {
return err
Expand Down