Commit graph

15893 commits

Author SHA1 Message Date
Miloslav Trmač
5fbd2d4f57 Make the output of (podman image trust show) deterministic
Sort map keys instead of iterating in the Go-imposed random order.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
feff2af324 Make most of pkg/trust package-private
We now have only a few entrypoints that are called externally,
so make the rest private.  This will make it more obvious that
we are not breaking any external users.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
3b55e991bd Move most of ImageEngine.ShowTrust into pkg/trust.PolicyDescription
This will allow us to write unit tests without setting up the complete Podman runtime
(and without the Linux dependency).

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
84e122bbf2 Add support for sigstoreSigned in (podman image trust set)
NOTE: This does not edit the use-sigstore-attachments value
in registries.d, similarly to how (podman image trust set) didn't
set the lookaside paths for simple signing.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
a4f00ec361 Create new policy entries together with validating input
That way, we don't have to switch over trustType twice.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
567a0bb948 Improve validation of data in ImageEngine.SetTrust
- Also reject public keys with types that don't use them
- Reject unknown trust types
- And add unit tests

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
a1f234e141 Move most of imageEngine.SetTrust to pkg/trust.AddPolicyEntries
This will allow us to write unit tests without setting up the complete Podman runtime
(and without the Linux dependency).

Also, actually add a basic smoke test of the core functionality.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
64fdfaa9b4 Add a variable for scope
Only process the incoming args[] (which is a single-element array
for some reason) once, and use a semantic variable name for the value
we care about.

Should not change behavior, the only caller already supposedly ensures
that len(args) == 1.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
7c9f176cf8 Make trust.CreateTempFile private
Nothing uses it outside the package.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
0c8b200093 Reorganize pkg/trust
Split the existing code into policy.go and registries.go,
depending on which files it concerns.

Only moves unchanged code, should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
702b66249f Remove an unused trust.ShowOutput type
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
Miloslav Trmač
49ac7ee55e Remove commented out code
We can always recover it from git, but it seems to serve
no purpose anyway.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-25 23:31:37 +02:00
OpenShift Merge Robot
d520a5ccab
Merge pull request #16228 from mtrmac/c-image-5.22.1
[v4.2.0-rhel] Update c/image to 5.22.1
2022-10-19 14:54:10 -04:00
Miloslav Trmač
b3feda84bc Update to c/image 5.22.1
> go get github.com/containers/image/v5@v5.22.1
> make vendor

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-19 18:58:18 +02:00
OpenShift Merge Robot
4978898a5c
Merge pull request #16052 from openshift-cherrypick-robot/cherry-pick-16050-to-v4.2.0-rhel
[v4.2.0-rhel] Prevent nil pointer deref in GetImage
2022-10-12 10:34:29 -04:00
OpenShift Merge Robot
12dd1e048b
Merge pull request #16116 from vrothberg/v4.2-backport-4dd67272ed17cfc4c0c1621a969ed66c432677c0
[v4.2.0-rhel] healthcheck: fix --on-failure=stop
2022-10-11 12:07:28 -04:00
Valentin Rothberg
def13bea77 healthcheck: fix --on-failure=stop
Fix the "stop" on-failure action by not removing the transient systemd
timer and service during container stop.  Removing the service will
in turn cause systemd to terminate the Podman process attempting to
stop the container and hence leave it in the "stopping" state.

Instead move the removal into the restart sequence.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-11 16:15:43 +02:00
OpenShift Merge Robot
d752133e2d
Merge pull request #16074 from mheon/backport_15437
[v4.2.0-rhel] Backport #15437
2022-10-09 13:50:17 +02:00
OpenShift Merge Robot
18e5650dd8
Merge pull request #16089 from mheon/backport_16084_420rhel
[v4.2.0-rhel] Backport #16084
2022-10-09 13:47:21 +02:00
Valentin Rothberg
0b7e634798 health checks: make on-failure action retry aware
Make sure that the on-failure actions only kick in once the health check
has passed its retries.  Also fix race conditions on reading/writing the
log.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>

<MH: Addressed cherry-pick conflicts>

Backported to v4.2.0-rhel per RHBZ 2097708

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-10-07 13:47:06 -04:00
Matthew Heon
dce3d6ee9d Add support for containers.conf volume timeouts
Also, do a general cleanup of all the timeout code. Changes
include:
- Convert from int to *uint where possible. Timeouts cannot be
  negative, hence the uint change; and a timeout of 0 is valid,
  so we need a new way to detect that the user set a timeout
  (hence, pointer).
- Change name in the database to avoid conflicts between new data
  type and old one. This will cause timeouts set with 4.2.0 to be
  lost, but considering nobody is using the feature at present
  (and the lack of validation means we could have invalid,
  negative timeouts in the DB) this feels safe.
