Skip to content

Commit

Permalink
infra container: replace pause with catatonit
Browse files Browse the repository at this point in the history
Podman has been using catatonit for a number of years already.
Thanks to @giuseppe, catatonit is now able to run as a pause
process which allows us to replace the pause binary entirely.

Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
vrothberg committed Nov 15, 2021
1 parent 58cf0d4 commit 5934e4c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
1 change: 1 addition & 0 deletions contrib/spec/podman.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ BuildRequires: libselinux-devel
BuildRequires: pkgconfig
BuildRequires: make
BuildRequires: systemd-devel
Requires: catatonit >= 0.1.7
Requires: containers-common
Requires: conmon
Requires: containernetworking-plugins >= 0.6.0-3
Expand Down
13 changes: 5 additions & 8 deletions pkg/specgen/generate/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,16 @@ func buildPauseImage(rt *libpod.Runtime, rtConfig *config.Config) (string, error
return imageName, nil
}

// NOTE: Having the pause binary in its own directory keeps the door
// open for replacing the image building with using an overlay root FS.
// The latter turned out to be complex and error prone (see #11956) but
// we may be able to come up with a proper solution at a later point in
// time.
pausePath, err := rtConfig.FindHelperBinary("pause/pause", false)
// Also look into the path as some distributions install catatonit in
// /usr/bin.
catatonitPath, err := rtConfig.FindHelperBinary("catatonit", true)
if err != nil {
return "", fmt.Errorf("finding pause binary: %w", err)
}

buildContent := fmt.Sprintf(`FROM scratch
COPY %s /pause
ENTRYPOINT ["/pause"]`, pausePath)
COPY %s /catatonit
ENTRYPOINT ["/catatonit", "-P"]`, catatonitPath)

tmpF, err := ioutil.TempFile("", "pause.containerfile")
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/apiv2/40-pods.at
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ t GET libpod/pods/fakename/top 404 \
.cause="no such pod"

t GET libpod/pods/foo/top 200 \
.Processes[0][-1]="/pause" \
.Processes[0][-1]="/catatonit -P" \
.Titles[-1]="COMMAND"

t GET libpod/pods/foo/top?ps_args=args,pid 200 \
.Processes[0][0]="/pause" \
.Processes[0][0]="/catatonit -P" \
.Processes[0][1]="1" \
.Titles[0]="COMMAND" \
.Titles[1]="PID" \
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/pod_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,13 @@ var _ = Describe("Podman pod create", func() {
check1 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Config.Entrypoint}}", data.Containers[0].ID})
check1.WaitWithDefaultTimeout()
Expect(check1).Should(Exit(0))
Expect(check1.OutputToString()).To(Equal("/pause"))
Expect(check1.OutputToString()).To(Equal("/catatonit -P"))

// check the Path and Args
check2 := podmanTest.Podman([]string{"container", "inspect", "--format", "{{.Path}}:{{.Args}}", data.Containers[0].ID})
check2.WaitWithDefaultTimeout()
Expect(check2).Should(Exit(0))
Expect(check2.OutputToString()).To(Equal("/pause:[/pause]"))
Expect(check2.OutputToString()).To(Equal("/catatonit:[-P]"))
})

It("podman create pod with --infra-command", func() {
Expand Down

0 comments on commit 5934e4c

Please sign in to comment.