Skip to content

Commit

Permalink
Issue #498: machine: Print openshift version when starting VM
Browse files Browse the repository at this point in the history
It can clear up some confusion to be aware of what OpenShift version
our current crc VM is using.
This requires a bundle with clusterInfo.openshiftVersion set in its
metadata. This should be the case for bundle releases newer than 4.1.11

This fixes #498
  • Loading branch information
cfergeau authored and praveenkumar committed Sep 19, 2019
1 parent 14d3867 commit fbda097
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/crc/machine/bundle/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CrcBundleInfo struct {
SncVersion string `json:"sncVersion"`
} `json:"buildInfo"`
ClusterInfo struct {
OpenShiftVersion string `json:"openshiftVersion"`
ClusterName string `json:"clusterName"`
BaseDomain string `json:"baseDomain"`
AppsDomain string `json:"appsDomain"`
Expand Down Expand Up @@ -130,3 +131,7 @@ func (bundle *CrcBundleInfo) GetKubeadminPassword() (string, error) {
func (bundle *CrcBundleInfo) GetBundleBuildTime() (time.Time, error) {
return time.Parse(time.RFC3339, strings.TrimSpace(bundle.BuildInfo.BuildTime))
}

func (bundle *CrcBundleInfo) GetOpenshiftVersion() string {
return bundle.ClusterInfo.OpenShiftVersion
}
21 changes: 19 additions & 2 deletions pkg/crc/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,13 @@ func Start(startConfig StartConfig) (StartResult, error) {
logging.Warnf("Bundle certificates are going to expire in %d days, better to use new release", duration)
}

logging.Infof("Creating VM ...")
openshiftVersion := crcBundleMetadata.GetOpenshiftVersion()
if openshiftVersion == "" {
logging.Infof("Creating VM...")
} else {
logging.Infof("Creating CodeReady Containers VM for OpenShift %s...", openshiftVersion)
}

// Retrieve metadata info
diskPath := crcBundleMetadata.GetDiskImagePath()
machineConfig.DiskPathURL = fmt.Sprintf("file://%s", filepath.ToSlash(diskPath))
Expand Down Expand Up @@ -181,12 +187,23 @@ func Start(startConfig StartConfig) (StartResult, error) {
return *result, errors.Newf("Error getting the state for host: %v", err)
}
if vmState == state.Running {
openshiftVersion := crcBundleMetadata.GetOpenshiftVersion()
if openshiftVersion == "" {
logging.Infof("A CodeReady Containers VM is already running")
} else {
logging.Infof("A CodeReady Containers VM for OpenShift %s is already running", openshiftVersion)
}
result.Status = vmState.String()
return *result, nil
}

if vmState != state.Running {
logging.Infof("Starting stopped VM ...")
openshiftVersion := crcBundleMetadata.GetOpenshiftVersion()
if openshiftVersion == "" {
logging.Infof("Starting CodeReady Containers VM ...")
} else {
logging.Infof("Starting CodeReady Containers VM for OpenShift %s...", openshiftVersion)
}
if err := host.Driver.Start(); err != nil {
result.Error = err.Error()
return *result, errors.Newf("Error starting stopped VM: %v", err)
Expand Down

0 comments on commit fbda097

Please sign in to comment.