- Ensure volume plugin timeouts can only be used with volumes
  created using a plugin. Timeouts on the local driver are
  nonsensical.
- Remove the existing test, as it did not use a volume plugin.
  Write a new test that does.

The actual plumbing of the containers.conf timeout in is one line
in volume_api.go; the remainder are the above-described cleanups.

Backported to v4.2.0-rhel per RHBZ 2125241

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-10-06 15:07:10 -04:00
Brent Baude
94d685c0d5 Prevent nil pointer deref in GetImage
Trying to print the image id on a failed inspect will result in a nil
pointer panic because the image will be nil.  Replace image.id with the
image name which is defined as a string without the use of inspect.

Fixes: bz#2131836

[NO NEW TESTS NEEDED]

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-10-05 00:54:26 +00:00
OpenShift Merge Robot
7154106256
Merge pull request #15953 from vrothberg/health-check-backports
[v4.2.0-rhel] health check: add on-failure actions
2022-09-27 15:11:09 +02:00
Valentin Rothberg
fb536046a3 health check: add on-failure actions
For systems that have extreme robustness requirements (edge devices,
particularly those in difficult to access environments), it is important
that applications continue running in all circumstances. When the
application fails, Podman must restart it automatically to provide this
robustness. Otherwise, these devices may require customer IT to
physically gain access to restart, which can be prohibitively difficult.

Add a new `--on-failure` flag that supports four actions:

- **none**: Take no action.

- **kill**: Kill the container.

- **restart**: Restart the container.  Do not combine the `restart`
               action with the `--restart` flag.  When running inside of
               a systemd unit, consider using the `kill` or `stop`
               action instead to make use of systemd's restart policy.

- **stop**: Stop the container.

To remain backwards compatible, **none** is the default action.

Backport of commit aad29e759c

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2097708
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-27 10:40:36 +02:00
Daniel J Walsh
95935c4484
Merge pull request #15915 from mheon/backport_15799_420rhel
[v4.2.0-rhel] Backport #15799
2022-09-23 14:42:07 -04:00
Matthew Heon
b1793d4b1f Ensure that a broken OCI spec does not break inspect
The process of saving the OCI spec is not particularly
reboot-safe. Normally, this doesn't matter, because we recreate
the spec every time a container starts, but if one was to reboot
(or SIGKILL, or otherwise fatally interrupt) Podman in the middle
of writing the spec to disk, we can end up with a malformed spec
that sticks around until the container is next started. Some
Podman commands want to read the latest version of the spec off
disk (to get information only populated after a container is
started), and will break in the case that a partially populated
spec is present. Swap to just ignoring these errors (with a
logged warning, to let folks know something went wrong) so we
don't break important commands like `podman inspect` in these
cases.

[NO NEW TESTS NEEDED] Provided reproducer involves repeatedly
rebooting the system

Backported to v4.2.0-rhel for RHBZ 2126697

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-09-23 11:38:28 -04:00
OpenShift Merge Robot
a1a57db4df
Merge pull request #15745 from vrothberg/v4.2-rhel-cherry-pick-bd050cde18bd0aee6975ef35e74c842b5e3056b7
[v4.2.0-rhel] libpod: UpdateContainerStatus: do not wait for container
2022-09-12 15:49:11 +02:00
Valentin Rothberg
67e300d4d9 libpod: UpdateContainerStatus: do not wait for container
Commit 30e7cbccc1 accidentally added a deadlock as Podman was waiting
for the exit code to show up when the container transitioned to stopped.
Code paths that require the exit code to be written (by the cleanup
process) should already be using `(*Container).Wait()` in a deadlock
free way.

[NO NEW TESTS NEEDED] as I did not manage to a reproducer that would
work in CI.  Ultimately, it's a race condition.

Backport-for: #15492
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2124716
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=2125647
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-12 09:20:38 +02:00
OpenShift Merge Robot
217b9eebc9
Merge pull request #15715 from flouthoc/v4.2.0-rhel-bump-buildah
[v4.2.0-rhel] vendor: bump buildah to `v1.27.1`
2022-09-09 15:24:58 +02:00
Aditya R
49125dccb5
vendor: bump buildah to v1.27.1
Podman build: Add container GID to additional groups

[NO NEW TESTS NEEDED]
[NO TESTS NEEDED]

