16517 Commits

Author SHA1 Message Date
43f7bdf822 podman inspect return exit code > 0 on print error
Unlikely to happen but when there is an error printing the data to
stdout (either as json or go template) we should not just log it and
exit with 0. Instead return a proper error and exit with 125.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:14 +02:00
00240a0e2e podman inspect: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:14 +02:00
377599f1f4 podman secret inspect: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:13 +02:00
f5e13ded93 podman secret ls: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:13 +02:00
1463898b07 podman network ls: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:13 +02:00
90634d5ee2 podman volume ls: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

Also fixa bug since the table format is expected to print headers as
well.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:13 +02:00
20eccfc9d0 podman machine inspect: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

Also fix a bug where a invlaid template would not cause a exit code > 0,
see the added test case.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:13 +02:00
a687949dbc podman machine ls: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:12 +02:00
65e78d92c9 podman auto-update: use report.Formatter over Template
Currently the podman command --format output code uses a mix of
report.Formatter and report.Template.

I patched report.Formatter to correctly handle newlines[1]. Since we
cannot fix this with report.Template we have to migrate all users to
report.Formatter. This ensures consistent behavior for all commands.

This change does not change the output, we can add a new test for the
newline bug when the common PR is vendored in.

[1] https://github.com/containers/common/pull/1146

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-13 10:33:12 +02:00
0f39129551 Merge pull request #15758 from edsantiago/docs_dedup_rootfs
[CI:DOCS] Man pages: refactor common options: --rootfs
2022-09-13 10:06:44 +02:00
09ba2e0b9e Man pages: refactor common options: --rootfs
podman-create and -run only. The SELinux text was added
to podman-run (but not -create) in #3631, and reformatted
in #5192. I assume here that it also applies to podman-create.

Per feedback from Dan, added :s0 to SELinux context

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-12 17:56:57 -06:00
4aeaeafde5 Merge pull request #15678 from edsantiago/bats_cleanup
system tests: periodic cleanup and fixes
2022-09-12 23:17:56 +02:00
8216d0ef4e Merge pull request #15749 from dfr/freebsd-networking
Add support for networking on FreeBSD
2022-09-12 21:14:40 +02:00
e24c2f0099 system tests: periodic cleanup and fixes
- basic       : add actual log-level tests
- events      : clean up, add --format tests
- systemd     : reorder proxy args for legibility
- auto-update : fix missing timeout that could lead to hang

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-12 12:17:51 -06:00
6e545945a5 Merge pull request #15717 from Luap99/events
fix several podman events issues
2022-09-12 19:55:15 +02:00
8432ed7488 Merge pull request #15751 from edsantiago/docs_dedup_volumes_from
[CI:DOCS] Man pages: refactor common options: --volumes-from
2022-09-12 19:48:49 +02:00
a63a40c3ee podman events --format: fix duplicated newline
The --format changes caused a duplicated newline.
PR #15678 should have a test for this.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:18 +02:00
2ae4ce7999 fix race where podman events exits to early
In order to display all events we have to read until the event channel
is closed.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:18 +02:00
b3212a6802 set default EventsLogFilePath on first run
The current code only sets EventsLogFilePath when the tmp is overwritten
from the db. We should always set the default when no path was set in
containers.conf.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:18 +02:00
12a1483e7f Improve --tmpdir and --events-backend docs
List the default paths to the event log file and the tmpdir option.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:17 +02:00
72e715a110 Use new secret store API
Refactored secrets API in common for stability purposes. Move podman to
said API.

[NO NEW TESTS NEEDED]

Signed-off-by: Ashley Cui <acui@redhat.com>
2022-09-12 18:05:17 +02:00
cd32b929e3 libpod: runtime newEventer() cleanup
There is no reason to create a new eventer every time. The libpod runtime
already has one attached which should be used instead.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:17 +02:00
76980a2226 event backend journald: fix problem with empty journal
Currently podman events will just fail with `Error: failed to get journal
cursor: failed to get cursor: cannot assign requested address` when the
journal contains zero podman events.

The problem is that we are using the journal accessors wrong. There is no
need to call GetCursor() and compare them manually. The Next() return an
integer which tells if it moved to the next or not. This means the we can
remove GetCursor() which would fail when there is no entry.

This also includes another bug fix. Previously the logic called Next()
twice for the first entry which caused us to miss the first entry.

To reproduce this issue you can run the following commands:
```
sudo journalctl --rotate
sudo journalctl --vacuum-time=1s
```
Note that this will delete the full journal.

Now run podman events and it fails but with this patch it works.
Now generate a single event, i.e. podman pull alpine, and run
podman events --until 1s.

I am not sure how to get a reliable test into CI, I really do not want
to delete the journal and developer or CI systems.

Fixes second part of #15688

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:17 +02:00
138b09c7e2 event backend none: return an error when reading events
podman --events-backend none events should return with an error since it
will never be able to actually list events.

