Do not error on relabel when relabel not supported#33831
Merged
cpuguy83 merged 1 commit intomoby:masterfrom Jun 29, 2017
Merged
Do not error on relabel when relabel not supported#33831cpuguy83 merged 1 commit intomoby:masterfrom
cpuguy83 merged 1 commit intomoby:masterfrom
Conversation
Signed-off-by: Brian Goff <[email protected]>
thaJeztah
reviewed
Jun 27, 2017
| if err == nil { | ||
| if label.RelabelNeeded(m.Mode) { | ||
| if err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil { | ||
| if err == syscall.ENOTSUP { |
Member
There was a problem hiding this comment.
Should this be moved into label.Relabel() or are there situations where ENOTSUP should be treated as an actual error here?
Member
Author
There was a problem hiding this comment.
It's a very low level lib, best to have it preserve errors.
Contributor
There was a problem hiding this comment.
small suggestion: can we avoid the nesting using switch?
For example:
err = label.Relabel(m.Source, mountLabel, ...)
switch(err) {
case nil:
case syscall.ENOTSUP:
...
default:
...
}
return
Member
There was a problem hiding this comment.
Not fond on the switch, but nesting can be improved indeed; perhaps something like this?
defer func() {
if err != nil {
return
}
if !label.RelabelNeeded(m.Mode) {
return
}
if err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
if err == syscall.ENOTSUP {
err = nil
return
}
path = ""
err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source)
}
}()
Member
There was a problem hiding this comment.
I think that's best left as a separate PR though, to keep the diff of this PR small
boaz0
reviewed
Jun 28, 2017
Contributor
boaz0
left a comment
There was a problem hiding this comment.
LGTM just small suggestion if it's fine with you. 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the same as https://github.com/moby/moby/tree/master/container/container_unix.go#L157
Using syscall here instead of
x/sys/unixsince this code path is run on both unix and windows.