Commit Graph

3950 Commits

Author SHA1 Message Date
OpenShift Merge Robot 639eb52c89
Merge pull request #20062 from vrothberg/syslog-fix
pass --syslog to the cleanup process
2023-09-20 11:57:33 -04:00
OpenShift Merge Robot c5be3aecde
Merge pull request #20056 from Luap99/fast-net-ls
compat API: speed up network list
2023-09-20 16:43:00 +02:00
Valentin Rothberg 4652a2623f pass --syslog to the cleanup process
The --syslog flag has not been passed to the cleanup process (i.e.,
conmon's exit args) complicating debugging quite a bit.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-20 15:37:07 +02:00
Daniel J Walsh 73dc72f80d
vendor of containers/common
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-20 08:39:49 -04:00
Paul Holzinger 8e5adde0b3
compat API: speed up network list
The network list compat API requires us to include all containers with
their ip addresses for the selected networks. Because we have no network
-> container mapping in the db we have to go through all containers
every time. However the old code did it in the most ineffective way
possible, it quered the containers from the db for each individual
network. The of course is extremely expensive. Now the other expensive
call is calling Inspect() on the container each time. Inspect does for
more than we need.

To fix this we fist query containers only once for the API call, then
replace the inspect call with directly accessing the network status.
This will speed things up a lot!
The reported scenario includes 100 containers and 25 networks,
previously it took 1.5s for the API call not it takes 24ms, that is a
more than a 62x improvement. (tested with curl)

[NO NEW TESTS NEEDED] We have no timing tests.

Fixes #20035

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-20 13:08:42 +02:00
Paul Holzinger befdb41995
libpod: remove unused ContainerState() fucntion
First that function claims to deep copy but then actually return the
original state so it does not work correctly, given that there are no
users just remove it instead of fixing it.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-09-20 11:01:09 +02:00
OpenShift Merge Robot 1e43fae5ad
Merge pull request #19873 from rst0git/update-checkpointctl
vendor: update github.com/checkpoint-restore/checkpointctl to 1.1.0
2023-09-14 15:22:02 +02:00
Daniel J Walsh b1e3e8d972
Run codespell on code
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-14 06:13:23 -04:00
Radostin Stoyanov 9b17d6cb06
vendor: update checkpointctl to v1.1.0
Signed-off-by: Radostin Stoyanov <radostin@redhat.com>
2023-09-12 08:41:02 +01:00
danishprakash cdcf18b862
kube: add DaemonSet support for generate
Signed-off-by: danishprakash <danish.prakash@suse.com>
2023-09-12 10:30:57 +05:30
OpenShift Merge Robot cbb955811c
Merge pull request #19245 from mheon/fix_19237
Ensure HC events fire after logs are written
2023-09-11 19:47:37 +02:00
OpenShift Merge Robot 325736fcb7
Merge pull request #19914 from umohnani8/term
Add support for kube TerminationGracePeriodSeconds
2023-09-11 19:24:18 +02:00
Giuseppe Scrivano 19bd9b33dd
libpod: move oom_score_adj clamp to init
commit 8b4a79a744 introduced
oom_score_adj clamping when the container oom_score_adj value is lower
than the current one in a rootless environment.  Move the check to
init() time so it is performed every time the container starts and not
only when it is created.  It is more robust if the oom_score_adj value
is changed for the current user session.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-11 17:04:37 +02:00
Matt Heon 925794c6aa Ensure HC events fire after logs are written
HC events were firing as part of the `exec` call, before it had
even been decided whether the HC succeeded or failed. As such,
the status was not going to be correct any time there was a
change (e.g. the first event after a container went healthy to
unhealthy would still read healthy). Move the event into the
actual Healthcheck function and throw it in a defer to make sure
it happens at the very end, after logs are written.

Ignores several conditions that did not log previously (container
in question does not have a healthcheck, or an internal failure
that should not really happen).

Still not a perfect solution. This relies on the HC log being
written, when instead we could just get the status straight from
the function writing the event - so if we fail to write the log,
we can still report a bad status. But if the log wasn't written,
we're in bad shape regardless - `podman ps` would disagree with
the event written, for example.

Fixes #19237

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-09-11 08:02:46 -04:00
Urvashi Mohnani d9a85466a0 Add support for kube TerminationGracePeriodSeconds
Add support to kube play to support the TerminationGracePeriodSeconds
fiels by sending the value of that to podman's stopTimeout.
Add support to kube generate to generate TerminationGracePeriodSeconds
if stopTimeout is set for a container (will ignore podman's default).

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-09-10 16:41:24 -04:00
Giuseppe Scrivano b8f6a12d01
libpod: create the cgroup pod before containers
When a container is created and it is part of a pod, we ensure the pod
cgroup exists so limits can be applied on the pod cgroup.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
Giuseppe Scrivano 5de8f4aba0
libpod: allow cgroup path without infra container
a pod can use cgroups without an infra container.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
Giuseppe Scrivano 5121c9eb0e
libpod: check if cgroup exists before creating it
do not create the pod cgroup if it already exists.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
Giuseppe Scrivano 38209ef49d
libpod: refactor platformMakePod signature
accept only the resources to be used by the pod, so that the function
can more easily be used by a successive patch.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
Giuseppe Scrivano 627ac1c96b
libpod: destroy pod cgroup on pod stop
When the pod is stopped, we need to destroy the pod cgroup, otherwise
it is leaked.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:48 +02:00
Giuseppe Scrivano 556db46a68
libpod: refactor code to new function
move the code to remove the pod cgroup to a separate function.  It is
a preparation for the next patch.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-09-08 14:58:44 +02:00
Daniel J Walsh 6ee8f73d41
Merge pull request #19885 from rhatdan/kube
Add support for kube  securityContext.procMount
2023-09-08 06:56:05 -04:00
Ed Santiago 70cf9740f1 StopContainer: display signal num when name unknown
Under some circumstances podman tries to kill a container
using signal 37, for which unix.SignalName() returns "".
Not helpful. So, when that happens, show "(signal number)".

Signed-off-by: Ed Santiago <santiago@redhat.com>
2023-09-07 14:13:14 -06:00
Daniel J Walsh b83485022d
Add support for kube securityContext\.procMount
Fixes: https://github.com/containers/podman/issues/19881

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-07 09:49:11 -04:00
Valentin Rothberg 589867d716 podman: don't restart after kill
Also add a new `StoppedByUser` field to the container-inspect state
which can be useful during debugging and is now also used in the
regression test.  Note that I moved the `false` check one test above
such that we can compare the previous Podman version which should just
be stuck in the `wait $ctr` command since it will continue restarting.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-09-07 15:18:02 +02:00
Matt Heon 71549c642f Ignore spurious container-removal errors
When removing a container's dependency, getting an error that the
container has already been removed (ErrNoSuchCtr and
ErrCtrRemoved) should not be fatal. We wanted the container gone,
it's gone, no need to error out.

[NO NEW TESTS NEEDED] This is a race and thus hard to test for.

Fixes #18874

Signed-off-by: Matt Heon <mheon@redhat.com>
2023-09-05 14:35:37 -04:00
Giuseppe Scrivano 702709a916
libpod: do not parse --hostuser in base 8
fix the parsing of --hostuser to treat the input in base 10.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-08-31 12:34:58 +02:00
OpenShift Merge Robot 8bda49608f
Merge pull request #19696 from Luap99/api-stream-format
api docs: document stream format
2023-08-28 19:43:24 +02:00
Giuseppe Scrivano 4b347609d6
oci: print stderr only after checking state
when the "kill" command fails, print the stderr from the OCI runtime
only after we check the container state.

It also simplifies the code since we don't have to hard code the error
messages we want to ignore.

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

[NO NEW TESTS NEEDED] it fixes a flake.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2023-08-28 09:22:48 +02:00
OpenShift Merge Robot 4ff21cf1ac
Merge pull request #19568 from umohnani8/infra-name
Add infra-name annotations to kube gen/play
2023-08-25 15:23:47 +02:00
Daniel J Walsh 6f284dbd46
podman exec should set umask to match container
Fixes: https://github.com/containers/podman/issues/19713

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-24 13:20:06 -04:00
Urvashi Mohnani 52ed7fce2a Add infra-name annotations to kube gen/play
Add io.podman.annotations.infra.name annotation to kube play so
users can set the name of the infra container created.
When a pod is created with --infra-name set, the generated
kube yaml will have an infraName annotation set that will
be used when playing the generated yaml with podman.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-08-24 11:29:56 -04:00
Paul Holzinger 7c9c969815
API attach: return vnd.docker.multiplexed-stream header
The attach API used to always return the Content-Type
`vnd.docker.raw-stream`, however docker api v1.42 added the
`vnd.docker.multiplexed-stream` type when no tty was used.

Follow suit and return the same header for docker api v1.42 and libpod
v4.7.0. This technically allows clients to make a small optimization as
they no longer need to inspect the container to see if they get a raw or
multiplexed stream.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-24 16:22:28 +02:00
OpenShift Merge Robot 1bb96a87c9
Merge pull request #19687 from dfr/freebsd-netstat
libpod: sum per-interface network stats for FreeBSD
2023-08-21 19:49:56 -02:30
OpenShift Merge Robot f727428b52
Merge pull request #19663 from rhatdan/ramfs
Add support for ramfs as well as tmpfs in volume mounts
2023-08-21 16:51:06 -02:30
Doug Rabson 3d00744d29 libpod: sum per-interface network stats for FreeBSD
This sums the metric values from all interfaces similar to the Linux
version.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-08-21 16:00:41 +01:00
OpenShift Merge Robot 375eb045ca
Merge pull request #19661 from dfr/freebsd-var-run
libpod: use /var/run instead of /run on FreeBSD
2023-08-21 12:24:50 -02:30
Daniel J Walsh 45ce4834af
Add support for ramfs as well as tmpfs in volume mounts
Users want to mount a tmpfs file system with secrets, and make
sure the secret is never saved into swap. They can do this either
by using a ramfs tmpfs mount or by passing `noswap` option to
a tmpfs mount.

Fixes: https://github.com/containers/podman/issues/19659

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-21 07:14:57 -04:00
Paul Holzinger c726cf8106
libpod: improve conmon error handling
When conmon is started it blocks and waits for us to signal it to start
via pipe. This works but when conmon exits before it waits for the start
message it causes podman to fail with `write child: broken pipe`. This
error is meaningless to podman users.

The real error is that conmon failed so we should not return early if we
fail to send the start message to conmon. Instead ignore the EPIPE error
case as it is safe to assume to the conmon died and for other errors we
make sure to kill conmon so that the following wait() call does not hang
forever. This also fixes problems with having conmon zombie processes
leaked as wait() was never called.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-17 15:32:59 +02:00
Paul Holzinger 8f85aaf07f
fixup "podman logs with non ASCII log tag" tests
We need to actually check the output not just exit codes. While doing
this it was clear that the first test was not checking what it should
be so I had to remove the quotes from the arg.

Also this check did not work with remote testing at all, we must set the
env then restart the server as the env for conmon must be set on the
server obviously.
Also we can only match the conmon error messages on the local client.

Lastly this test requires the journald driver but we cannot use the in
container tests so skip it there.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-17 15:30:59 +02:00
Doug Rabson 27b41f0877 libpod: use /var/run instead of /run on FreeBSD
This changes /run to /var/run for .containerenv and secrets in FreeBSD
containers for consistency with FreeBSD path conventions. Running Linux
containers on FreeBSD hosts continue to use /run for compatibility.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-08-17 14:04:53 +01:00
Peter Hunt ff66f31ddd
libpod: correctly pass env so alternative locales work
in addition to b6167cedb2
we also need to pass LANG. Do so, and add a test to verify

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2023-08-17 12:15:08 +02:00
Paul Holzinger 4b80492bd2
fix podman top missing output flake
Sometimes there is no output displayed from the podman top command but
no error is shown either. Looking at the code I think the issue here is
that we do not wait for the output reader to end as it runs in a
different goroutine. Thus the last lines of output might be missing.

The fix is simply to wait for said goroutine to finish before returning.
While at it also fix the missing scanner error check and return the read
errors back to the caller.

[NO NEW TESTS NEEDED] It is a flake.

Fixes #19504

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-11 13:43:23 +02:00
Paul Holzinger a55c2636de
file logger: fix podman logs --tail with partial lines
There is a problem where our tail code does not handles correctly
partial log lines. This makes podman logs --tail output possibly
incorrect lines when k8s-file is used.

This manifests as flake in CI because partial lines are only sometimes
written, basically always when the output is flushed before writing a
newline.

For our code we must not count partial lines which was already done but
the important thing we must keep reading backwards until the next full
(F) line. This is because all partial (P) lines still must be added to
the full line. See the added tests for details on how the log file looks
like.

While fixing this, I rework the tail logic a bit, there is absolutely no
reason to read the lines in a separate goroutine just to pass the lines
back via channel. We can do this in the same routine.
The logic is very simple, read the lines backwards, append lines to
result and then at the end invert the result slice as tail must return
the lines in the correct order. This more efficient then having to
allocate two different slices or to prepend the line as this would
require a new allocation for each line.

Lastly the readFromLogFile() function wrote the lines back to the log
line channel in the same routine as the log lines we read, this was bad
and causes a deadlock when the returned lines are bigger than the
channel size. There is no reason to allocate a big channel size we can
just write the log lines in a different goroutine, in this case the main
routine were read the logs anyway.

A new system test and unit tests have been added to check corner cases.

Fixes #19545

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-08-09 14:48:01 +02:00
OpenShift Merge Robot 406c480535
Merge pull request #19533 from hangscer8/fix_waitPidStop_timer
Stop timer in function waitPidStop
2023-08-08 06:59:20 -04:00
OpenShift Merge Robot 2f50d8e579
Merge pull request #19425 from rhatdan/service
Add support for passing container stop timeout as -1 (infinite)
2023-08-08 04:52:33 -04:00
hang.jiang 282594e58f Stop timer in function waitPidStop
Because it will cause memory leak if we do not stop timer when the function has completed.

[NO NEW TESTS NEEDED]

Signed-off-by: hang.jiang <hang.jiang@daocloud.io>
2023-08-08 16:31:27 +08:00
Doug Rabson ec5a9b9cc7 libpod: fix a crash in 'kube generate' on FreeBSD
For containers using host networking, 'kube generate' crashed in
(*Container).HostNetwork which dereferenced config.Spec.Linux without
checking if its non-nil, which is the case for FreeBSD containers.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-08-07 08:16:48 +01:00
Dan Čermák dd4f47dd98
Always show RemoteSocket.Exists in json
The `Exists` field of the `RemoteSocket` struct is marshaled to json with the
`omitempty` setting. This has the disadvantage that by default `podman info`
shows a `remotePath` entry (the remote path is set in
`pkg/domain/infra/abi/systems.go`: `(*ContainerEngine).Info`) but not that this
path does not exist:
```
❯ podman info --format json | jq .host.remoteSocket
{
  "path": "/run/user/1000/podman/podman.sock"
}
```

By removing the `omitempty`, we ensure that the existence is always shown:
```
❯ bin/podman info --format json | jq .host.remoteSocket
{
  "path": "/run/user/1000/podman/podman.sock",
  "exists": false
}
```

Signed-off-by: Dan Čermák <dcermak@suse.com>
2023-08-04 16:24:58 +02:00
Daniel J Walsh 1e54539432
Add support for passing container stop timeout as -1 (infinite)
Compat api for containers/stop should take -1 value

Add support for `podman stop --time -1`
Add support for `podman restart --time -1`
Add support for `podman rm --time -1`
Add support for `podman pod stop --time -1`
Add support for `podman pod rm --time -1`
Add support for `podman volume rm --time -1`
Add support for `podman network rm --time -1`

Fixes: https://github.com/containers/podman/issues/17542

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-08-04 08:36:45 -04:00