-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Overlay size option: --overlay2=all:memory,size=1g #11723
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
base: master
Are you sure you want to change the base?
Conversation
c25a5c4
to
10ff226
Compare
Changed syntax from
to
|
9642db8
to
d7cb29a
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.
Please see the discussion in #11504. I'd prefer not to complicate the --overlay2
flag any further. If you really want to use memory backend via --overlay2=*:memory
, then consider applying memory limits to the entire container. OR try using the file backend with self
medium and setting up size limits on the host rootfs directory.
runsc/boot/vfs.go
Outdated
@@ -585,6 +585,12 @@ func (c *containerMounter) configureOverlay(ctx context.Context, conf *config.Co | |||
// filesystem specific options. | |||
upperOpts := *lowerOpts | |||
upperOpts.GetFilesystemOptions = vfs.GetFilesystemOptions{InternalMount: true} | |||
if conf.GetOverlay2().Size() != "" { |
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.
In gVisor, the overlay can be configured in many scenarios:
- Via --overlay2 flag for rootfs or even bind mounts.
- For specific bind mounts using mount annotations
See
gvisor/runsc/container/container.go
Line 939 in d30c58e
func (c *Container) initGoferConfs(ovlConf config.Overlay2, mountHints *boot.PodMountHints, rootfsHint *boot.RootfsHint) error { |
So applying the size limit to every overlay in the sandbox based on --overlay2 flag is incorrect.
(deleted wrong comments; let me think) |
New version where overlay size is passed in |
if upperOpts.GetFilesystemOptions.Data != "" { | ||
upperOpts.GetFilesystemOptions.Data += "," | ||
} |
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 guaranteed to be false right? Since we just initialized upperOpts.GetFilesystemOptions
on line 587 above.
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. I added here so that next time someone will add another option here or above, they won't forget to add a comma. I can revert.
@@ -939,6 +939,7 @@ func createGoferConf(overlayMedium config.OverlayMedium, mountType string, mount | |||
func (c *Container) initGoferConfs(ovlConf config.Overlay2, mountHints *boot.PodMountHints, rootfsHint *boot.RootfsHint) error { | |||
// Handle root mount first. | |||
overlayMedium := ovlConf.RootOverlayMedium() | |||
overlaySize := ovlConf.RootOverlaySize() | |||
mountType := boot.Bind | |||
if rootfsHint != nil { |
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 similar reasons as mentioned below, if rootfs is being configured by the rootfs annotations (rootfsHint != nil), then overlaySize should be reset.
Also, I think we should extend the rootfs annotation to include specifying size:
gvisor/runsc/boot/mount_hints.go
Line 230 in d19c3bc
// RootfsHint represents extra information about rootfs that are provided via |
Maybe dev.gvisor.spec.rootfs.options
which has value like size=...
. Later we can extend this to support more tmpfs options if need be.
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.
Added the option.
"annotations": {
"dev.gvisor.spec.rootfs.type": "bind",
"dev.gvisor.spec.rootfs.source": "/",
"dev.gvisor.spec.rootfs.overlay": "memory",
"dev.gvisor.spec.rootfs.options": "size=1m"
}
Next version ready for review. |
Implement #11504.
Add optional
size=
parameter to--overlay2
flag: when it is set, overlay upper layer is mounted with given size flag.Tested: