Skip to content

Conversation

@thaJeztah
Copy link
Member

Splitting this from #42143, where I found this issue

These tests would panic;

  • in WithRLimits(), because HostConfig was not set;

    moby/daemon/oci_linux.go

    Lines 46 to 47 in 470ae84

    // We want to leave the original HostConfig alone so make a copy here
    hostConfig := *c.HostConfig
  • in daemon.mergeUlimits(), because daemon.configStore was not set;
    for name, ul := range daemon.configStore.Ulimits {

This panic was not discovered because the current version of runc/libcontainer that we vendor
would not always return false for apparmor.IsEnabled() when running docker-in-docker or if
apparmor_parser is not found. Starting with v1.0.0-rc93 of libcontainer, this is no longer
the case (changed in opencontainers/runc@bfb4ea1)

This patch;

  • changes the tests to initialize Daemon.configStore and Container.HostConfig
  • Combines TestExecSetPlatformOpt and TestExecSetPlatformOptPrivileged into a new test
    (TestExecSetPlatformOptAppArmor)
  • Runs the test both if AppArmor is enabled and if not (in which case it tests
    that the container's AppArmor profile is left empty).
  • Adds a FIXME comment for a possible bug in execSetPlatformOpts, which currently
    prefers custom profiles over "privileged".

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

@thaJeztah
Copy link
Member Author

Failure is unrelated

These tests would panic;

- in WithRLimits(), because HostConfig was not set;
  https://github.com/moby/moby/blob/470ae8422fc6f1845288eb7572253b08f1e6edf8/daemon/oci_linux.go#L46-L47
- in daemon.mergeUlimits(), because daemon.configStore was not set;
  https://github.com/moby/moby/blob/470ae8422fc6f1845288eb7572253b08f1e6edf8/daemon/oci_linux.go#L1069

This panic was not discovered because the current version of runc/libcontainer that we vendor
would not always return false for `apparmor.IsEnabled()` when running docker-in-docker or if
`apparmor_parser` is not found. Starting with v1.0.0-rc93 of libcontainer, this is no longer
the case (changed in opencontainers/runc@bfb4ea1)

This patch;

- changes the tests to initialize Daemon.configStore and Container.HostConfig
- Combines TestExecSetPlatformOpt and TestExecSetPlatformOptPrivileged into a new test
  (TestExecSetPlatformOptAppArmor)
- Runs the test both if AppArmor is enabled and if not (in which case it tests
  that the container's AppArmor profile is left empty).
- Adds a FIXME comment for a possible bug in execSetPlatformOpts, which currently
  prefers custom profiles over "privileged".

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah force-pushed the fix_exec_apparmor_test branch from 4081923 to 6d1eceb Compare April 22, 2021 22:39
@thaJeztah
Copy link
Member Author

@AkihiroSuda @cpuguy83 ptal

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

@cpuguy83 cpuguy83 merged commit ac99c86 into moby:master Apr 29, 2021
@thaJeztah thaJeztah deleted the fix_exec_apparmor_test branch April 29, 2021 19:25
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.

3 participants