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

[CI:DOCS] man pages: document some --format options #14386

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/source/markdown/podman-container-inspect.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,48 @@ all results in a JSON array. If a format is specified, the given template will b
Format the output using the given Go template.
The keys of the returned JSON can be used as the values for the --format flag (see examples below).

Valid placeholders for the Go template are listed below:

| **Placeholder** | **Description** |
| ----------------- | ------------------ |
| .AppArmorProfile | AppArmor profile (string) |
Copy link
Member Author

Choose a reason for hiding this comment

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

Is this (string) (array of strings) (etc) useful?

Copy link
Member

Choose a reason for hiding this comment

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

I think it is unless it becomes overwhelming to the man page.

| .Args | Command-line arguments (array of strings) |
| .BoundingCaps | Bounding capability set (array of strings) |
| .Config ... | Structure with config info |
| .ConmonPidFile | Path to file containing conmon pid (string) |
| .Created | Container creation time (string, ISO3601) |
| .Dependencies | Dependencies (array of strings) |
| .Driver | Storage driver (string) |
| .EffectiveCaps | Effective capability set (array of strings) |
| .ExecIDs | Exec IDs (array of strings) |
| .GraphDriver ... | Further details of graph driver (struct) |
| .HostConfig ... | Host config details (struct) |
| .HostnamePath | Path to file containing hostname (string) |
| .HostsPath | Path to container /etc/hosts file (string) |
| .ID | Container ID (full 64-char hash) |
| .Image | Container image ID (64-char hash) |
| .ImageName | Container image name (string) |
| .IsInfra | Is this an infra container? (string: true/false) |
| .IsService | Is this a service container? (string: true/false) |
| .MountLabel | SELinux label of mount (string) |
| .Mounts | Mounts (array of strings) |
| .Name | Container name (string) |
| .Namespace | Container namespace (string) |
| .NetworkSettings ... | Network settings (struct) |
| .OCIConfigPath | Path to OCI config file (string) |
| .OCIRuntime | OCI runtime name (string) |
| .Path | Path to container command (string) |
| .PidFile | Path to file containing container PID (string) |
| .Pod | Parent pod (string) |
| .ProcessLabel | SELinux label of process (string) |
| .ResolvConfPath | Path to container's resolv.conf file (string) |
| .RestartCount | Number of times container has been restarted (int) |
| .Rootfs | Container rootfs (string) |
| .SizeRootFs | Size of rootfs (int) |
| .SizeRw | FIXME |
| .State ... | Container state info (struct) |
| .StaticDir | Path to container metadata dir (string) |

#### **--latest**, **-l**

Instead of providing the container name or ID, use the last created container. If you use methods other than Podman
Expand Down
10 changes: 10 additions & 0 deletions docs/source/markdown/podman-info.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ Show additional information

Change output format to "json" or a Go template.

| **Placeholder** | **Info pertaining to ...** |
| ------------------- | --------------------------------------- |
| .Host ... | ...the host on which podman is running |
| .Store ... | ...the storage driver and paths |
| .Registries ... | ...configured registries |
| .Plugins ... | ...external plugins |
| .Version ... | ...podman version |

Each of the above branch out into further subfields, more than can
reasonably be enumerated in this document.

## EXAMPLE

Expand Down
44 changes: 28 additions & 16 deletions docs/source/markdown/podman-pod-inspect.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,34 @@ Change the default output format. This can be of a supported type like 'json'
or a Go template.
Valid placeholders for the Go template are listed below:

| **Placeholder** | **Description** |
| ----------------- | ----------------------------------------------------------------------------- |
| .ID | Pod ID |
| .Name | Pod name |
| .State | Pod state |
| .Hostname | Pod hostname |
| .Labels | Pod labels |
| .Created | Time when the pod was created |
| .CreateCgroup | Whether cgroup was created |
| .CgroupParent | Pod cgroup parent |
| .CgroupPath | Pod cgroup path |
| .CreateInfra | Whether infrastructure created |
| .InfraContainerID | Pod infrastructure ID |
| .SharedNamespaces | Pod shared namespaces |
| .NumContainers | Number of containers in the pod |
| .Containers | Pod containers |
| **Placeholder** | **Description** |
| ----------------- | ------------------------------------------ |
| .ID | Pod ID |
| .Name | Pod name |
| .State | Pod state |
| .Hostname | Pod hostname |
| .Labels | Pod labels |
| .BlkioDeviceReadBps | Block I/O Device Read, in bytes/sec |
| .CPUPeriod | CPU period |
| .CPUQuota | CPU quota |
| .CPUSetCPUs | CPU Set CPUs |
| .Created | Time when the pod was created |
| .CreateCgroup | Whether cgroup was created |
| .CgroupParent | Pod cgroup parent |
| .CgroupPath | Pod cgroup path |
| .Containers | Pod containers |
| .CreateCommand | Create command |
| .CreateInfra | Whether infrastructure created |
| .InfraContainerID | Pod infrastructure ID |
| .Devices | Devices |
| .ExitPolicy | Exit policy |
| .InfraConfig ... | Infra config (contains further fields) |
| .Mounts | Mounts |
| .Namespace | Namespace |
| .NumContainers | Number of containers in the pod |
| .SecurityOpts | Security options |
| .SharedNamespaces | Pod shared namespaces |
| .VolumesFrom | Volumes from |

