Skip to content
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

overlay.get: if we're ignoring metacopy=on, ignore it when it's global #1049

Merged
merged 1 commit into from
Nov 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions drivers/overlay/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ func hasMetacopyOption(opts []string) bool {
return false
}

func stripOption(opts []string, option string) []string {
for i, s := range opts {
if s == option {
return stripOption(append(opts[:i], opts[i+1:]...), option)
}
}
return opts
}

func hasVolatileOption(opts []string) bool {
for _, s := range opts {
if s == "volatile" {
Expand Down Expand Up @@ -1254,6 +1263,10 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
disableShifting = true
}

logLevel := logrus.WarnLevel
if unshare.IsRootless() {
logLevel = logrus.DebugLevel
}
optsList := options.Options
if len(optsList) == 0 {
optsList = strings.Split(d.options.mountOptions, ",")
Expand All @@ -1262,16 +1275,18 @@ func (d *Driver) get(id string, disableShifting bool, options graphdriver.MountO
// options otherwise the kernel refuses to follow the metacopy xattr.
if hasMetacopyOption(strings.Split(d.options.mountOptions, ",")) && !hasMetacopyOption(options.Options) {
if d.usingMetacopy {
logrus.StandardLogger().Logf(logLevel, "Adding metacopy option, configured globally")
optsList = append(optsList, "metacopy=on")
} else {
logLevel := logrus.WarnLevel
if unshare.IsRootless() {
logLevel = logrus.DebugLevel
}
logrus.StandardLogger().Logf(logLevel, "Ignoring metacopy option from storage.conf, not supported with booted kernel")
}
}
}
if !d.usingMetacopy {
if hasMetacopyOption(optsList) {
logrus.StandardLogger().Logf(logLevel, "Ignoring global metacopy option, not supported with booted kernel")
}
optsList = stripOption(optsList, "metacopy=on")
}

for _, o := range optsList {
if o == "ro" {
readWrite = false
Expand Down