-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add support for overlay volatile option #8402
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
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 | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,7 @@ const upperdirKey = "containerd.io/snapshot/overlay.upperdir" | |||||||||||||||||||||||||||||||||||||||||||
| type SnapshotterConfig struct { | ||||||||||||||||||||||||||||||||||||||||||||
| asyncRemove bool | ||||||||||||||||||||||||||||||||||||||||||||
| upperdirLabel bool | ||||||||||||||||||||||||||||||||||||||||||||
| volatile bool | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Opt is an option to configure the overlay snapshotter | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -67,13 +68,21 @@ func WithUpperdirLabel(config *SnapshotterConfig) error { | |||||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // Volatile enables the volatile option of overlayfs to omit all | ||||||||||||||||||||||||||||||||||||||||||||
| // forms of sync calls to the upper layer filesystem. | ||||||||||||||||||||||||||||||||||||||||||||
| func Volatile(config *SnapshotterConfig) error { | ||||||||||||||||||||||||||||||||||||||||||||
| config.volatile = true | ||||||||||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| type snapshotter struct { | ||||||||||||||||||||||||||||||||||||||||||||
| root string | ||||||||||||||||||||||||||||||||||||||||||||
| ms *storage.MetaStore | ||||||||||||||||||||||||||||||||||||||||||||
| asyncRemove bool | ||||||||||||||||||||||||||||||||||||||||||||
| upperdirLabel bool | ||||||||||||||||||||||||||||||||||||||||||||
| indexOff bool | ||||||||||||||||||||||||||||||||||||||||||||
| userxattr bool // whether to enable "userxattr" mount option | ||||||||||||||||||||||||||||||||||||||||||||
| volatile bool | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -111,13 +120,21 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) { | |||||||||||||||||||||||||||||||||||||||||||
| logrus.WithError(err).Warnf("cannot detect whether \"userxattr\" option needs to be used, assuming to be %v", userxattr) | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| // check volatile option | ||||||||||||||||||||||||||||||||||||||||||||
| if config.volatile { | ||||||||||||||||||||||||||||||||||||||||||||
| if err := overlayutils.SupportsVolatileMount(root); err != nil { | ||||||||||||||||||||||||||||||||||||||||||||
| return nil, err | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| return &snapshotter{ | ||||||||||||||||||||||||||||||||||||||||||||
| root: root, | ||||||||||||||||||||||||||||||||||||||||||||
| ms: ms, | ||||||||||||||||||||||||||||||||||||||||||||
| asyncRemove: config.asyncRemove, | ||||||||||||||||||||||||||||||||||||||||||||
| upperdirLabel: config.upperdirLabel, | ||||||||||||||||||||||||||||||||||||||||||||
| indexOff: supportsIndex(), | ||||||||||||||||||||||||||||||||||||||||||||
| userxattr: userxattr, | ||||||||||||||||||||||||||||||||||||||||||||
| volatile: config.volatile, | ||||||||||||||||||||||||||||||||||||||||||||
| }, nil | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -464,6 +481,10 @@ func (o *snapshotter) mounts(s storage.Snapshot) []mount.Mount { | |||||||||||||||||||||||||||||||||||||||||||
| options = append(options, "userxattr") | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if o.volatile { | ||||||||||||||||||||||||||||||||||||||||||||
| options = append(options, "volatile") | ||||||||||||||||||||||||||||||||||||||||||||
|
Member
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. overlayfs snapshot is service and this option is global setting. I think there are existing cases which required the rootfs is synced after umount. Currently, the kubernetes container is temporary and we can't restart a exited container. kubernetes always recreates container for pod. So, I would like to add the I was thinking that we can go in this way: a. When the overlayfs snapshot inits, it use containerd/snapshots/overlay/plugin/plugin.go Lines 41 to 61 in e52fbfd
b. Add the mount option to add |
||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| if s.Kind == snapshots.KindActive { | ||||||||||||||||||||||||||||||||||||||||||||
| options = append(options, | ||||||||||||||||||||||||||||||||||||||||||||
| fmt.Sprintf("workdir=%s", o.workPath(s.ID)), | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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 don't think we should change the option here. If there is conflict, we should modify the option before call the
WithTempMount, for instance, https://github.com/containerd/containerd/pull/8259/files.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.
there are lots of calls to WithTempMount? should I create another function which modifies the options calls before calling WithTempMount then update those other calls to call the new function? Feels like pointless nesting maybe I am misunderstanding, would be helpful if that link has some line numbers :) ty
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 this is probably the right place to strip the option. Need to ensure the input mount array is not overwritten though.
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.
@natefive Sorry for late reply.
For my original comment, yes. But recently, I checked the code about starting container. It's unlikely to change the mount since there is no entrypoint for us to update it before passing to shim.
containerd/container.go
Lines 244 to 267 in b6abda7
I think we should introduce a label like #6528.
cc @dmcgowan