Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't try to get IP of VM when its not running #4521

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

anjannath
Copy link
Member

Description

for crc status command to get some VM information like disk-usage, pv count, etc. we need to SSH into the VM but this is only possible when the VM is running

in case the state of the VM is not Running it will now return early without trying to fetch those additional information which results in the following error:

Error getting ip: host is not running

Fixes: #4512

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Proposed changes

Return early from client.Status() when VM state is not Running

Testing

  1. crc status succeeds after crc stop on linux

Contribution Checklist

  • I have read the contributing guidelines
  • My code follows the style guidelines of this project
  • I Keep It Small and Simple: The smaller the PR is, the easier it is to review and have it merged
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I tested my code on specified platforms
    • Linux
    • Windows
    • MacOS

@openshift-ci openshift-ci bot requested review from cfergeau and gbraad December 18, 2024 10:48
Copy link

openshift-ci bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rohanKanojia
Once this PR has been reviewed and has the lgtm label, please ask for approval from anjannath. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -35,6 +35,10 @@ func (client *client) Status() (*types.ClusterStatusResult, error) {
return nil, errors.Wrap(err, "Cannot get machine state")
}

if vmStatus != state.Running {
return createClusterStatusResult(vmStatus, vm.bundle.GetBundleType(), vm.bundle.GetVersion(), "", 0, 0, 0, 0, 0, 0, nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is quite cryptic, so an inline comment might be helpful to clearly indicate what happens. description is not enough top determine what the cluster result is.

Copy link
Contributor

@albfan albfan Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

network-mode is not even an option on windows and mac, so probably we can merge #4514 and set linux as network-mode user too.

Then we can rework this to detect linux, and network-mode to system. That would clarify why quick early with a madeup cluster is needed as network-mode system needs vm running to work

Copy link
Member Author

@anjannath anjannath Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is quite cryptic, so an inline comment might be helpful to clearly indicate what happens. description is not enough top determine what the cluster result is.

added a inline comment in and also updated the commit description, as earlier it was wrong, the IP is actually needed to get the openshift cluster status

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about following, this way it doesn't look cryptic and for both network mode it follows same path to get the IP since ram/disksize ..etc doesn't return the error but zero values.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated the PR!

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
Copy link

openshift-ci bot commented Dec 23, 2024

@anjannath: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-crc 607fdc3 link true /test e2e-crc

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@praveenkumar praveenkumar merged commit 15030fe into crc-org:main Dec 24, 2024
29 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] crc status for a stopped instance on Linux returns Error getting ip: host is not running
5 participants