#### **--latest**, **-l**

Expand Down
11 changes: 11 additions & 0 deletions docs/source/markdown/podman-secret-inspect.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ Secrets can be queried individually by providing their full name or a unique par

Format secret output using Go template.

| **Placeholder** | **Description** |
| ------------------------ | ----------------------------------------------------------------- |
| .ID | ID of secret |
| .Spec | Details of secret |
| .Spec.Name | Name of secret |
| .Spec.Driver | Driver info |
| .Spec.Driver.Name | Driver name (string) |
| .Spec.Driver.Options ... | Driver options (map of driver-specific options) |
| .CreatedAt | When secret was created (relative timestamp, human-readable) |
| .UpdatedAt | When secret was last updated (relative timestamp, human-readable) |

#### **--help**

Print usage statement.
Expand Down
38 changes: 27 additions & 11 deletions docs/source/markdown/podman-stats.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,33 @@ Pretty-print container statistics to JSON or using a Go template

Valid placeholders for the Go template are listed below:

| **Placeholder** | **Description** |
| --------------- | ------------------ |
| .ID | Container ID |
| .Name | Container Name |
| .CPUPerc | CPU percentage |
| .MemUsage | Memory usage |
| .MemUsageBytes | Memory usage (IEC) |
| .MemPerc | Memory percentage |
| .NetIO | Network IO |
| .BlockIO | Block IO |
| .PIDS | Number of PIDs |
| **Placeholder** | **Description** |
| --------------- | ------------------ |
| .ID | Container ID (truncated) |
| .ContainerID | Container ID (full hash) |
| .Name | Container Name |
| .CPUPerc | CPU percentage |
| .MemUsage | Memory usage |
| .MemUsageBytes | Memory usage (IEC) |
| .AvgCPU | Average CPU (full precision float) |
| .AVGCPU | Average CPU (formatted) |
| .CPU | Percent CPU (full precision float) |
| .CPUNano | CPU Usage, total, in nanoseconds |
| .CPUSystemNano | CPU Usage, kernel, in nanoseconds |
| .Duration | Same as CPUNano (FIXME: why?) |
| .MemLimit | Memory limit, in bytes |
| .MemPerc | Memory percentage |
| .NetIO | Network IO |
| .BlockIO | Block IO |
| .PIDS | Number of PIDs |
| .NetInput | Network Input |
| .NetOutput | Network Output |
| .BlockInput | Block Input |
| .BlockOutput | Block Output |
| .PIDs | Number of PIDs |
| .SystemNano | Current system datetime, nanoseconds since epoch |
| .UpTime | WTF? This is Duration (CPUNano) in human-readable form?? |
| .Up | Same as UpTime (FIXME: why?) |
Copy link
Member Author

Choose a reason for hiding this comment

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

Two FIXMES and one WTH where I'd appreciate feedback

Copy link
Member

Choose a reason for hiding this comment

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

UpTime looks like it is the value in /proc/uptime. Which RHEL describes as
total number of seconds the system has been up.
In Containers (Really PID Namespaces) this would be the total number of seconds the container has been up

