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>
This commit is contained in:
parent
aaee3ca6c1
commit
6ca20ec771
1 changed files with 8 additions and 1 deletions
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue