Skip to content

Commit

Permalink
disk-resize: remove runGrowPart helper
Browse files Browse the repository at this point in the history
we did refactor 655822f and because of
this now disk resize steps executed even there is no free space in the
disk. Before this refactor we used to return early as soon as there is a
specfic exit code from `growpart` command in case no free space on disk.

With this PR we are reverting this functionality to make sure we return
early if there is no space on disk to grow.
  • Loading branch information
praveenkumar committed Jun 26, 2023
1 parent cc522a0 commit e0f6731
Showing 1 changed file with 11 additions and 17 deletions.
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

0 comments on commit e0f6731

Please sign in to comment.