Commit Graph

12 Commits

Author SHA1 Message Date
Matt Heon ec68f07c04 Fix Lint on Windows and enable the job
[NO NEW TESTS NEEDED] Purely refactoring

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-20 08:06:18 -05:00
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Valentin Rothberg a5f6a4a3bf kube: notifyproxy: close once
Do not close a notifyproxy more than once.  Also polish the backend a
bit to reflect ealier changes from commit 4fa307f.

Fixes: #19715
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-08-24 16:24:28 +02:00
Valentin Rothberg 4fa307f149 kube sdnotify: run proxies for the lifespan of the service
As outlined in #16076, a subsequent BARRIER *may* follow the READY
message sent by a container.  To correctly imitate the behavior of
systemd's NOTIFY_SOCKET, the notify proxies span up by `kube play` must
hence process messages for the entirety of the workload.

We know that the workload is done and that all containers and pods have
exited when the service container exits.  Hence, all proxies are closed
at that time.

The above changes imply that Podman runs for the entirety of the
workload and will henceforth act as the MAINPID when running inside of
systemd.  Prior to this change, the service container acted as the
MAINPID which is now not possible anymore; Podman would be killed
immediately on exit of the service container and could not clean up.

The kube template now correctly transitions to in-active instead of
failed in systemd.

Fixes: #16076
Fixes: #16515
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-12-06 14:15:11 +01:00
Valentin Rothberg c4ebe9e2ad notifyproxy: fix container watcher
The notify proxy has a watcher to check whether the container has left
the running state.  In that case, Podman should stop waiting for the
ready message to prevent a dead lock.  Fix this watcher but adding a
loop.

Fixes the dead lock in #16076 surfacing in a timeout.  The underlying
issue persists though.  Also use a timer in the select statement to
prevent the goroutine from running unnecessarily long

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-25 10:12:29 +02:00
Valentin Rothberg 7b84a3a434 play kube: notifyproxy: listen before starting the pod
Starting listening for the READY messages on the sdnotify proxies before
starting the Pod.  Otherwise, we may be missing messages.

[NO NEW TESTS NEEDED] as it's hard to test this very narrow race.

Related to but may not be fixing #16076.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-10-12 11:36:04 +02:00
OpenShift Merge Robot 1d63d9f488
Merge pull request #15820 from vrothberg/fix-15800
kube: notifyproxy: fix lost READY message
2022-09-26 13:37:40 +02:00
Chris Evich d968f3fe09
Replace deprecated ioutil
Package `io/ioutil` was deprecated in golang 1.16, preventing podman from
building under Fedora 37.  Fortunately, functionality identical
replacements are provided by the packages `io` and `os`.  Replace all
usage of all `io/ioutil` symbols with appropriate substitutions
according to the golang docs.

Signed-off-by: Chris Evich <cevich@redhat.com>
2022-09-20 15:34:27 -04:00
Valentin Rothberg 4a053a821a notifyproxy: don't set a read deadline
The read deadline may yield the READY message to be lost in space.
Instead, use a more Go-idiomatic alternative by using two goroutines;
one reading from the connection, the other watching the container.

[NO NEW TESTS NEEDED] since existing tests are exercising this
functionality already.

Fixes: #15800
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-16 13:45:25 +02:00
Valentin Rothberg 274d34a25a kube play: support auto updates and rollbacks
Add auto-update support to `podman kube play`.  Auto-update policies can
be configured for:
 * the entire pod via the `io.containers.autoupdate` annotation
 * a specific container via the `io.containers.autoupdate/$name` annotation

To make use of rollbacks, the `io.containers.sdnotify` policy should be
set to `container` such that the workload running _inside_ the container
can send the READY message via the NOTIFY_SOCKET once ready.  For
further details on auto updates and rollbacks, please refer to the
specific article [1].

Since auto updates and rollbacks bases on Podman's systemd integration,
the k8s YAML must be executed in the `podman-kube@` systemd template.
For further details on how to run k8s YAML in systemd via Podman, please
refer to the specific article [2].

An examplary k8s YAML may look as follows:
```YAML
apiVersion: v1
kind: Pod
metadata:
  annotations:
      io.containers.autoupdate: "local"
      io.containers.autoupdate/b: "registry"
  labels:
    app: test
  name: test_pod
spec:
  containers:
  - command:
    - top
    image: alpine
    name: a
  - command:
    - top
    image: alpine
    name: b
```

[1] https://www.redhat.com/sysadmin/podman-auto-updates-rollbacks
[2] https://www.redhat.com/sysadmin/kubernetes-workloads-podman-systemd

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-09-06 08:56:55 +02:00
Valentin Rothberg 79e21b5b16 kube play: sd-notify integration
Integrate sd-notify policies into `kube play`.  The policies can be
configured for all contianers via the `io.containers.sdnotify`
annotation or for indidivual containers via the
`io.containers.sdnotify/$name` annotation.

The `kube play` process will wait for all containers to be ready by
waiting for the individual `READY=1` messages which are received via
the `pkg/systemd/notifyproxy` proxy mechanism.

Also update the simple "container" sd-notify test as it did not fully
test the expected behavior which became obvious when adding the new
tests.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-08-10 21:12:39 +02:00
Valentin Rothberg 67a2e7351b add `pkg/systemd/notifyproxy`
Add a new package for proxying notify sockets and waiting for the
READY=1 message to appear.  May subject to further changes in
future commits.

Tests make sure that it behaves properly.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-08-10 21:10:17 +02:00