Skip to content

Commit

Permalink
try to get IP of VM only when its state is 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 23, 2024
1 parent 130a608 commit 607fdc3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Binary file added capture.pcap
Binary file not shown.
10 changes: 7 additions & 3 deletions pkg/crc/machine/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@ func (client *client) Status() (*types.ClusterStatusResult, error) {
return nil, errors.Wrap(err, "Cannot get machine state")
}

ip, err := vm.IP()
if err != nil {
return nil, errors.Wrap(err, "Error getting ip")
ip := ""
if vmStatus == state.Running {
ip, err = vm.IP()
if err != nil {
return nil, errors.Wrap(err, "Error getting ip")
}
}

ramSize, ramUse := client.getRAMStatus(vm)
diskSize, diskUse := client.getDiskDetails(vm)
pvSize, pvUse := client.getPVCSize(vm)
Expand Down

0 comments on commit 607fdc3

Please sign in to comment.