Skip to content

Commit ec90efb

Browse files
committed
Make the temp mount as ready only in container WithVolumes
Signed-off-by: Qiutong Song <[email protected]>
1 parent 5247172 commit ec90efb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

pkg/cri/opts/container.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
6969
if err != nil {
7070
return err
7171
}
72+
// Since only read is needed, append ReadOnly mount option to prevent linux kernel
73+
// from syncing whole filesystem in umount syscall.
74+
if len(mounts) == 1 && mounts[0].Type == "overlay" {
75+
mounts[0].Options = append(mounts[0].Options, "ro")
76+
}
77+
7278
root, err := os.MkdirTemp("", "ctd-volume")
7379
if err != nil {
7480
return err

0 commit comments

Comments
 (0)