Skip to content

integration: use systemd when $DOCKER_SYSTEMD is set#40493

Merged
thaJeztah merged 2 commits intomoby:masterfrom
AkihiroSuda:dockerfile-systemd
Mar 3, 2020
Merged

integration: use systemd when $DOCKER_SYSTEMD is set#40493
thaJeztah merged 2 commits intomoby:masterfrom
AkihiroSuda:dockerfile-systemd

Conversation

@AkihiroSuda
Copy link
Member

@AkihiroSuda AkihiroSuda commented Feb 10, 2020

- What I did
Added systemd in the integration testing image.
This will help testing rootless and systemd stuff.

Fix #40492

- How I did it
Added a variant of hack/dind script:hack/dind-systemd.

This script executes the arguments as a systemd service in foreground with tty connected, and then call systemctl exit $EXIT_STATUS to shutdown the systemd process with the expected exit code.

- How to verify it

  • DOCKER_SYSTEMD=1 make test-integration

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)
🐧

@AkihiroSuda AkihiroSuda requested a review from tianon as a code owner February 10, 2020 17:59
@thaJeztah
Copy link
Member

This script is more widely used than just in our CI; wondering if we should have a separate script just for CI if this is needed

@AkihiroSuda
Copy link
Member Author

Testing should be possible on a laptop as well?

@thaJeztah
Copy link
Member

Right, but it's also used in the docker images on Docker Hub for example; https://github.com/docker-library/docker/blob/7db7eccb7b7507b1a6ba3ef81c6f37b16149cc55/Dockerfile-dind.template#L33-L38

Also not sure

  • if we always want systemd to be used?
  • if instead of cat-ing the unit file, we should just add a unit file to this repo, and COPY it into the container

@AkihiroSuda AkihiroSuda force-pushed the dockerfile-systemd branch 2 times, most recently from cf6d7d1 to eb85eca Compare February 10, 2020 21:07
@AkihiroSuda
Copy link
Member Author

Updated not to use systemd when systemd is not installed, but I think docker images on Docker Hub should fork the code.

if we always want systemd to be used?

I think we can use systemd always.

Also, even for rootful with cgroupfs driver, systemd might be useful for simplifying .integration-daemon-{start,stop} stuff.

if instead of cat-ing the unit file, we should just add a unit file to this repo, and COPY it into the container

No, the file needs to be autogenerated (for command args, workdir, and env vars)

@AkihiroSuda
Copy link
Member Author

AkihiroSuda commented Feb 10, 2020

Interestingly, this PR seems to have digged up some broken tests that hadn't been executed in CI.

[2020-02-10T21:34:56.998Z] --- FAIL: TestCgroupDriverSystemdMemoryLimit (1.76s)

[2020-02-10T21:34:56.998Z]     cgroupdriver_systemd_test.go:54: assertion failed: 67108864 (s.HostConfig.Memory int64) != 67108864 (mem int)

[2020-02-10T21:34:56.998Z] FAIL

[2020-02-10T21:34:56.998Z] 

[2020-02-10T21:34:56.998Z] === Failed

[2020-02-10T21:34:56.998Z] === FAIL: arm64.integration.system TestCgroupDriverSystemdMemoryLimit (1.76s)

[2020-02-10T21:34:56.998Z] === PAUSE TestCgroupDriverSystemdMemoryLimit

[2020-02-10T21:34:56.998Z] === CONT  TestCgroupDriverSystemdMemoryLimit

[2020-02-10T21:34:56.998Z]     cgroupdriver_systemd_test.go:54: assertion failed: 67108864 (s.HostConfig.Memory int64) != 67108864 (mem int)

@AkihiroSuda

This comment has been minimized.

@AkihiroSuda
Copy link
Member Author

@tianon PTAL?

@tianon
Copy link
Member

tianon commented Feb 15, 2020

I agree with the intent here (automated testing of more things via systemd, especially things that can't effectively be tested right now), but anything that runs systemd in a container, even more especially one that's typically run with --privileged, makes me very wary. I've seen way too many systems accidentally tanked thanks to systemd inside the container having some service someone forgot to disable that then tries to initialize already-initialized host devices (as an example), and causing the expected havoc.

@thaJeztah
Copy link
Member

could we add a variant just used for our CI, and keep the standard dind script as-is?

@tianon
Copy link
Member

tianon commented Feb 15, 2020

I like that idea, as long as the logistics work for actually using it 😅

@AkihiroSuda AkihiroSuda changed the title hack/dind: enable systemd integration: use systemd when $DOCKER_SYSTEMD is set Feb 18, 2020
@AkihiroSuda
Copy link
Member Author

Updated to split the script. PTAL.

@AkihiroSuda
Copy link
Member Author

@tianon PTAL?

The test was failing:

  --- FAIL: TestCgroupDriverSystemdMemoryLimit (1.76s)
      cgroupdriver_systemd_test.go:54: assertion failed: 67108864 (s.HostConfig.Memory int64) != 67108864 (mem int)

Signed-off-by: Akihiro Suda <[email protected]>
Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@thaJeztah thaJeztah merged commit e2b7793 into moby:master Mar 3, 2020
@thaJeztah thaJeztah added this to the 20.03.0 milestone Apr 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test-integration: use systemd image

4 participants