Skip to content

Commit 05b04a1

Browse files
qiutongsthaJeztah
authored andcommitted
Make the temp mount as ready only in container WithVolumes
Signed-off-by: Qiutong Song <[email protected]> (cherry picked from commit ec90efb) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3df54a8 commit 05b04a1

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
@@ -66,6 +66,12 @@ func WithVolumes(volumeMounts map[string]string) containerd.NewContainerOpts {
6666
if err != nil {
6767
return err
6868
}
69+
// Since only read is needed, append ReadOnly mount option to prevent linux kernel
70+
// from syncing whole filesystem in umount syscall.
71+
if len(mounts) == 1 && mounts[0].Type == "overlay" {
72+
mounts[0].Options = append(mounts[0].Options, "ro")
73+
}
74+
6975
root, err := ioutil.TempDir("", "ctd-volume")
7076
if err != nil {
7177
return err

0 commit comments

Comments
 (0)