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

Add podman system prune and info commands #2252

Merged
merged 2 commits into from
Feb 6, 2019

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Feb 1, 2019

We are missing the equivalence of the docker system commands

This patch set adds podman system prune

Signed-off-by: Daniel J Walsh dwalsh@redhat.com

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 1, 2019

func pruneSystemCmd(c *cli.Context) error {

runtime, err := adapter.GetRuntime(c)
Copy link
Member

Choose a reason for hiding this comment

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

bonus points for using the adapter.Runtime!

@baude
Copy link
Member

baude commented Feb 1, 2019

would really like some tests if that is possible

fmt.Println(cid)
}
}
err1 := volumePrune(runtime, getContext(), c.Bool("force"))
Copy link
Member

Choose a reason for hiding this comment

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

I don't think docker system prune actually prunes volumes. The description says exclusively containers, images, networks

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@vrothberg vrothberg Feb 1, 2019

Choose a reason for hiding this comment

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

There's a --volumes flag.

@rhatdan rhatdan force-pushed the system branch 2 times, most recently from b5c0f01 to 63017fd Compare February 1, 2019 14:12
@rhatdan
Copy link
Member Author

rhatdan commented Feb 1, 2019

/test images

@rhatdan
Copy link
Member Author

rhatdan commented Feb 1, 2019

err = pruneContainers(runtime, ctx, shared.Parallelize("rm"), c.Bool("force"))
if c.Bool("volumes") {
fmt.Println("Deleted Volumes")
err1 := volumePrune(runtime, getContext())
Copy link
Member

Choose a reason for hiding this comment

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

Should we be printing IDs here?

Copy link
Member Author

Choose a reason for hiding this comment

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

volumePrune should print the ids that it is removing.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 1, 2019

/test images

@mheon
Copy link
Member

mheon commented Feb 1, 2019

LGTM

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Nice PR! Just some minor comments regarding --force and making the manpage and help message a bit clearer.

pruneSystemFlags = []cli.Flag{
cli.BoolFlag{
Name: "all, a",
Usage: "remove all unused data",
Copy link
Member

Choose a reason for hiding this comment

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

s/remove/Remove/ for consistency

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed these all in the second patch.

}
pruneSystemCommand = cli.Command{
Name: "prune",
Usage: "Remove unused data",
Copy link
Member

Choose a reason for hiding this comment

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

"data" versus "systems"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Data is correct. systems was incorrect.

WARNING! This will remove:
- all stopped containers%s
- all dangling images
- all build cache
Copy link
Member

Choose a reason for hiding this comment

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

Can we add - all volumes if the flag is set?


ctx := getContext()
fmt.Println("Deleted Containers")
err = pruneContainers(runtime, ctx, shared.Parallelize("rm"), c.Bool("force"))
Copy link
Member

Choose a reason for hiding this comment

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

s/err/errPruneContainers/

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if we should use --force here as it should only impact the cli prompt.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed


// Call prune; if any cids are returned, print them and then
// return err in case an error also came up
pruneCids, err1 := runtime.PruneImages(c.Bool("all"))
Copy link
Member

Choose a reason for hiding this comment

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

s/err1/err/PruneImages/ ... just to make the code easier to brain-parse

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok I changed to use lasterr to make it clearer.

@@ -0,0 +1,38 @@
% PODMAN(1) Podman Man Pages
% Brent Baude
% December 2018
Copy link
Member

Choose a reason for hiding this comment

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

Copy artifact?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

does not have any containers based on it.

By default, volumes are not removed to prevent important data from being deleted if there is currently no container using the volume. Use the --volumes flag when running the command to prune volumes as well.

Copy link
Member

Choose a reason for hiding this comment

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

Can we define what we mean by systems (i.e., containers, images, build cache)? Same applies to the help message. Currently, it's hard to figure out which data is removed without actually running the command.

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 a global replace issue. System should be Images
Fixed

@rhatdan rhatdan force-pushed the system branch 2 times, most recently from bd4c286 to fb8a731 Compare February 4, 2019 18:48
@giuseppe
Copy link
Member

giuseppe commented Feb 5, 2019

LGTM

@@ -13,7 +13,7 @@ var (
podUnpauseFlags = []cli.Flag{
cli.BoolFlag{
Name: "all, a",
Usage: "unpause all paused pods",
Usage: "Anpause all paused pods",
Copy link
Member

Choose a reason for hiding this comment

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

s/Anpause/Unpause/

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -1,9 +1,9 @@
% podman-version(1)
Copy link
Member

Choose a reason for hiding this comment

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

Should this be podman-info?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, Fixed

@@ -1,9 +1,9 @@
% podman-version(1)

## NAME
podman\-system\-info - Display system information
Copy link
Member

Choose a reason for hiding this comment

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

Should this have it's own page, even if it's mostly a cut/paste job?

Copy link
Member Author

Choose a reason for hiding this comment

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

No they are identical, This is what we do with all of the podman container commands

podman-container-ps -> podman-ps.
for example. I think we should add the alternate names to the linked images though.


| Command | Man Page | Description |
| ------- | --------------------------------------------------- | ---------------------------------------------------------------------------- |
| info | [podman-system-info(1)](podman-system-info.1.md) | Displays Podman related system information. |
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the podman-system-info.1.md exists and I don't see it in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@@ -162,6 +162,7 @@ the exit codes follow the `chroot` standard, see below:
| [podman-start(1)](podman-start.1.md) | Starts one or more containers. |
| [podman-stats(1)](podman-stats.1.md) | Display a live stream of one or more container's resource usage statistics. |
| [podman-stop(1)](podman-stop.1.md) | Stop one or more running containers. |
| [podman-system(1)](podman-system.1.md) | Manage podman. |
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 you should add podman-system-info and podman-system-prune here as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't add any subcommands on the main man page?

podman container prune is not there so

Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

Any plans to implement podman system df or podman system events to match Docker? Even if they're no-ops?

@rhatdan
Copy link
Member Author

rhatdan commented Feb 5, 2019

Yes we need to add df and events, althoug podman-system-events is just another way of calling podman events, which also does not exist yet.

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #2227) made this pull request unmergeable. Please resolve the merge conflicts.

We are missing the equivalence of the docker system commands

This patch set adds `podman system prune`
and `podman system info`

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
We have no consistancy in out option usages and descritions
on whether or not the first letter should be capatalized.

This patch forces them all to be capatilized.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
@openshift-merge-robot
Copy link
Collaborator

/retest

@vrothberg
Copy link
Member

/test validate

@baude
Copy link
Member

baude commented Feb 6, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 6, 2019
@openshift-merge-robot openshift-merge-robot merged commit c735072 into containers:master Feb 6, 2019
@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 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants