Commit graph

985 commits

Author SHA1 Message Date
OpenShift Merge Robot 427e87449d
Merge pull request #4887 from vrothberg/fix-4886
e2e/run_signal_test.go: make it more robust
2020-01-16 20:23:37 +01:00
Valentin Rothberg 9d3667c2f0 systemdgen: add --ignore flag to generic services
The --ignore flag lets Podman ignore errors when a specified container
does not exist (anymore).  That's a nice addition to generic services
generated via the --new flag.  Those services create new containers and
can hence allows user to manually remove a container; may it only be by
accident.

The important part of using the --ignore flag is that Podman will exit 0
which plays nicer with most restart policies; a non-zero exit may yield
systemd to restart the entire service which is arguably wrong if the
user manually deletes the container.

If desired, users can still alter the generated files.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-16 16:36:21 +01:00
Valentin Rothberg 49703299b1 e2e/run_signal_test.go: make it more robust
Make the signal test more robust by just checking that the container's
exit code is non-zero.  There are two possible exit codes (i.e., 130 and
137) depending on how the container is being killed, which is likely
responsible for CI flakes.

Fixes: #4886
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-16 16:19:06 +01:00
OpenShift Merge Robot e1e405b70d
Merge pull request #4807 from ssbarnea/fix/pre-commit
Enable pre-commit linting
2020-01-15 23:51:22 +01:00
OpenShift Merge Robot 0870e88ff4
Merge pull request #4824 from edsantiago/bats
more BATS tests
2020-01-15 23:33:02 +01:00
OpenShift Merge Robot 0aa9dba3e1
Merge pull request #4806 from vrothberg/seccomp
policy for seccomp-profile selection
2020-01-15 01:16:07 +01:00
Sorin Sbarnea e9cd3319cf Enable pre-commit tool linting
This should help use keep the codebase more consistent, and avoid sevel
whitespace related issues, or bad file permissions.

pre-commit allows us to easily introduce other linters in follow-ups,
like bashate.