Signed-off-by: Aditya R <arajan@redhat.com>
2022-09-09 16:47:10 +05:30
OpenShift Merge Robot
c7364c4292
Merge pull request #15696 from openshift-cherrypick-robot/cherry-pick-15618-to-v4.2.0-rhel
[v4.2.0-rhel] Add container GID to additional groups
2022-09-09 12:33:40 +02:00
Matthew Heon
21540161f2 Add container GID to additional groups
Mitigates a potential permissions issue. Mirrors Buildah PR #4200
and CRI-O PR #6159.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-09-08 15:33:29 +00:00
OpenShift Merge Robot
79243ca5e9
Merge pull request #15676 from mheon/fix_ci
[v4.2.0-rhel] Fix CI
2022-09-07 21:23:58 +02:00
Valentin Rothberg
8e52d98c61 fix CI: remove hardcodeded alpine version
The apiv2 test hardcoded the tag of the alpine image.
Remove it to unblock CI.

Fixes: #15388
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-07 13:39:41 -04:00
OpenShift Merge Robot
b78d9b7658
Merge pull request #15540 from cevich/ec2_imgts_rhel
[v4.2.0-rhel] [CI:DOCS] Cirrus: Update meta task for EC2
2022-08-31 08:37:35 -04:00
Chris Evich
1e88166c4a
Cirrus: update DEST_BRANCH
Signed-off-by: Chris Evich <cevich@redhat.com>
2022-08-30 13:20:48 -04:00
Lokesh Mandvekar
3a124df053
[CI:DOCS] Cirrus: Update meta-task for EC2 image
Copied from: https://github.com/containers/aardvark-dns/pull/207

Fixes: #15502

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
Signed-off-by: Chris Evich <cevich@redhat.com>
2022-08-30 12:56:56 -04:00
Matthew Heon
7fe5a419cf Bump to v4.2.0
Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-08-10 16:46:05 -04:00
Matthew Heon
754e320564 Final release notes for v4.2.0
Signed-off-by: Matthew Heon <mheon@redhat.com>
2022-08-10 16:46:05 -04:00
Tomas Volf
4900394c8f Document behavior of --timestamp when only FROM is used
Fixes: #15171

Signed-off-by: Tomas Volf <tomas.volf@showmax.com>
2022-08-10 16:46:05 -04:00
Brent Baude
b619c7a722 check memory test based on range
when verifying that the memory was set correctly for a podman machine
instance, we check if the number is between a range because based on
architecture, operating system, and memory itself this number can differ
significantly.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-08-10 16:46:05 -04:00
Giuseppe Scrivano
a3778b0512 specgen: use sandbox id instead of name for annotation
use the sandbox id instead of the name for the
io.kubernetes.cri-o.SandboxID annotation used by gVisor.

Closes: https://github.com/containers/podman/issues/15223

[NO NEW TESTS NEEDED] it is specific to gVisor

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-10 16:46:05 -04:00
Giuseppe Scrivano
fa1085ed01 cmd: refuse --userns if a mapping is specified
if an explicit mapping is specified, do not accept `--userns` since it
overriden to "private".

Closes: https://github.com/containers/podman/issues/15233

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-08-10 16:46:05 -04:00
Toshiki Sonoda
91a1f3022b e2e: Add rootless mount cleanup test
`podman run -d mount cleanup test` adapt to rootless environment.

Signed-off-by: Toshiki Sonoda <sonoda.toshiki@fujitsu.com>
2022-08-10 16:46:05 -04:00
Lokesh Mandvekar
297c722383 [CI:COPR] podman.spec.rpkg: add python3 dependency for el8
EL8 builds are failing because hack/markdown-preprocess needs python3
which AFAICT isn't included by default in EL8 build environments.

This commit also includes an additional `[CI:COPR]` mode which is
currently runs the same tests as `[CI:DOCS]` but could differ in future.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2022-08-10 16:46:05 -04:00
Karthik Elango
a6ea3325a0 start filter flag changes
Tying filtering logic for podman stop and start to same place in getContainersAndInputByContext() to reduce code redundancy

Signed-off-by: Karthik Elango <kelango@redhat.com>
2022-08-10 16:46:05 -04:00
Chris Evich
a19c5a2521 Cirrus: Run Cross builds in [CI:DOCS] mode
Fixes: #15189

A while ago I updated the only_if/skip options and forgot that several
"cross build" tasks also build documentation in addition to binaries.  Re-enable
them to execute all the time, except when Cirrus-cron is making our
multi-arch images.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-08-10 16:46:05 -04:00
Valentin Rothberg
e776425e56 podman info: hide --debug
It's a NOP since Podman v2.0 (#5738).

[NO NEW TESTS NEEDED] - does not change behavior.

Fixes: #15185
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-08-10 16:46:05 -04:00
Valentin Rothberg
53a631ca28 ISSUE TEMPLATE: remove --debug from podman info
`--debug` is a NOP and will be hidden in a later commit.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-08-10 16:46:05 -04:00
Lokesh Mandvekar
a7d932422d Cirrus: use dnf instead of rpm to install packages
Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
2022-08-10 16:46:05 -04:00