-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Don't sort plugin mounts slice #36711
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
Conversation
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.
Just for my knowledge. How does the new test framework run on specific OSes? For example, how does it achieve the old DaemonIsLinux condition?
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.
This is handled here: https://github.com/moby/moby/pull/36711/files#diff-ead2a878e85c5d12126b9757bff4cf69R24
And yes I totally added that after you said something :)
Also removed this check (which was a copy/paste from logging) since we don't need it 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.
assert.NilError
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.
This is a copy-paste from the logging package... I don't know why it was changed to assert.Check... @dnephin ?
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 guess assert.Check just returns ok if the passed in value is nil. If it's not nil there's some switch on the type, and error types would fail the test.
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.
Yes, that's right. The automated migration converted testify/assert.NoError (which uses t.Fail()) to assert.Check() (which uses t.Fail()) because those have the equivalent behaviour. Checking errors with t.Fail() is generally going to be wrong and lead to a panic later in the test when something else is nil. So the original test was wrong to use testify/assert.NoError, and should have used testify/require.NoError.
gotestyourself/assert.NilError(t, err) is correct because it uses t.FailNow() and stops execution of the test.
I didn't fix every place that was using the wrong assertion, because there were many, but I tried to fix up a few.
75ba560 to
63501cc
Compare
Codecov Report
@@ Coverage Diff @@
## master #36711 +/- ##
=========================================
Coverage ? 34.96%
=========================================
Files ? 613
Lines ? 45556
Branches ? 0
=========================================
Hits ? 15928
Misses ? 27541
Partials ? 2087 |
63501cc to
4c550ef
Compare
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.
Would be nice to add a function comment about expectations:
"DummyPluginSrc at cmd/dummy
DummyPluginInstallPath at $GOPATH/bin/dummy"
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.
Not in this PR, but we should have a common set of helpers for all plugins, instead of duplicating code.
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.
What is this lock protecting?
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.
It makes sure that tests can run in parallel and that we only build a specific binary once.
plugin/v2/plugin_linux.go
Outdated
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.
For my clarification: So including the OCI defaults in the sort was overwriting the explicit /dev mounts from the plugin with the OCI defaults? Even so, how did it mess up the host /dev?
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.
Because it's adding things like a custom /dev/pts for the plugin, but if the host /dev is mounted in first this causes issues.
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.
Janky panicked due to test case where m.Source is nil.
| {Name: "pmount2", Settable: []string{"source"}, Type: "none"}, // Mount without source is invalid. |
Please check for m.Source != nil
4c550ef to
a8b4ddd
Compare
|
@cpuguy83 validation failures 😓 |
39315c2 to
fab5a51
Compare
This was added as part of a53930a with the intent to sort the mounts in the plugin config, but this was sorting *all* the mounts from the default OCI spec which is problematic. In reality we don't need to sort this because we are only adding a self-binded mount to flag it as rshared. We may want to look at sorting the plugin mounts before they are added to the OCI spec in the future, but for now I think the existing behavior is fine since the plugin author has control of the order (except for the propagated mount). Signed-off-by: Brian Goff <cpuguy83@gmail.com>
fab5a51 to
ec90839
Compare
|
LGTM |
vdemeester
left 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.
LGTM 🐯
This was added as part of a53930a with
the intent to sort the mounts in the plugin config, but this was sorting
all the mounts from the default OCI spec which is problematic.
In reality we don't need to sort this because we are only adding a
self-binded mount to flag it as rshared.
We may want to look at sorting the plugin mounts before they are added
to the OCI spec in the future, but for now I think the existing behavior
is fine since the plugin author has control of the order (except for the
propagated mount).
Fixes #36698