فهرست منبع

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>
Kir Kolyshkin 8 سال پیش
والد
کامیت
6ca20ec771
1فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 8 1
      daemon/graphdriver/devmapper/device_setup.go

+ 8 - 1
daemon/graphdriver/devmapper/device_setup.go

@@ -172,6 +172,8 @@ func writeLVMConfig(root string, cfg directLVMConfig) error {
 }
 }
 
 
 func setupDirectLVM(cfg directLVMConfig) error {
 func setupDirectLVM(cfg directLVMConfig) error {
+	lvmProfileDir := "/etc/lvm/profile"
+
 	pvCreate, err := exec.LookPath("pvcreate")
 	pvCreate, err := exec.LookPath("pvcreate")
 	if err != nil {
 	if err != nil {
 		return errors.Wrap(err, "error looking up command `pvcreate` while setting up direct lvm")
 		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")
 		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 {
 	if cfg.AutoExtendPercent == 0 {
 		cfg.AutoExtendPercent = 20
 		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)
 	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 {
 	if err != nil {
 		return errors.Wrap(err, "error writing docker thinp autoextend profile")
 		return errors.Wrap(err, "error writing docker thinp autoextend profile")
 	}
 	}