I don't see '{{.Up so I don't think we should document 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.

I don't see '{{.Up so I don't think we should document it.

Well, that's just the problem in a nutshell. Where are you looking, that you don't see .Up? Because I guarantee that it exists, and this is exactly the problem I'm trying to address.

First: it exists:

$ bin/podman stats --no-reset --no-stream --format '{{.Up}}'
57.940104s

Second, and much more importantly, command-completion offers it as a suggestion:

$ bin/podman stats --format '{{.'
{{.AVGCPU}}         {{.CPUSystemNano}}  {{.MemPerc}}        {{.PIDS}}         
{{.AvgCPU}}         {{.CPU}}            {{.MemUsageBytes}}  {{.PIDs}}         
{{.BlockIO}}        {{.ContainerID}}    {{.MemUsage}}       {{.PerCPU}}       
{{.BlockInput}}     {{.ContainerStats.  {{.Name}}           {{.SystemNano}}   
{{.BlockOutput}}    {{.Duration}}       {{.NetIO}}          {{.UpTime}}       
{{.CPUNano}}        {{.ID}}             {{.NetInput}}       {{.Up}}           <<<<<<<<<<<<<<
{{.CPUPerc}}        {{.MemLimit}}       {{.NetOutput}}

Therefore, IMO, it should be documented. This is what I'm trying to do in #14046. Nobody has stepped in to document the FIXMEs in that PR, so I'm taking baby steps myself. There are some fields, like this one, that are way above my ability to explain.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, and .UpTime does not seem to be the same as /proc/uptime:

$ bin/podman stats --no-reset --no-stream --format '{{.UpTime}}'
57.994023s
$ bin/podman exec -l cat /proc/uptime
10354051.09 78779541.56

Copy link
Member

Choose a reason for hiding this comment

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

I got that from reading the code, but perhaps there is other mechanisms for setting it?

In Main I now see:
$ ./bin/podman stats --format {{.
{{.AvgCPU}}         {{.BlockIO}}        {{.ContainerStats.  {{.CPUPerc}}        {{.ID}}             {{.MemUsage}}       {{.NetInput}}       {{.PerCPU}}         {{.SystemNano}}     
{{.AVGCPU}}         {{.BlockOutput}}    {{.CPU}}            {{.CPUSystemNano}}  {{.MemLimit}}       {{.MemUsageBytes}}  {{.NetIO}}          {{.PIDs}}           {{.Up}}             
{{.BlockInput}}     {{.ContainerID}}    {{.CPUNano}}        {{.Duration}}       {{.MemPerc}}        {{.Name}}           {{.NetOutput}}      {{.PIDS}}           {{.UpTime}}         
IN Release I see
$ /bin/podman stats --format {{.
{{.AvgCPU}}         {{.BlockOutput}}    {{.CPU}}            {{.CPUSystemNano}}  {{.MemLimit}}       {{.MemUsage}}       {{.NetInput}}       {{.PerCPU}}         {{.SystemNano}}     
{{.BlockInput}}     {{.ContainerID}}    {{.CPUNano}}        {{.Duration}}       {{.MemPerc}}        {{.Name}}           {{.NetOutput}}      {{.PIDs}}           {{.UpTime}}     

Copy link
Member

Choose a reason for hiding this comment

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

Fine then I say we either eliminate these builtin functions or someone figure a way to not expose them Up and Uptime are two ways of returning the same thing (One is a string the other is a time format?).

If these become part of the docs, then we loose the ability to change their output.

BlockInput versus BlockIO etc...

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, that's the premise behind #14046. As a dumb end user, if I type --format something<TAB> and see .Foo, I would like to have .Foo documented in a man page somewhere; preferably in a complete and accurate table showing me its explanation and a list of all other possible values. (Actually, command completion aside, I have ALWAYS wanted this table of possible formats; it's just that now there's a small possibility of creating those tables and keeping them accurate).

I realize this is a very low priority in the grand scheme of things. I would just like to have serious conversations about it, because if you look at #14046 you will see that we do a very, very poor job of documenting formats, and I think we can and should do better. Even if I have to abandon my cross-check, I would like to see some effort toward documenting.

Copy link
Member

Choose a reason for hiding this comment

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

Sure. and I like the idea. The problem is we have leaked into this area fields we want users to use, along with fields we don't want them to use, and up to now, it was very unlikely they would discover the ones that leaked out. Which is why I don't want to document the mistake ones.

Copy link
Member

Choose a reason for hiding this comment

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

Well how do you know what is internal and what not?
The only way to support this would be to create new structs for the templates and copy the (internal) data into it, currently they are embedded and thus accessible for all template users.

At the moment there is no protection if a developer changes/removes fields. With @edsantiago script we could at least ensure that they are no unwanted breaking changes in the format templates.

Copy link
Member

Choose a reason for hiding this comment

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

I want to look at the stats code and figure out if these functions are actually needed or not. Some of these are just translating from one form to another, but a conflict in names causes issues. Bottom line if we can not explain what a field is to the user then we should not document it.


When using a GO template, you may precede the format with `table` to print headers.

Expand Down
8 changes: 8 additions & 0 deletions docs/source/markdown/podman-version.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ OS, and Architecture.

Change output format to "json" or a Go template.

| **Placeholder** | **Description** |
| ------------------- | ------------------------ |
| .Client ... | Version of local podman |
| .Server ... | Version of remote podman |

Each of the above fields branch deeper into further subfields
such as .Version, .APIVersion, .GoVersion, and more.

## Example

A sample output of the `version` command:
Expand Down