Skip to content

Commit b065a1e

Browse files
committed
remove code resizing partition for the ocp preset
the required `growpart` and `xfs_growfs` commands are run as a systemd service which is part of the self-sufficient bundle for microshift preset this is handled by crc like before
1 parent 9d17fbb commit b065a1e

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

pkg/crc/machine/start.go

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import (
3636
libmachinestate "github.com/crc-org/machine/libmachine/state"
3737
"github.com/docker/go-units"
3838
"github.com/pkg/errors"
39-
"golang.org/x/crypto/ssh"
4039
)
4140

4241
const minimumMemoryForMonitoring = 14336
@@ -115,35 +114,20 @@ func growRootFileSystem(sshRunner *crcssh.Runner, preset crcPreset.Preset, persi
115114
return err
116115
}
117116

118-
// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
119-
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Growing %s partition", rootPart), "/usr/bin/growpart", rootPart[:len("/dev/.da")], rootPart[len("/dev/.da"):]); err != nil {
120-
var exitErr *ssh.ExitError
121-
if !errors.As(err, &exitErr) {
117+
if preset == crcPreset.Microshift {
118+
lvFullName := "rhel/root"
119+
if err := growLVForMicroshift(sshRunner, lvFullName, rootPart, persistentVolumeSize); err != nil {
122120
return err
123121
}
124-
if exitErr.ExitStatus() != 1 {
122+
logging.Infof("Resizing %s filesystem", rootPart)
123+
rootFS := "/sysroot"
124+
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Remounting %s read/write", rootFS), "mount -o remount,rw", rootFS); err != nil {
125125
return err
126126
}
127-
logging.Debugf("No free space after %s, nothing to do", rootPart)
128-
return nil
129-
}
130-
131-
if preset == crcPreset.Microshift {
132-
lvFullName := "rhel/root"
133-
if err := growLVForMicroshift(sshRunner, lvFullName, rootPart, persistentVolumeSize); err != nil {
127+
if _, _, err = sshRunner.RunPrivileged(fmt.Sprintf("Growing %s filesystem", rootFS), "xfs_growfs", rootFS); err != nil {
134128
return err
135129
}
136130
}
137-
138-
logging.Infof("Resizing %s filesystem", rootPart)
139-
rootFS := "/sysroot"
140-
if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Remounting %s read/write", rootFS), "mount -o remount,rw", rootFS); err != nil {
141-
return err
142-
}
143-
if _, _, err = sshRunner.RunPrivileged(fmt.Sprintf("Growing %s filesystem", rootFS), "xfs_growfs", rootFS); err != nil {
144-
return err
145-
}
146-
147131
return nil
148132
}
149133

@@ -427,11 +411,6 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
427411
return nil, errors.Wrap(err, "Error updating public key")
428412
}
429413

430-
// Trigger disk resize, this will be a no-op if no disk size change is needed
431-
if err := growRootFileSystem(sshRunner, startConfig.Preset, startConfig.PersistentVolumeSize); err != nil {
432-
return nil, errors.Wrap(err, "Error updating filesystem size")
433-
}
434-
435414
// Start network time synchronization if `CRC_DEBUG_ENABLE_STOP_NTP` is not set
436415
if stopNtp, _ := strconv.ParseBool(os.Getenv("CRC_DEBUG_ENABLE_STOP_NTP")); stopNtp {
437416
logging.Info("Stopping network time synchronization in CRC VM")

0 commit comments

Comments
 (0)