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

limactl ls $INSTANCE should exit with non-0 status if $INSTANCE does not exist #1139 #2295

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

BajuMcBites
Copy link
Contributor

  • switched the warning message into an error message

Signed-off-by: Sahaj Bhakta <85909754+BajuMcBites@users.noreply.github.com>
@BajuMcBites BajuMcBites marked this pull request as ready for review April 25, 2024 02:25
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda added this to the v0.21.1 milestone Apr 25, 2024
@AkihiroSuda AkihiroSuda merged commit 3bdea6a into lima-vm:master Apr 25, 2024
25 checks passed
@jandubois
Copy link
Member

jandubois commented Apr 26, 2024

I realize this PR has already been merged, but I disagree with the implementation, as it introduces a regression:

I have a single alpine instance. Before this PR I get the following output:

$ limactl ls foo alpine bar
WARN[0000] No instance matching foo found.
WARN[0000] No instance matching bar found.
NAME      STATUS     SSH            VMTYPE    ARCH      CPUS    MEMORY    DISK      DIR
alpine    Stopped    127.0.0.1:0    qemu      x86_64    4       4GiB      100GiB    ~/.lima/alpine

With this PR the command stops at the first instance that is not found:

$ limactl ls foo alpine bar
FATA[0000] no instance matching foo found

So I think we need to record the fact that at least one requested instance was not found, but only exit with os.Exit(1) after the information about the existing instances (and warnings about additional missing instances) have been printed.

I would like to see this fixed in a follow-up PR.

@jandubois jandubois mentioned this pull request Apr 26, 2024
@BajuMcBites
Copy link
Contributor Author

Sorry about this, I did not think to account for multiple instances. I can work on another PR to fix this issue. Should it still log the "No instance matching found." as warnings and then exit with 1, or is there a different message type that is preferred?

@jandubois
Copy link
Member

I can work on another PR to fix this issue. Should it still log the "No instance matching found." as warnings and then exit with 1

Yes, I think the output should remain unchanged, just the exit code should be non-0 when at least one instance could not be found.

The easiest way to exit with a non-0 code would be to call os.Exit(1).

Note that there are multiple output formats for this command, with some early return statements. Make sure that all of them are being covered!

jandubois added a commit that referenced this pull request Apr 27, 2024
limactl ls $INSTANCE should exit with non-0 status if $INSTANCE does not exist #1139 #2295
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.

limactl ls $INSTANCE should exit with non-0 status if $INSTANCE does not exist
3 participants