Fixes part three of #15688

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:17 +02:00
c5bdb6afe7 fix hang with podman events file logger
podman --events-backend file events --stream=false should never hang. The
problem is that our tail library will wait for the file to be created
which makes sense when we do not run with --stream=false. To fix this we
can just always create the file when the logger is initialized. This
would also help to report errors early on in case the file is not
accessible.

Fixes part one from #15688

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2022-09-12 18:05:11 +02:00
56c880a7e4 libpod: Move ocicniPortsToNetTypesPorts and compareOCICNIPorts to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
221c4d5f06 libpod: Move NetworkDisconnect and NetworkConnect to networking_common.go
This also moves Runtime methods ConnectContainerToNetwork and
DisconnectContainerFromNetwork as well as support functions
getFreeInterfaceName and normalizeNetworkName.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>

libpod: Move (Connect|Disconnect)Container(To|From)Network and normalizeNetworkName to networking_common.go

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
f939f3fdfc libpod: Move resultToBasicNetworkConfig to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
c9de84080d libpod: Add support for getContainerNetworkInfo on FreeBSD
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
51c70e588d libpod: Move getContainerNetworkInfo to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
d014dca81f libpod: Move isBridgeNetMode and reloadContainerNetwork to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
1dd0eb4679 libpod: Move teardownNetwork and teardownCNI to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:47 +01:00
2bf050f1d1 libpod: Move setUpNetwork and getCNIPodName to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:36 +01:00
3d7f9f67a7 libpod: Move convertPortMappings and getNetworkOptions to networking_common.go
[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:36 +01:00
d1414adbbb libpod: Add FreeBSD implementation of container networking
This uses a jail to manage the container's network. Container jails for
all containers in a pod are nested within this and share the network
resources.

There is some code in networking_freebsd.go which is common with
networking_linux.go. Subsequent commits will move the shared code to
networking_common.go to reduce this duplication.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:28:35 +01:00
c5f64d9f58 libpod: Re-work the container's network state to help code sharing
This replaces the NetworkJail string field with a struct pointer named
NetNS. This does not try to emulate the complete NetNS interface but does
help to re-use code that just refers to c.state.NetNS.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:11:25 +01:00
36cfd05a7d libpod: Move platform-specific bind mounts to a per-platform method
This adds a new per-platform method makePlatformBindMounts and moves the
/etc/hostname mount. This file is only needed on Linux.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:11:25 +01:00
369d86040e libpod: Avoid a nil dereference when generating resolv.conf on FreeBSD
The code which generates resolv.conf dereferenced c.config.Spec.Linux
and this field is not set for FreeBSD containers.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 16:08:56 +01:00
5abc08df25 Merge pull request #15511 from rhatdan/codespell
Fix stutters
2022-09-12 16:52:08 +02:00
3b9e31c9bb Merge pull request #15747 from vrothberg/docs-volume
[CI:DOCS] --volume: consistent wording
2022-09-12 15:46:38 +02:00
43da39d317 Man pages: refactor common options: --volumes-from
Removed a spurious right-bracket; went with upper-case for options;
removed 'you's; added some <<container|pod>>s.

Hard to review because none of the existing man pages had it
quite right.

Signed-off-by: Ed Santiago <santiago@redhat.com>
2022-09-12 06:59:19 -06:00
4d202f067d Merge pull request #15744 from dfr/vendor
update c/storage to latest
2022-09-12 13:35:11 +02:00
050ae61817 [CI:DOCS] --volume: consistent wording
Make sure that the wording of mounting something _from_ the source
_into_ the destination is consistent.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-12 10:04:29 +02:00
d935e97994 update c/storage to latest
Signed-off-by: Doug Rabson <dfr@rabson.org>
2022-09-12 08:11:46 +01:00
1635fe8620 Merge pull request #15737 from Juneezee/refactor/os.ReadDir
refactor: use `os.ReadDir` for lightweight directory reading
2022-09-12 06:50:48 +02:00
940d3d8892 Merge pull request #15734 from KenMacD/add-path
Include PATH in conmon env.
2022-09-12 00:38:03 +02:00
6091ff42dc Include more environment variables in conmon env.
Include the path and helper binary dir so that the podman
environment more closely matches when conmon calls it as an
exit command.

Also match the CONTAINERS_CONF lookup to the codestyle of other
environment lookups.

[NO NEW TESTS NEEDED]

Resolves #15707

Signed-off-by: Kenny MacDermid <kenny@macdermid.ca>
2022-09-11 11:49:35 -03:00
118546c6a7 refactor: use os.ReadDir for lightweight directory reading
`os.ReadDir` was added in Go 1.16 as part of the deprecation of `ioutil`
package. It is a more efficient implementation than `ioutil.ReadDir`.

Reference: https://pkg.go.dev/io/ioutil#ReadDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-09-11 15:58:31 +08:00
b9cbc0c09a Merge pull request #15728 from tyler92/fix-cpu-millis-limit
Fix CPU usage limitation in play kube for non integer values
2022-09-10 17:40:01 +02:00
2c63b8439b Fix stutters
Podman adds an Error: to every error message.  So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-10 07:52:00 -04:00