Skip to content

Do not error on relabel when relabel not supported#33831

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
cpuguy83:ignore_enotsup_on_relabel
Jun 29, 2017
Merged

Do not error on relabel when relabel not supported#33831
cpuguy83 merged 1 commit intomoby:masterfrom
cpuguy83:ignore_enotsup_on_relabel

Conversation

@cpuguy83
Copy link
Copy Markdown
Member

This is the same as https://github.com/moby/moby/tree/master/container/container_unix.go#L157
Using syscall here instead of x/sys/unix since this code path is run on both unix and windows.

Comment thread volume/volume.go
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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should this be moved into label.Relabel() or are there situations where ENOTSUP should be treated as an actual error here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's a very low level lib, best to have it preserve errors.

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.

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

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah Jun 29, 2017

Choose a reason for hiding this comment

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

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)
	}
}()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think that's best left as a separate PR though, to keep the diff of this PR small

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@boaz0 boaz0 left a comment

Choose a reason for hiding this comment

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

LGTM just small suggestion if it's fine with you. 👍

Copy link
Copy Markdown
Member

@vdemeester vdemeester 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.

5 participants