Skip to content

Commit

Permalink
fix error when trying to get IP of VM when its not running
Browse files Browse the repository at this point in the history
for crc status command to get the status of the OpenShift
cluster we need the IP address of the VM but while  using
network-mode 'system' and a Stopped VM this fails with:
Error getting ip: host is not running

this checks if the VM is in Running state before trying to
get the VM IP

we do not the see the same error for 'user'  network-mode
as in that case the VM ip is always 127.0.0.1
  • Loading branch information
anjannath committed Dec 20, 2024
1 parent 130a608 commit a3dcec1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/crc/machine/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ func (client *client) Status() (*types.ClusterStatusResult, error) {
return nil, errors.Wrap(err, "Cannot get machine state")
}

// when the VM is not running, return the ClusterStatus with
// VM and OpenShift status as Stopped and zero values for VM
// disk, ram, pv usage and size
if vmStatus != state.Running {
return createClusterStatusResult(vmStatus, vm.bundle.GetBundleType(), vm.bundle.GetVersion(), "", 0, 0, 0, 0, 0, 0, nil)
}

ip, err := vm.IP()
if err != nil {
return nil, errors.Wrap(err, "Error getting ip")
Expand Down

0 comments on commit a3dcec1

Please sign in to comment.