Note: pre-commit tool does *not* install any git-hooks. Making commits
will will call the tool unless you deliverately tell it to install the
hooks.

Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
2020-01-14 13:42:59 +00:00
OpenShift Merge Robot e83a1b87da
Merge pull request #4817 from rhatdan/codespell
Add codespell to validate spelling mistakes in code.
2020-01-13 17:59:58 +01:00
Ed Santiago 1298f19773 more BATS tests
- run: --name (includes 'podman container exists' tests)
- run: --pull (always, never, missing)
- build: new test for ADD URL (#4420)
- exec: new test for issue #4785 (pipe getting lost)
- diff: new test
- selinux (mostly copied from docker-autotest)

Plus a bug fix: the wait_for_output() helper would continue
checking, eventually timing out, even if the container had
already exited (probably because of an error). Fix: as
part of the loop, run 'podman inspect' and bail out if
container is not running. Include exit code and logs.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2020-01-13 06:29:52 -07:00
OpenShift Merge Robot 55dd73cf58
Merge pull request #4823 from vrothberg/gen-systemd
podman-generate-systemd --new
2020-01-12 23:13:45 +01:00
Daniel J Walsh 4093b2c011
Add codespell to validate spelling mistakes in code.
Fix all errors found by codespell

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-11 06:32:19 -05:00
Giuseppe Scrivano 4726eb2861
test: fix error message
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-10 10:38:47 +01:00
Giuseppe Scrivano 71341a1948
log: support --log-opt tag=
support a custom tag to add to each log for the container.

It is currently supported only by the journald backend.

Closes: https://github.com/containers/libpod/issues/3653

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-01-10 10:35:19 +01:00
Valentin Rothberg f3f4c54f2a policy for seccomp-profile selection
Implement a policy for selecting a seccomp profile.  In addition to the
default behaviour (default profile unless --security-opt seccomp is set)
add a second policy doing a lookup in the image annotation.

If the image has the "io.containers.seccomp.profile" set its value will be
interpreted as a seccomp profile.  The policy can be selected via the
new --seccomp-policy CLI flag.

Once the containers.conf support is merged into libpod, we can add an
option there as well.

Note that this feature is marked as experimental and may change in the
future.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-09 17:57:58 +01:00
Valentin Rothberg 816e50ba02 podman-generate-systemd --new
Add a --new flag to podman-generate-systemd to create a new container
via podman-run instead of starting an existing container.

Creating a new container presents the challenge to find a reverse
mapping from a container to the CLI flags it can be created with.  We
are doing this via `(Container).Config.CreateCommand` field, which
includes a copy of the process' command from procFS at creating time.
This field may not be useful when the container was not created via the
Podman CLI (e.g., via a Python script).  Hence, we do not guarantee the
correctness of the generated files.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-01-09 16:12:12 +01:00
OpenShift Merge Robot f3fc10feb4
Merge pull request #4802 from rhatdan/varlink
Fix podman-remote info to show registry data
2020-01-09 10:40:20 +01:00
Sascha Grunert 40b74e02b7
Add untag sub-command
Podman now supports untagging images via the `untag` sub-command for the
root and `image` commands. Testing and documentation has been added as
well.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-08 10:06:10 +01:00
Daniel J Walsh d52a4dc2d4
Fix podman-remote info to show registry data
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-07 19:38:46 -05:00
OpenShift Merge Robot c41fd09a8d
Merge pull request #4781 from haircommander/seccomp-profile-root
play kube: make seccomp handling better conform to k8s
2020-01-07 22:13:03 +01:00
Peter Hunt b6792b61de play kube: make seccomp handling better conform to k8s
Add flag --seccomp-profile-root in play kube to allow users to specify where to look for seccomp profiles
update tests

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2020-01-03 13:27:17 -05:00
Qi Wang b6e1689ff2 fix bug copy from container directory
Keep the original input source path with "/." so podman can copy the content of the directory when copying from container to host.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-01-02 00:53:02 -05:00
OpenShift Merge Robot 9e03aa14b6
Merge pull request #4748 from NevilleC/nc-podname
[Issue #4703] Add the pod name when we use `podman ps -p`
2019-12-29 12:16:43 +01:00
Ed Santiago 0f78f345d9 Fix race condition in kill test leading to hang
When you open a FIFO for reading, but there's no writer, you hang.
This is just one of those obscure UNIXisms we all know but just
forget all too often.

My last PR was guilty of introducing such a condition; I caught
it by accident while testing other stuff. In short, the signal
container was doing 'echo DONE' as its last step, and we (BATS)
were reading the FIFO to check for it; but if the container
exited before we opened the FIFO for read, the open would hang.
This is not a hang that we can catch in the test: it would hang
the entire job forever. CI would presumably time out eventually,
but with no useful indication of the cause of the error.

Solution: use 'exec' to open the FIFO early and keep it open,
and use 'read -u FD' instead of 'read <$fifo': the former
reads from an open FD, the latter forces a new open() each time.

There is a shorter, more maintainable solution -- see #4755 -- but
that suffers from the same hanging problem in the (unlikely) case
where the signal-handling container exits, e.g. if signal handling
is broken in podman. The test would hang, with no helpful indicator.
Although this PR is a little more advanced scripting, I have
commented the relevant code well and believe the maintenance
cost is worth the risk of undebuggable hangs.

There is still a hang risk: if 'podman logs -f' fails and exits
immediately, the 'exec' will hang. I can't think of a non-racy
way to prevent that, and choose to live with that risk.

Tested by temporarily including 9 (SIGKILL) in the signals list.
The read timeout triggers, and the end user has a fair chance
of tracking down the root cause.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-28 08:00:05 -07:00
OpenShift Merge Robot 24b4921508
Merge pull request #4753 from NevilleC/nc-missingsize
Ensure SizeRw is shown when a user does 'inspect --size -t container'.
2019-12-28 12:35:23 +01:00
Neville Cain 8bc394ce6e Add the pod name when we use podman ps -p
The pod name does not appear when doing `podman ps -p`.
It is missing as the documentation says:
-p, --pod              Print the ID and name of the pod the containers are associated with

The pod name is added in the ps output and checked in unit tests.

Closes #4703

Signed-off-by: NevilleC <neville.cain@qonto.eu>
2019-12-28 00:03:57 +01:00
Neville Cain 2a5c235f78 Ensure SizeRw is shown when a user does 'inspect --size -t container'.
Currently, if a user requests the size on a container (inspect --size -t container),
the SizeRw does not show up if the value is 0. It's because InspectContainerData is
defined as int64 and there is an omit when empty.

We do want to display it even if the value is empty. I have changed the type of SizeRw to be a pointer to an int64 instead of an int64. It will allow us todistinguish the empty value to the missing value.

I updated the test "podman inspect container with size" to ensure we check thatSizeRw is displayed correctly.

Closes #4744

Signed-off-by: NevilleC <neville.cain@qonto.eu>
2019-12-27 23:49:34 +01:00
OpenShift Merge Robot 269b173496
Merge pull request #4749 from edsantiago/parse_and_validate_signal
signal parsing - better input validation
2019-12-27 14:59:37 +01:00
Ed Santiago 40f55ca3fe signal parsing - better input validation
The helper function we use for signal name mapping does not
check for negative numbers nor invalid (too-high) ones. This
can yield unexpected error messages:

   # podman kill -s -1 foo
   ERRO[0000] unknown signal "18446744073709551615"

This PR introduces a small wrapper for it that:

  1) Strips off a leading dash, allowing '-1' or '-HUP'
     as valid inputs; and
  2) Rejects numbers <1 or >64 (SIGRTMAX)

