Skip to content

Commit

Permalink
Podman preset deprecation: Remove all usages of the Podman preset fro…
Browse files Browse the repository at this point in the history
…m the code

- remove podman preset specific code
- reject podman as a valid preset value for new machines
  • Loading branch information
vyasgun authored and cfergeau committed Apr 22, 2024
1 parent 2b6d22c commit 095fb5f
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 214 deletions.
4 changes: 0 additions & 4 deletions cmd/crc/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ func runStart(ctx context.Context) (*types.StartResult, error) {
EnableBundleQuayFallback: config.Get(crcConfig.EnableBundleQuayFallback).AsBool(),
}

if startConfig.Preset == preset.Podman {
logging.Warn(preset.PodmanDeprecatedWarning)
}

client := newMachine()
isRunning, _ := client.IsRunning()

Expand Down
3 changes: 0 additions & 3 deletions cmd/crc/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ func (s *status) prettyPrintTo(writer io.Writer) error {
if s.Preset == preset.OpenShift {
lines = append(lines, line{"OpenShift", openshiftStatus(s)})
}
if s.Preset == preset.Podman {
lines = append(lines, line{"Podman", s.PodmanVersion})
}
if s.Preset == preset.Microshift {
lines = append(lines, line{"MicroShift", openshiftStatus(s)})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/cluster/pullsecret.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewNonInteractivePullSecretLoader(config crcConfig.Storage, path string) Pu

func (loader *nonInteractivePullSecretLoader) Value() (string, error) {
// If crc is built from an OKD bundle or podman bundle is used, then use the fake pull secret in constants.
if crcConfig.GetPreset(loader.config) == preset.OKD || crcConfig.GetPreset(loader.config) == preset.Podman {
if crcConfig.GetPreset(loader.config) == preset.OKD {
return constants.OkdPullSecret, nil
}

Expand Down
8 changes: 1 addition & 7 deletions pkg/crc/config/callbacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"path/filepath"

"github.com/crc-org/crc/v2/pkg/crc/constants"
"github.com/crc-org/crc/v2/pkg/crc/logging"
"github.com/crc-org/crc/v2/pkg/crc/preset"
"github.com/crc-org/crc/v2/pkg/os"
"github.com/spf13/cast"
)
Expand All @@ -23,11 +21,7 @@ func RequiresDeleteMsg(key string, _ interface{}) string {
"delete the CRC instance with 'crc delete' and start it with 'crc start'.", key)
}

func RequiresDeleteAndSetupMsg(key string, value interface{}) string {

if key == Preset && value == string(preset.Podman) {
logging.Warn(preset.PodmanDeprecatedWarning)
}
func RequiresDeleteAndSetupMsg(key string, _ interface{}) string {
// since we cannot easily import the machine package here to check for existence of the CRC vm
// we rely on the existence of the machine config file to determine if a VM exists
if os.FileExists(filepath.Join(constants.MachineInstanceDir, "crc", "config.json")) {
Expand Down
8 changes: 4 additions & 4 deletions pkg/crc/config/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func newInMemoryConfig() (*Config, error) {
}

// Check that with the default preset, we cannot set less CPUs than the defaultCPUs
// but that it is allowed with a different preset with less requirements (podman)
// but that it is allowed with a different preset with less requirements (microshift)
func TestCPUsValidate(t *testing.T) {
cfg, err := newInMemoryConfig()
require.NoError(t, err)
Expand All @@ -58,7 +58,7 @@ func TestCPUsValidate(t *testing.T) {
IsSecret: false,
}, cfg.Get(CPUs))

_, err = cfg.Set(Preset, crcpreset.Podman)
_, err = cfg.Set(Preset, crcpreset.Microshift)
require.NoError(t, err)
_, err = cfg.Set(CPUs, defaultCPUs-1)
require.NoError(t, err)
Expand All @@ -76,7 +76,7 @@ func TestSetPreset(t *testing.T) {
cfg, err := newInMemoryConfig()
require.NoError(t, err)

_, err = cfg.Set(Preset, crcpreset.Podman)
_, err = cfg.Set(Preset, crcpreset.Microshift)
require.NoError(t, err)
_, err = cfg.Set(Memory, 10800)
require.NoError(t, err)
Expand Down Expand Up @@ -118,7 +118,7 @@ func TestUnsetPreset(t *testing.T) {
cfg, err := newInMemoryConfig()
require.NoError(t, err)

_, err = cfg.Set(Preset, crcpreset.Podman)
_, err = cfg.Set(Preset, crcpreset.Microshift)
require.NoError(t, err)
_, err = cfg.Set(Memory, 10800)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func GetDefaultCPUs(preset crcpreset.Preset) int {
switch preset {
case crcpreset.OpenShift, crcpreset.OKD:
return 4
case crcpreset.Podman, crcpreset.Microshift:
case crcpreset.Microshift:
return 2
default:
// should not be reached
Expand Down
2 changes: 0 additions & 2 deletions pkg/crc/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ func getPresetNameE(imageName string) (crcpreset.Preset, error) {
return crcpreset.OpenShift, nil
case "okd-bundle":
return crcpreset.OKD, nil
case "podman-bundle":
return crcpreset.Podman, nil
case "microshift-bundle":
return crcpreset.Microshift, nil
default:
Expand Down
11 changes: 4 additions & 7 deletions pkg/crc/machine/bundle/copier.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,10 @@ func (copier *Copier) CopyPrivateSSHKey(srcPath string) error {
}

func (copier *Copier) CopyKubeConfig() error {
if !copier.srcBundle.IsPodman() {
kubeConfigFileName := filepath.Base(copier.srcBundle.GetKubeConfigPath())
srcPath := copier.srcBundle.GetKubeConfigPath()
destPath := copier.resolvePath(kubeConfigFileName)
return crcos.CopyFileContents(srcPath, destPath, 0640)
}
return nil
kubeConfigFileName := filepath.Base(copier.srcBundle.GetKubeConfigPath())
srcPath := copier.srcBundle.GetKubeConfigPath()
destPath := copier.resolvePath(kubeConfigFileName)
return crcos.CopyFileContents(srcPath, destPath, 0640)
}

func (copier *Copier) CopyFilesFromFileList() error {
Expand Down
25 changes: 4 additions & 21 deletions pkg/crc/machine/bundle/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,14 @@ func (bundle *CrcBundleInfo) GetBundleBuildTime() (time.Time, error) {
return time.Parse(time.RFC3339, strings.TrimSpace(bundle.BuildInfo.BuildTime))
}

func (bundle *CrcBundleInfo) GetOpenshiftVersion() string {
func (bundle *CrcBundleInfo) GetVersion() string {
return bundle.ClusterInfo.OpenShiftVersion.String()
}

func (bundle *CrcBundleInfo) GetPodmanVersion() string {
return bundle.Nodes[0].PodmanVersion
}

func (bundle *CrcBundleInfo) GetVersion() string {
switch bundle.GetBundleType() {
case crcPreset.Podman:
return bundle.GetPodmanVersion()
default:
return bundle.GetOpenshiftVersion()
}
}

func (bundle *CrcBundleInfo) GetBundleNameWithoutExtension() string {
return GetBundleNameWithoutExtension(bundle.GetBundleName())
}
Expand All @@ -205,22 +196,14 @@ 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(),
bundle.GetDiskImagePath(),
bundle.GetKernelPath(),
bundle.GetInitramfsPath(),
}
if !bundle.IsPodman() {
files = append(files, []string{
bundle.GetOcPath(),
bundle.GetKubeConfigPath()}...)
}
bundle.GetOcPath(),
bundle.GetKubeConfigPath()}

for _, file := range files {
if file == "" {
Expand Down Expand Up @@ -352,7 +335,7 @@ func Download(preset crcPreset.Preset, bundleURI string, enableBundleQuayFallbac
return image.PullBundle(constants.GetDefaultBundleImageRegistry(preset))
}
return downloadedBundlePath, err
case crcPreset.Podman, crcPreset.OKD:
case crcPreset.OKD:
fallthrough
default:
return image.PullBundle(constants.GetDefaultBundleImageRegistry(preset))
Expand Down
19 changes: 9 additions & 10 deletions pkg/crc/machine/bundle/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ func (repo *Repository) Get(bundleName string) (*CrcBundleInfo, error) {
return nil, err
}

if !bundleInfo.IsPodman() {
// TODO: update this logic after major release of bundle like 4.14
// As of now we are using this logic to support older bundles of microshift and it need to be updated
// to only provide app domain route information as per preset.
if !crcstrings.Contains([]string{constants.AppsDomain, constants.MicroShiftAppDomain}, fmt.Sprintf(".%s", bundleInfo.ClusterInfo.AppsDomain)) {
return nil, fmt.Errorf("unexpected bundle, it must have %s or %s apps domain", constants.AppsDomain, constants.MicroShiftAppDomain)
}
if bundleInfo.GetAPIHostname() != fmt.Sprintf("api%s", constants.ClusterDomain) {
return nil, fmt.Errorf("unexpected bundle, it must have %s base domain", constants.ClusterDomain)
}
// TODO: update this logic after major release of bundle like 4.14
// As of now we are using this logic to support older bundles of microshift and it need to be updated
// to only provide app domain route information as per preset.
if !crcstrings.Contains([]string{constants.AppsDomain, constants.MicroShiftAppDomain}, fmt.Sprintf(".%s", bundleInfo.ClusterInfo.AppsDomain)) {
return nil, fmt.Errorf("unexpected bundle, it must have %s or %s apps domain", constants.AppsDomain, constants.MicroShiftAppDomain)
}
if bundleInfo.GetAPIHostname() != fmt.Sprintf("api%s", constants.ClusterDomain) {
return nil, fmt.Errorf("unexpected bundle, it must have %s base domain", constants.ClusterDomain)
}

return &bundleInfo, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/machine/bundle/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestExtract(t *testing.T) {

bundle, err := repo.Get(testBundle(t))
assert.NoError(t, err)
assert.Equal(t, "4.6.1", bundle.GetOpenshiftVersion())
assert.Equal(t, "4.6.1", bundle.GetVersion())

_ = os.Remove(bundle.GetKubeConfigPath())
bundle, err = repo.Get(testBundle(t))
Expand Down
6 changes: 0 additions & 6 deletions pkg/crc/machine/console.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package machine

import (
"fmt"

"github.com/crc-org/crc/v2/pkg/crc/machine/types"
"github.com/pkg/errors"
)
Expand All @@ -18,10 +16,6 @@ func (client *client) GetConsoleURL() (*types.ConsoleResult, error) {
}
defer vm.Close()

if vm.bundle.IsPodman() {
return nil, fmt.Errorf("Only supported with OpenShift bundles")
}

vmState, err := vm.State()
if err != nil {
return nil, errors.Wrap(err, "Error getting the state for virtual machine")
Expand Down

0 comments on commit 095fb5f

Please sign in to comment.