devmapper autoconfig: add mkdir
I tried using dm.directlvm_device but it ended up with the following error: > Error starting daemon: error initializing graphdriver: error > writing docker thinp autoextend profile: open > /etc/lvm/profile/docker-thinpool.profile: no such file or directory The reason is /etc/lvm/profile directory does not exist. I think it is better to try creating it beforehand. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com> Upstream-commit: 6ca20ec771ab7c0ebf64c20021ca795746cf3ccb Component: engine
This commit is contained in:
@ -172,6 +172,8 @@ func writeLVMConfig(root string, cfg directLVMConfig) error {
|
||||
}
|
||||
|
||||
func setupDirectLVM(cfg directLVMConfig) error {
|
||||
lvmProfileDir := "/etc/lvm/profile"
|
||||
|
||||
pvCreate, err := exec.LookPath("pvcreate")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error looking up command `pvcreate` while setting up direct lvm")
|
||||
@ -197,6 +199,11 @@ func setupDirectLVM(cfg directLVMConfig) error {
|
||||
return errors.Wrap(err, "error looking up command `lvchange` while setting up direct lvm")
|
||||
}
|
||||
|
||||
err = os.MkdirAll(lvmProfileDir, 0755)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error creating lvm profile directory")
|
||||
}
|
||||
|
||||
if cfg.AutoExtendPercent == 0 {
|
||||
cfg.AutoExtendPercent = 20
|
||||
}
|
||||
@ -237,7 +244,7 @@ func setupDirectLVM(cfg directLVMConfig) error {
|
||||
}
|
||||
|
||||
profile := fmt.Sprintf("activation{\nthin_pool_autoextend_threshold=%d\nthin_pool_autoextend_percent=%d\n}", cfg.AutoExtendThreshold, cfg.AutoExtendPercent)
|
||||
err = ioutil.WriteFile("/etc/lvm/profile/docker-thinpool.profile", []byte(profile), 0600)
|
||||
err = ioutil.WriteFile(lvmProfileDir+"/docker-thinpool.profile", []byte(profile), 0600)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error writing docker thinp autoextend profile")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user