Skip to content
This repository has been archived by the owner on Feb 8, 2021. It is now read-only.

Commit

Permalink
Add new option "cache" to container and volume
Browse files Browse the repository at this point in the history
Signed-off-by: Hui Zhu <teawater@hyper.sh>
  • Loading branch information
teawater committed Jul 23, 2018
1 parent fe3670a commit 2eb5d07
Show file tree
Hide file tree
Showing 6 changed files with 389 additions and 332 deletions.
7 changes: 7 additions & 0 deletions daemon/pod/container.go
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/hyperhq/hypercontainer-utils/hlog"
"github.com/hyperhq/hyperd/errors"
"github.com/hyperhq/hyperd/storage"
apitypes "github.com/hyperhq/hyperd/types"
"github.com/hyperhq/hyperd/utils"
runv "github.com/hyperhq/runv/api"
Expand Down Expand Up @@ -888,6 +889,12 @@ func (c *Container) addToSandbox() error {
c.Log(ERROR, "failed to prepare rootfs: %v", err)
return err
}
if root.Format != "vfs" && root.Format != "nas" {
root.Cache = c.spec.Cache
if root.Cache == "" {
root.Cache = storage.DEFAULT_VOL_CACHE
}
}
c.descript.RootVolume = root

c.Log(TRACE, "finished container prepare, wait for volumes")
Expand Down
5 changes: 5 additions & 0 deletions daemon/pod/mount.go
Expand Up @@ -39,6 +39,7 @@ func ProbeExistingVolume(v *apitypes.UserVolume, sharedDir string) (*runv.Volume
Source: v.Source,
Format: v.Format,
Fstype: v.Fstype,
Cache: v.Cache,
}

if v.Option != nil {
Expand All @@ -64,6 +65,10 @@ func ProbeExistingVolume(v *apitypes.UserVolume, sharedDir string) (*runv.Volume
}
}

if vol.Cache == "" && v.Format != "vfs" && v.Format != "nas" {
vol.Cache = storage.DEFAULT_VOL_CACHE
}

return vol, nil
}

Expand Down
1 change: 1 addition & 0 deletions storage/defaults.go
Expand Up @@ -8,4 +8,5 @@ const (
DEFAULT_DM_VOL_SIZE int = 2 * 1024 * 1024 * 1024
DEFAULT_VOL_FS = "ext4"
DEFAULT_VOL_MKFS = "mkfs.ext4"
DEFAULT_VOL_CACHE = "writeback"
)

0 comments on commit 2eb5d07

Please sign in to comment.