Also adds a test suite checking signal handling as well as
ensuring that invalid signals are rejected by the command line.

Fixes: #4746

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-26 16:50:21 -07:00
Matthew Heon 25860df878 The --quiet flag does not conflict with templates in ps
To match Docker behavior, make `--quiet` and `--format` with a Go
template not conflict. Instead, just turn off `--quiet` in such
cases, as we'll be using Go template output instead.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-26 17:45:55 -05:00
Daniel J Walsh 50ece79387
build(deps): bump github.com/containers/image/v5 from 5.0.0 to 5.1.0
Bumps [github.com/containers/image/v5](https://github.com/containers/image) from 5.0.0 to 5.1.0.
- [Release notes](https://github.com/containers/image/releases)
- [Commits](https://github.com/containers/image/compare/v5.0.0...v5.1.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-20 09:30:47 -05:00
OpenShift Merge Robot dde48b44e7
Merge pull request #4684 from vrothberg/systemd-improvements
container config: add CreateCommand
2019-12-19 19:36:52 +01:00
OpenShift Merge Robot c1a7911f37
Merge pull request #4689 from edsantiago/bats
podman images history test - clean up
2019-12-19 15:13:29 +01:00
OpenShift Merge Robot e6b843312b
Merge pull request #4643 from adrianreber/master
Correctly export the root file-system changes
2019-12-17 18:08:36 +01:00
Sascha Grunert 72f35cf211
Remove coverprofile from the repository
The profile should not be part of the repo and is already in the
gitignore.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-12-16 13:49:16 +01:00
Valentin Rothberg 437bc61f4e container config: add CreateCommand
Store the full command plus arguments of the process the container has
been created with.  Expose this data as a `Config.CreateCommand` field
in the container-inspect data as well.

This information can be useful for debugging, as we can find out which
command has created the container, and, if being created via the Podman
CLI, we know exactly with which flags the container has been created
with.

The immediate motivation for this change is to use this information for
`podman-generate-systemd` to generate systemd-service files that allow
for creating new containers (in contrast to only starting existing
ones).

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2019-12-13 14:39:45 +01:00
Ed Santiago ebc4ae660d podman images history test - clean up
As initially written the test does not work other than in
a CI environment because it relies on an empty tag history.
Rewrite so we can guarantee that, by creating a new image.

Also add slightly more helpful tests: the initial tests
would just show "expected 0, got 1" which is unhelpful.
Tweak so we test on actual history contents, which will
show more informative messages on failure.

And, finally, clean up after ourselves.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-12 08:56:44 -07:00
Adrian Reber 225c7ae6c9
Correctly export the root file-system changes
When doing a checkpoint with --export the root file-system diff was not
working as expected. Instead of getting the changes from the running
container to the highest storage layer it got the changes from the
highest layer to that parent's layer. For a one layer container this
could mean that the complete root file-system is part of the checkpoint.

With this commit this changes to use the same functionality as 'podman
diff'. This actually enables to correctly diff the root file-system
including tracking deleted files.

This also removes the non-working helper functions from libpod/diff.go.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-12-09 13:29:36 +01:00
OpenShift Merge Robot 82a83b9ff5
Merge pull request #4440 from edsantiago/bats
test for #3920 (improper caching of tarballs in build)
2019-12-06 08:18:11 -08:00
OpenShift Merge Robot 8924a302a2
Merge pull request #4563 from mheon/fix_change_parsing
Fix parsing for arrays of values in image changes
2019-12-06 04:09:06 -08:00
Ed Santiago 235d4e457a test for #3920 (improper caching of tarballs in build)
See https://github.com/containers/buildah/pull/1955

I've confirmed that this test fails under podman-1.6.2-2.fc30
and passes under current master.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-12-05 07:28:18 -07:00
Matthew Heon 001d06d7f6 Completely rework --change parsing
The way we were trying to parse was very broken. I originally
attempted to use Buildah's Dockerfile parser here, but dealing
with it (and convincing it to accept only a limited subset, and
only one instruction at a time) was challenging, so I rewrote a
subset of Dockerfile parsing. This should handle most common
cases well, though there are definitely unhandled edge cases for
ENV and LABEL.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2019-12-04 18:55:30 -05:00
Giuseppe Scrivano 077ee1a10d
rootless: enable stats test on cgroup v2
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2019-12-04 13:11:58 +01:00
OpenShift Merge Robot c9696c451d
Merge pull request #4596 from kunalkushwaha/container-prune
container prune command fixed as per docker prune command
2019-12-02 18:33:58 -08:00
Daniel J Walsh b9b2ab5e5f
Fix podman-remote version to print client and server
If the user specifies .Server.* on a non podman-remote,
substitute .Client for .Server and return the value.
This is for compatability with Docker.

Since prior versions documented --format {{ .Version }}, we
have to continue to support that.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-02 15:50:00 +01:00
Daniel J Walsh 79bf5010ed
Add podman system reset command
This command will destroy all data created via podman.
It will remove containers, images, volumes, pods.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-11-29 05:34:52 -05:00
Kunal Kushwaha 10c37a2c93 filter added to container prune command
filter flag helps to filter the containers based on
labels, until(time), name, etc for prune command.

Signed-off-by: Kunal Kushwaha <kunal.kushwaha@gmail.com>
2019-11-29 15:28:55 +09:00
Adrian Reber 5e43c7cde1
Disable checkpointing of containers started with --rm
Trying to checkpoint a container started with --rm works, but it makes
no sense as the container, including the checkpoint, will be deleted
after writing the checkpoint. This commit inhibits checkpointing
containers started with '--rm' unless '--export' is used. If the
checkpoint is exported it can easily be restored from the exported
checkpoint, even if '--rm' is used. To restore a container from a
checkpoint it is even necessary to manually run 'podman rm' if the
container is not started with '--rm'.

Signed-off-by: Adrian Reber <areber@redhat.com>
2019-11-28 20:25:45 +01:00
OpenShift Merge Robot 2178875fa7
Merge pull request #4568 from openSUSE/history
Add support for image name history
2019-11-27 15:31:22 +01:00
Sascha Grunert 63e46cc85c
Add support for image name history
We leverage the containers/storage image history tracking feature to
show the previously used image names when running:
`podman images --history`

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2019-11-27 13:42:06 +01:00
OpenShift Merge Robot 27a09f8fab
Merge pull request #4443 from QiWang19/prune_pod
Remove containers when pod prune & pod rm.
2019-11-26 20:43:28 +01:00