-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kola: Add isolation=readonly|dynamicuser
#3060
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -826,6 +826,7 @@ type externalTestMeta struct { | |||
AppendKernelArgs string `json:"appendKernelArgs,omitempty"` | ||||
AppendFirstbootKernelArgs string `json:"appendFirstbootKernelArgs,omitempty"` | ||||
Exclusive bool `json:"exclusive"` | ||||
Isolation string `json:"isolation"` | ||||
TimeoutMin int `json:"timeoutMin"` | ||||
Conflicts []string `json:"conflicts"` | ||||
AllowConfigWarnings bool `json:"allowConfigWarnings"` | ||||
|
@@ -943,6 +944,24 @@ func registerExternalTest(testname, executable, dependencydir string, userdata * | |||
targetMeta = &metaCopy | ||||
} | ||||
|
||||
switch targetMeta.Isolation { | ||||
case "readonly": | ||||
case "dynamicuser": | ||||
// These tests cannot provide their own Ignition | ||||
if userdata != nil { | ||||
return fmt.Errorf("test %v specifies isolation=%v but includes an Ignition config", testname, targetMeta.Isolation) | ||||
} | ||||
targetMeta.Exclusive = false | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Still need to drop this bit as discussed in https://github.com/coreos/coreos-assembler/pull/3060/files#r960684553 and https://github.com/coreos/coreos-assembler/pull/3060/files#discussion_r960795802 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no use case for I definitely see this replacing most of our use of In practice, our test framework is mostly something that needs to be understood by a relatively small set of people. Sure, this is a change that some people would need to learn about later, but it's really not a big change either, and we have docs. And the existing test corpus acts as an example. I think enhancing the robustness of the test suite outweighs the very short term transition period where we some people may need to learn that Here's another way to look at this - a lot of people I'm sure start writing a new test by copy-pasting an old one. Today it's really easy to copy-paste an With Your proposal would implicitly support people accidentally doing just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just stating and restating and stating again that I don't want to imply If someone added a test that was likely to cause flakes because it's run with other tests we'd catch that today because we automatically re-run failed tests on their own and we'd see that the re-run passed. I get what you were trying to do with this, but the model we developed doesn't apply If we change anything what I would prefer is for non-exclusive tests to default to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I already wrote up a comment in the other thread before I saw Dusty's reply proposing essentially the same thing. Moving it here for completeness: I think the isolation functionality is potentially useful, but if the goal is to reduce boilerplate comments, the proposed flags are counterproductive. Tests have to opt in to this functionality by writing something like So let's figure out what we actually want here, without recreating systemd security option spaghetti. Proposal: for tests that have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Your seems to overlap with bgilbert's, so replying below:
Right, but the developers on the team already have to read the external-tests.md documentation to understand much at all. Needing that isn't...isolated...to this change.
Hmmm...definitely implicit-over-explicit going on here. I think having an ignition/butane config provided turning off isolation would be too magical, and instead we should error out and require Overall I'm absolutely fine with defaulting A tricky thing here is that some of our read only tests actually do need to still run as root because they traverse the filesystem and we have some protected directories. This is why I introduced both Anyways then so then we're agreeing to:
I need to more carefully look at the case of external tests with ignition configs and see the impact. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did see it. It does not address my concerns from the comment #3060 (comment) it was replying to, nor my restatement just now in #3060 (comment). My -1 will remain in place until those concerns are addressed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah...you're proposing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Err...I was with you on the first half of the sentence - sure, we can have a boolean instead a tristate (I still don't think a tristate is hard or complicated but whatever, I was mainly on board with just having a boolean). That seems to be what Dusty was arguing for too. Then in the second half you made up another boolean - and now we have two booleans which is (I hope you'd agree if you step back for a moment) not actually simpler. For one thing, two booleans is four potential states. The new one of which (restrict: false, run-as-root: true) is redundant. And any future expansion via additional booleans becomes quickly grows the state space. I think I'd much prefer just a boolean (if that's what we're going down to) alongside the ability for tests to inject arbitrary systemd unit directives, which would likely help solve other things too (e.g. ordering against other units). Edit: of course, two booleans for this combines with wanting to retain a boolean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extra boolean isn't simpler for the implementation, but we should prioritize building intuitive directives for the test author. I think distinct flags help with that, but I'm okay with a three-valued enum if we can find sensible names for the values. I see how the arbitrary directive injection could be useful, but using it to override For completeness, I'll note a couple things. One is that an enum implies that there's only one dimension of hardening, and down the road we might find that we want to compose multiple hardening flags anyway. The other is that systemd has the sort of interlocking options you're arguing against. I have deadlines I need to focus on, so I'm muting this thread for now. I've tried to fully capture my constraints in #3060 (comment) (but |
||||
case "": | ||||
break | ||||
default: | ||||
return fmt.Errorf("test %v specifies unknown isolation=%v", testname, targetMeta.Isolation) | ||||
} | ||||
|
||||
if userdata == nil { | ||||
userdata = conf.EmptyIgnition() | ||||
} | ||||
|
||||
warningsAction := conf.FailWarnings | ||||
if targetMeta.AllowConfigWarnings { | ||||
warningsAction = conf.IgnoreWarnings | ||||
|
@@ -980,6 +999,16 @@ Environment=KOLA_TEST_EXE=%s | |||
Environment=%s=%s | ||||
ExecStart=%s | ||||
`, unitName, testname, base, kolaExtBinDataEnv, destDataDir, remotepath) | ||||
switch targetMeta.Isolation { | ||||
case "readonly": | ||||
unit += "ProtectSystem=strict\nPrivateTmp=yes\n" | ||||
case "dynamicuser": | ||||
unit += "DynamicUser=yes\n" | ||||
case "": | ||||
break | ||||
default: | ||||
return fmt.Errorf("test %v specifies unknown isolation=%v", testname, targetMeta.Isolation) | ||||
} | ||||
if targetMeta.InjectContainer { | ||||
if CosaBuild == nil { | ||||
return fmt.Errorf("test %v uses injectContainer, but no cosa build found", testname) | ||||
|
@@ -1091,7 +1120,7 @@ func registerTestDir(dir, testprefix string, children []os.FileInfo) error { | |||
var dependencydir string | ||||
var meta externalTestMeta | ||||
var err error | ||||
userdata := conf.EmptyIgnition() | ||||
var userdata *conf.UserData | ||||
executables := []string{} | ||||
for _, c := range children { | ||||
fpath := filepath.Join(dir, c.Name()) | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
# This verifies that isolation=dynamicuser maps to systemd DynamicUser=yes and | ||
# (unlike the default kola model) runs as non-root. | ||
# kola: { "isolation": "dynamicuser" } | ||
dustymabe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
set -xeuo pipefail | ||
|
||
id=$(id -u) | ||
test "$id" '!=' 0 | ||
echo "ok dynamicuser" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really think it's best if we don't rely on
exclusive: false
beingimplicit
anywhere. Tests can do things in their butane config that are exclusive and would/could cause other tests to fail.If you want an
isolation
anddynamicuser
flag that's OK I guess, but I really want to keepexlusive: false
explicit.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we could also enforce that such tests don't provide an ignition config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really opposed to also requiring an explicit
exclusive: false
as long as we don't force people to copy-paste the rationale for it 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now strengthened this to prevent the test from providing an Ignition config too!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did also test the testing framework manually:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you still will probably include a comment/rationale for
isolation: readonly
. I'm not really sure what you gain here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would I add a comment/rationale for that? Would you block coreos/fedora-coreos-config#1949 on that? If so I'm sorry I just disagree, it's self-evidently obvious and doesn't need a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem is that a lot of the configuration options here aren't self-evident especially to someone who didn't write the test and it's safer to just default to including a rationale for everything to make sure we catch the full context.
I agree with you that if you read the documentation on this one, and then you read the systemd documentation on that option, then it's clear: "this test is completely read-only and doesn't write to the filesystem at all", but that requires... work, we could just state it up front. It doesn't really cost us anything to help the user read/understand what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And.. the answer is "no", I'm not that dogmatic. I'd suggest it but if you firmly say "are you going to block this on that?" I wouldn't. Later on, though, if I ever touched the file I'd be like "hmm, wonder why these options aren't documented like all the others?" and I'd add it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I think we can continue a debate about the comment schema after landing this.