Skip to content

oci: include the domainname in "kernel.domainname"#37302

Merged
cpuguy83 merged 2 commits intomoby:masterfrom
cyphar:nis-domainname
Nov 30, 2018
Merged

oci: include the domainname in "kernel.domainname"#37302
cpuguy83 merged 2 commits intomoby:masterfrom
cyphar:nis-domainname

Conversation

@cyphar
Copy link
Copy Markdown
Contributor

@cyphar cyphar commented Jun 17, 2018

The OCI doesn't have a specific field for an NIS domainname (mainly
because FreeBSD and Solaris appear to have a similar concept but it is
configured entirely differently).

However, on Linux, the NIS domainname can be configured through both the
setdomainname(2) syscall but also through the "kernel.domainname"
sysctl. Since the OCI has a way of injecting sysctls this means we don't
need to have any OCI changes to support NIS domainnames (and we can
always switch if the OCI picks up such support in the future).

My ear tufts let me show you them

My ear tufts let me show you them by Bill Stilwell

Fixes: #27067
Signed-off-by: Aleksa Sarai asarai@suse.de

@cyphar
Copy link
Copy Markdown
Contributor Author

cyphar commented Jun 18, 2018

We need opencontainers/runc#1827 in order for this to be handled properly on the runtime side.

@codecov
Copy link
Copy Markdown

codecov bot commented Jun 18, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@baab736). Click here to learn what that means.
The diff coverage is 0%.

@@            Coverage Diff            @@
##             master   #37302   +/-   ##
=========================================
  Coverage          ?   36.11%           
=========================================
  Files             ?      610           
  Lines             ?    45275           
  Branches          ?        0           
=========================================
  Hits              ?    16349           
  Misses            ?    26685           
  Partials          ?     2241

Comment thread daemon/oci_linux.go Outdated
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I should point out that the original code (using FullHostname was not really correct before, since the Domainname was not properly exposed or used). So this part is not an accidental change.

@cyphar
Copy link
Copy Markdown
Contributor Author

cyphar commented Jun 25, 2018

And now we need to require opencontainers/runc@3ccfa2f.

Comment thread daemon/oci_linux.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, so, if a user have set kernel.domainname in HostConfig.Sysctls it will stop working, right? It seems a backward-incompatible change. Also, since setting sysctls directly is lower level than parameters in Config, it probably should take precedence.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, so, if a user have set kernel.domainname in HostConfig.Sysctls it will stop working, right?

I couldn't find anywhere that actually set HostConfig.Sysctls (though since we expose it through the API maybe somebody has used it in the past). But you're right that the precedence is the wrong way around (I forgot that HostConfig was actually accessible through the API -- if it was internal-only this change wouldn't break because I don't think we've ever used Sysctls internally).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@cyphar cyphar force-pushed the nis-domainname branch 2 times, most recently from 8c2f8fc to aeea5dc Compare June 27, 2018 01:25
@cyphar cyphar requested a review from tianon as a code owner June 27, 2018 01:25
@cyphar cyphar force-pushed the nis-domainname branch 2 times, most recently from 13e1b36 to d663653 Compare August 16, 2018 07:23
@cyphar
Copy link
Copy Markdown
Contributor Author

cyphar commented Nov 29, 2018

Rebased.

/ping @kolyshkin

@cpuguy83
Copy link
Copy Markdown
Member

@cyphar Thanks! Can you add a test for this?

Namely:

  1. An integration test to test the full stack (ie, is the domain name actually set in the container)
  2. A unit test to make sure we both setting the sysctl as expected and that hostconfig takes precedence?

The OCI doesn't have a specific field for an NIS domainname[1] (mainly
because FreeBSD and Solaris appear to have a similar concept but it is
configured entirely differently).

However, on Linux, the NIS domainname can be configured through both the
setdomainname(2) syscall but also through the "kernel.domainname"
sysctl. Since the OCI has a way of injecting sysctls this means we don't
need to have any OCI changes to support NIS domainnames (and we can
always switch if the OCI picks up such support in the future).

It should be noted that because we have to generate this each spec
creation we also have to make sure that it's not clobbered by the
HostConfig. I'm pretty sure making this change generic (so that
HostConfig will not clobber any pre-set sysctls) will not cause other
issues to crop up.

[1]: opencontainers/runtime-spec#592

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This also includes a few refactors of oci_linux_test.go.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
@cyphar
Copy link
Copy Markdown
Contributor Author

cyphar commented Nov 30, 2018

@cpuguy83 Tests added.

@kolyshkin
Copy link
Copy Markdown
Contributor

So, it looks like the last commit removes the very essence of the shm test cases I wrote earlier...

@kolyshkin
Copy link
Copy Markdown
Contributor

...or maybe not; need to check it while it's not 3am and I'm using a regular PC not a phone.

@cyphar
Copy link
Copy Markdown
Contributor Author

cyphar commented Nov 30, 2018

@kolyshkin The second commit consolidates the "fake daemon" pattern used, and allows us to use createSpec in a unit test -- both of the existing functions said they were reproducing the code code of createSpec (so switching to using createSpec should keep the test semantics).

@kolyshkin
Copy link
Copy Markdown
Contributor

LGTM, thanks @cyphar

Copy link
Copy Markdown
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

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.

7 participants