Skip to content

Commit

Permalink
cli - enable etcd-on-ramdisk option
Browse files Browse the repository at this point in the history
Change-Id: Iacab72ddd78c5a57ae75f6043a3b7a5d49d386a1
  • Loading branch information
morucci committed May 22, 2024
1 parent 7d8150b commit c20adf2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
13 changes: 8 additions & 5 deletions cli/cmd/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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 == "" {
Expand All @@ -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"
Expand All @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion cli/cmd/dev/microshift/microshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type GroupVarsData struct {
FQDN string
DiskFileSize string
MicroshiftRolePath string
ETCDOnRAMDisk bool
}

type PlayBook struct {
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/dev/microshift/static/all.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}\"" }}
Expand Down
1 change: 1 addition & 0 deletions cli/cmd/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit c20adf2

Please sign in to comment.