Skip to content

Commit

Permalink
Starting an existing machines with podman preset will return an error
Browse files Browse the repository at this point in the history
- return deprecation error when the user tries to start an existing machine with podman preset
  • Loading branch information
vyasgun authored and cfergeau committed Apr 22, 2024
1 parent 095fb5f commit 8f83eae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/crc/machine/bundle/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ func (bundle *CrcBundleInfo) IsMicroshift() bool {
return bundle.GetBundleType() == crcPreset.Microshift
}

func (bundle *CrcBundleInfo) IsPodman() bool {
return bundle.GetBundleType() == crcPreset.Podman
}

func (bundle *CrcBundleInfo) verify() error {
files := []string{
bundle.GetSSHKeyPath(),
Expand Down
7 changes: 7 additions & 0 deletions pkg/crc/machine/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
}
defer vm.Close()

// Return with an error redirecting user to use podman machine instead
if vm.bundle.IsPodman() {
return &types.StartResult{}, fmt.Errorf("error: %s", crcPreset.PodmanDeprecatedWarning)
}
currentBundleName := vm.bundle.GetBundleName()
if currentBundleName != bundleName {
logging.Debugf("Bundle '%s' was requested, but the existing VM is using '%s'",
Expand Down Expand Up @@ -679,6 +683,9 @@ func (client *client) IsRunning() (bool, error) {
}

func (client *client) validateStartConfig(startConfig types.StartConfig) error {
if startConfig.Preset == crcPreset.Podman {
return fmt.Errorf(crcPreset.PodmanDeprecatedWarning)
}
if client.monitoringEnabled() && startConfig.Memory < minimumMemoryForMonitoring {
return fmt.Errorf("Too little memory (%s) allocated to the virtual machine to start the monitoring stack, %s is the minimum",
units.BytesSize(float64(startConfig.Memory)*1024*1024),
Expand Down
10 changes: 9 additions & 1 deletion pkg/crc/preset/preset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ var presetMap = map[Preset]string{
Microshift: string(Microshift),
}

const (
PodmanDeprecatedWarning = "The Podman preset is deprecated and will be removed in a future release. Consider" +
" rather using a Podman Machine managed by Podman Desktop: https://podman-desktop.io"
)

func AllPresets() []Preset {
var keys []Preset
for k := range presetMap {
Expand Down Expand Up @@ -52,6 +57,9 @@ func (preset Preset) ForDisplay() string {
}

func ParsePresetE(input string) (Preset, error) {
if string(Podman) == input {
return Podman, fmt.Errorf(PodmanDeprecatedWarning)
}
for pSet, pString := range presetMap {
if pString == input {
return pSet, nil
Expand All @@ -62,7 +70,7 @@ func ParsePresetE(input string) (Preset, error) {
}
func ParsePreset(input string) Preset {
preset, err := ParsePresetE(input)
if err != nil {
if err != nil && preset != Podman {
logging.Errorf("unexpected preset mode %s, using default", input)
return OpenShift
}
Expand Down

0 comments on commit 8f83eae

Please sign in to comment.