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

Podman machine info #14762

Merged
merged 1 commit into from
Jul 7, 2022
Merged

Podman machine info #14762

merged 1 commit into from
Jul 7, 2022

Conversation

ashley-cui
Copy link
Member

Add podman machine info command, which displays info about the machine
host as well as version info.

Signed-off-by: Ashley Cui [email protected]

Does this PR introduce a user-facing change?

Add podman machine info command, which displays info about the machine
host as well as version info.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 28, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashley-cui

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

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 28, 2022
@ashley-cui
Copy link
Member Author

ashley-cui commented Jun 28, 2022

Fixes: #14113

}

host.NumberOfMachines = len(listResponse)
host.RemoteSocket = fmt.Sprintf("/run/user/%d/podman/podman.sock", os.Getuid())
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only field I'm not sure is entirely correct, please correct me if I'm wrong here.

@ashley-cui
Copy link
Member Author

@baude @benoitf PTAL

@ashley-cui ashley-cui force-pushed the machinfo branch 2 times, most recently from c7cf4bc to f6ced0d Compare June 28, 2022 18:47
Copy link
Contributor

@cdoern cdoern left a comment

Choose a reason for hiding this comment

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

Is there any info to indicate whether the machine is starting? Or would that not be pertinent here, only in machine list?

}

host.NumberOfMachines = len(listResponse)
host.RemoteSocket = fmt.Sprintf("/run/user/%d/podman/podman.sock", os.Getuid())
Copy link
Contributor

@cdoern cdoern Jun 28, 2022

Choose a reason for hiding this comment

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

if running rootful do we need to check for /run/podman/podman.sock?

Copy link
Contributor

Choose a reason for hiding this comment

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

or actually given #14706 this is not an issue. That URL is right for rootless (I think)

Copy link
Member

Choose a reason for hiding this comment

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

This should be based on the valure of XDG_RUNTIME_DIR, shouldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Wouldn't that just be the same as eventSockDIr? Or is remote socket something different? @baude, thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

It is defined right here for podman info ->

