From c20adf2a803937f2c6c315dabfc262e3b2c646f9 Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Wed, 22 May 2024 09:03:38 +0000 Subject: [PATCH] cli - enable etcd-on-ramdisk option Change-Id: Iacab72ddd78c5a57ae75f6043a3b7a5d49d386a1 --- cli/cmd/dev/dev.go | 13 ++++++++----- cli/cmd/dev/microshift/microshift.go | 5 ++++- cli/cmd/dev/microshift/static/all.yaml.tmpl | 1 + cli/cmd/utils/utils.go | 1 + 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cli/cmd/dev/dev.go b/cli/cmd/dev/dev.go index 64da16f0..ecb03bde 100644 --- a/cli/cmd/dev/dev.go +++ b/cli/cmd/dev/dev.go @@ -44,6 +44,7 @@ var devRunTestsAllowedArgs = []string{"olm", "standalone", "upgrade"} var microshiftUser = "cloud-user" var defaultDiskSpace = "20G" +var defaultHost = "microshift.dev" var errMissingArg = errors.New("missing argument") @@ -73,8 +74,8 @@ func createMicroshift(kmd *cobra.Command, cliCtx cliutils.SoftwareFactoryConfigC msHost := cliCtx.Dev.Microshift.Host if msHost == "" { - ctrl.Log.Error(errMissingArg, "Host must be set in `microshift` section of the configuration") - os.Exit(1) + msHost = defaultHost + ctrl.Log.Info("Host not set, defaulting to " + defaultHost) } msUser := cliCtx.Dev.Microshift.User if msUser == "" { @@ -84,14 +85,15 @@ func createMicroshift(kmd *cobra.Command, cliCtx cliutils.SoftwareFactoryConfigC } msOpenshiftPullSecret := cliCtx.Dev.Microshift.OpenshiftPullSecret if msOpenshiftPullSecret == "" { - ctrl.Log.Error(errMissingArg, "A valid OpenShift pull secret must be set in `microshift` section of the configuration file") - os.Exit(1) + msOpenshiftPullSecret = "not-a-valid-pull-secret" + ctrl.Log.Info("A valid OpenShift pull secret must be set in `microshift` section of the configuration file") } msDiskFileSize := cliCtx.Dev.Microshift.DiskFileSize if msDiskFileSize == "" { msDiskFileSize = defaultDiskSpace ctrl.Log.Info("disk-file-size not set, defaulting to " + defaultDiskSpace) } + msEtcdOnRamdisk := cliCtx.Dev.Microshift.ETCDOnRAMDisk msAnsibleMicroshiftRolePath := cliCtx.Dev.AnsibleMicroshiftRolePath if msAnsibleMicroshiftRolePath == "" { msAnsibleMicroshiftRolePath = rootDir + "/ansible-microshift-role" @@ -104,7 +106,8 @@ func createMicroshift(kmd *cobra.Command, cliCtx cliutils.SoftwareFactoryConfigC } options := ms.MkAnsiblePlaybookOptions(msHost, msUser, msOpenshiftPullSecret, rootDir) - varsFile := ms.MkTemporaryVarsFile(cliCtx.FQDN, msDiskFileSize, msAnsibleMicroshiftRolePath, rootDir) + varsFile := ms.MkTemporaryVarsFile( + cliCtx.FQDN, msDiskFileSize, msAnsibleMicroshiftRolePath, rootDir, msEtcdOnRamdisk) options.ExtraVarsFile = []string{"@" + varsFile} // Ensure ansible-microshift-role is available ms.MkMicroshiftRoleSetupPlaybook(rootDir) diff --git a/cli/cmd/dev/microshift/microshift.go b/cli/cmd/dev/microshift/microshift.go index a8ab8523..4050cc5c 100644 --- a/cli/cmd/dev/microshift/microshift.go +++ b/cli/cmd/dev/microshift/microshift.go @@ -48,6 +48,7 @@ type GroupVarsData struct { FQDN string DiskFileSize string MicroshiftRolePath string + ETCDOnRAMDisk bool } type PlayBook struct { @@ -114,11 +115,13 @@ func MkAnsiblePlaybookOptions(host string, user string, pullSecret string, rootD } } -func MkTemporaryVarsFile(fqdn string, diskFileSize string, microshiftRolePath string, rootDir string) string { +func MkTemporaryVarsFile( + fqdn string, diskFileSize string, microshiftRolePath string, rootDir string, etcdOnRamdisk bool) string { varsData := GroupVarsData{ fqdn, diskFileSize, microshiftRolePath, + etcdOnRamdisk, } filePath := rootDir + "/all.yaml" template, err := cutils.ParseString(groupvars, varsData) diff --git a/cli/cmd/dev/microshift/static/all.yaml.tmpl b/cli/cmd/dev/microshift/static/all.yaml.tmpl index 889a97bb..54daff70 100644 --- a/cli/cmd/dev/microshift/static/all.yaml.tmpl +++ b/cli/cmd/dev/microshift/static/all.yaml.tmpl @@ -4,6 +4,7 @@ microshift_fqdn: microshift.dev sf_fqdn: {{ .FQDN }} disk_file_sparsed: true disk_file_size: {{ .DiskFileSize }} +etcd_on_ramdisk: {{ .ETCDOnRAMDisk }} setup_olm: true microshift_additional_addresses: - {{ "\"{{ microshift_fqdn }}\"" }} diff --git a/cli/cmd/utils/utils.go b/cli/cmd/utils/utils.go index a7b05420..f3f15626 100644 --- a/cli/cmd/utils/utils.go +++ b/cli/cmd/utils/utils.go @@ -71,6 +71,7 @@ type SoftwareFactoryConfigContext struct { User string `json:"user" mapstructure:"user"` OpenshiftPullSecret string `json:"openshift-pull-secret" mapstructure:"openshift-pull-secret"` DiskFileSize string `json:"disk-file-size" mapstructure:"disk-file-size"` + ETCDOnRAMDisk bool `json:"etcd-on-ramdisk" mapstructure:"etcd-on-ramdisk"` } `json:"microshift" mapstructure:"microshift"` Tests struct { DemoReposPath string `json:"demo-repos-path" mapstructure:"demo-repos-path"`