uri := url.URL{

@ashley-cui ashley-cui force-pushed the machinfo branch 2 times, most recently from 8031ea5 to 9709bc6 Compare June 29, 2022 13:21
@benoitf
Copy link
Contributor

benoitf commented Jun 29, 2022

That command is really helpful.

Few notes:

  • it has been said by someone else but yes I would expect to know if a Podman machine is currently starting (or stopping)

  • I would expect things changing to be prefixed by 'Current' maybe (or be in a sub-section)
    For example RemoteSocket will change depending on the machine we start (and the same for the currently running machine RunningMachine) while arch, DefaultMachine, EventsDir, etc. are for all machines

    like:

     "Host": {
     "NumberOfMachines": 1, 
     "currentMachine" : {
        "Name": "podman-machine-default",
        "Starting": true,
        "Running": false,
        "Stopping": false,
        "RemoteSocket": "/run/user/501/podman/podman.sock"

}

@baude
Copy link
Member

baude commented Jun 29, 2022

would it be enough to list the machines by name and then use the statuses to determine which is "current"?

@mheon
Copy link
Member

mheon commented Jun 29, 2022

Why are we including a list of machines? That seems like a podman machine ls thing?

@benoitf
Copy link
Contributor

benoitf commented Jun 29, 2022

I would like to have the LocalSocket as well (or 'ContainerHost' link )

because for example RemoteSocket: /run/user/501/podman/podman.sock is not so interesting while using a machine

I would prefer to know the /Users/benoitf/.local/share/containers/podman/machine/podman-machine-default/podman.sock path

@baude
Copy link
Member

baude commented Jun 29, 2022

@mheon thanks for the reminder on machine ls; indeed, I did not want to list each machine in machine info; that is what podman machine ls is for ... i think the original idea was to give number of machines; and if a machine was running, to show that.

@mheon
Copy link
Member

mheon commented Jun 29, 2022

Number of machines/number of running, maybe? Knowing at least 1 is up is a clue to go to machine ls to check, I'd imagine.

@ashley-cui
Copy link
Member Author

@mheon, @baude , @benoitf I'd agree that we shouldn't list machines in machine info, and I'd also prefer if we don't add any information on the machine, as that's covered by podman machine inspect. podman machine info should be generic, ie the information in podman machine info should be relevant to every machine on the system. I think if we do display the machine socket, that should be in inspect.

@mheon, Only one machine can be up at a time, so maybe a field like machineRunning that's a bool?

@benoitf
Copy link
Contributor

benoitf commented Jun 29, 2022

I'm ok to remove all the content that is related to the current machine (like sockets, etc) (and then add it in the inspect command)

About the default machine, can we change through cli the default machine name or is it always 'podman-machine-default' ?

but I think user wants to know the current status of the machine: running, starting or stopped (Running is not enough)

because if you do podman machine info and the machine is still not displayed as RunningMachine you may try to execute podman machine start while the machine is already trying to start

I would also be interested to know if machine has failed to start (it's not running but there was a failure)

so something like

  "CurrentMachine": "podman-machine-default",
  "State|Status": "Starting|Running|Stopped|Failed|N/A...",

@ashley-cui
Copy link
Member Author

Sure, I think default machine is the same thing as current machine. I think I would be okay with adding something like default machine state too, if the others are as well. 😄

@baude
Copy link
Member

baude commented Jun 30, 2022

i assume current machine to mean -- the machine that is running and has nothing to do with default. And using that definition, if a machine is running, the state must be running as well. Am I viewing this differently than others? @rhatdan what so you?

@rhatdan
Copy link
Member

rhatdan commented Jun 30, 2022

Since we only have one machine running at a time, I would expect it to be current machine, if no machine is running then it should be default.

@ashley-cui
Copy link
Member Author

Updated!

@rhatdan
Copy link
Member

rhatdan commented Jul 1, 2022

LGTM
@benoitf @baude PTAL

@benoitf
Copy link
Contributor

benoitf commented Jul 1, 2022

I tried again the command

when I launch podman machine info without a machine I can see

Host:
  Arch: amd64
  CurrentMachine: ""
  DefaultMachine: ""
  EventsDir: /var/folders/tg/_5rxbhmj4xncz4szvpgswrmc0000gn/T/podman-run--1/podman
  MachineConfigDir: /Users/benoitf/.config/containers/podman/machine/qemu
  MachineImageDir: /Users/benoitf/.local/share/containers/podman/machine/qemu
  MachineState: ""
  NumberOfMachines: 0
  OS: darwin
  RemoteSocket: /var/folders/tg/_5rxbhmj4xncz4szvpgswrmc0000gn/T/podman-run--1/podman/podman.sock
  VMType: qemu

But the RemoteSocket path does not exists

$ ls -la /var/folders/tg/_5rxbhmj4xncz4szvpgswrmc0000gn/T/podman-run--1/podman/podman.sock
ls: /var/folders/tg/_5rxbhmj4xncz4szvpgswrmc0000gn/T/podman-run--1/podman/podman.sock: No such file or directory

on my side the socket is at
~/.local/share/containers/podman/machine/podman.sock symlink to /Users/benoitf/.local/share/containers/podman/machine/podman-machine-default/podman.sock

If I only create a machine but I don't start it
podman machine info reports

RemoteSocket: /var/folders/tg/_5rxbhmj4xncz4szvpgswrmc0000gn/T/podman-run--1/podman/podman.sock

but socket path still doesn't exists

and even if I do run the machine the path is still incorrect ?

so

  1. the path displayed is invalid ?
  2. I don't know if RemoteSocket should be displayed if there is no machine or if there is no machine running

as further improvement, I would like to see, if possible, (like in another enhancement) that a machine is being created/initialized

if I do podman machine init in one terminal and podman machine info in another one

I would expect to have when doing podman machine info

  ...
  CurrentMachine: podman-machine-default
  DefaultMachine: podman-machine-default
  ...
  MachineState: Creating
  NumberOfMachines: 1

@ashley-cui
Copy link
Member Author

ashley-cui commented Jul 1, 2022

  1. the path displayed is invalid ?
  2. I don't know if RemoteSocket should be displayed if there is no machine or if there is no machine running

Hmm, okay I think then it isn't XDG_RUNTIME_DIR, let me take another look and fix it

as further improvement, I would like to see, if possible, (like in another enhancement) that a machine is being created/initialized

if I do podman machine init in one terminal and podman machine info in another one

I would expect to have when doing podman machine info

  ...
  CurrentMachine: podman-machine-default
  DefaultMachine: podman-machine-default
  ...
  MachineState: Creating
  NumberOfMachines: 1

I'm not sure if we have a creating status already, this might need to be taken a look at in another PR. Might also be a chicken-and-egg problem. as we don't know that we're creating a VM until the VM exists.. but there might be a place in the code execution were we could sneak that in, I'll give it another look in a different PR

@ashley-cui
Copy link
Member Author

Okay, socket should be correct, but I'm not sure if we should put the sock in machine info, since now we're going into machine inspect territory, by calling inspect. WDYT @baude


```
$ podman machine info
$ podman machine info --format json
Copy link
Member

Choose a reason for hiding this comment

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

might be nice to have a simple go template example too.

@baude
Copy link
Member

baude commented Jul 5, 2022

i think whether the socket exists or not is outside the scope of this PR. I would recommend that we merge this PR and have @benoitf create an issue about the sockets. One thing regarding the sockets, we intentionally do not create them unless a machine is running but for machine events, it probably does make sense.

@ashley-cui
Copy link
Member Author

Added go template example, and removed RemoteSocket field since I think we should avoid calling machine inspect in machine info.

@baude
Copy link
Member

baude commented Jul 5, 2022

LGTM

@mheon
Copy link
Member

mheon commented Jul 5, 2022

Two nits otherwise LGTM

Add podman machine info command, which displays infor about the machine
host as well as version info.

Signed-off-by: Ashley Cui <[email protected]>
@ashley-cui
Copy link
Member Author

Tests are green, @containers/podman-maintainers PTAL and merge

@rhatdan
Copy link
Member

rhatdan commented Jul 7, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 7, 2022
@openshift-ci openshift-ci bot merged commit dd0418a into containers:main Jul 7, 2022
@ashley-cui ashley-cui deleted the machinfo branch July 15, 2022 19:27
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants