Misc fixes for devmapper
| ... | ... |
@@ -172,29 +172,18 @@ func writeLVMConfig(root string, cfg directLVMConfig) error {
|
| 172 | 172 |
} |
| 173 | 173 |
|
| 174 | 174 |
func setupDirectLVM(cfg directLVMConfig) error {
|
| 175 |
- pvCreate, err := exec.LookPath("pvcreate")
|
|
| 176 |
- if err != nil {
|
|
| 177 |
- return errors.Wrap(err, "error looking up command `pvcreate` while setting up direct lvm") |
|
| 178 |
- } |
|
| 179 |
- |
|
| 180 |
- vgCreate, err := exec.LookPath("vgcreate")
|
|
| 181 |
- if err != nil {
|
|
| 182 |
- return errors.Wrap(err, "error looking up command `vgcreate` while setting up direct lvm") |
|
| 183 |
- } |
|
| 175 |
+ lvmProfileDir := "/etc/lvm/profile" |
|
| 176 |
+ binaries := []string{"pvcreate", "vgcreate", "lvcreate", "lvconvert", "lvchange", "thin_check"}
|
|
| 184 | 177 |
|
| 185 |
- lvCreate, err := exec.LookPath("lvcreate")
|
|
| 186 |
- if err != nil {
|
|
| 187 |
- return errors.Wrap(err, "error looking up command `lvcreate` while setting up direct lvm") |
|
| 188 |
- } |
|
| 189 |
- |
|
| 190 |
- lvConvert, err := exec.LookPath("lvconvert")
|
|
| 191 |
- if err != nil {
|
|
| 192 |
- return errors.Wrap(err, "error looking up command `lvconvert` while setting up direct lvm") |
|
| 178 |
+ for _, bin := range binaries {
|
|
| 179 |
+ if _, err := exec.LookPath(bin); err != nil {
|
|
| 180 |
+ return errors.Wrap(err, "error looking up command `"+bin+"` while setting up direct lvm") |
|
| 181 |
+ } |
|
| 193 | 182 |
} |
| 194 | 183 |
|
| 195 |
- lvChange, err := exec.LookPath("lvchange")
|
|
| 184 |
+ err := os.MkdirAll(lvmProfileDir, 0755) |
|
| 196 | 185 |
if err != nil {
|
| 197 |
- return errors.Wrap(err, "error looking up command `lvchange` while setting up direct lvm") |
|
| 186 |
+ return errors.Wrap(err, "error creating lvm profile directory") |
|
| 198 | 187 |
} |
| 199 | 188 |
|
| 200 | 189 |
if cfg.AutoExtendPercent == 0 {
|
| ... | ... |
@@ -212,36 +201,36 @@ func setupDirectLVM(cfg directLVMConfig) error {
|
| 212 | 212 |
cfg.ThinpMetaPercent = 1 |
| 213 | 213 |
} |
| 214 | 214 |
|
| 215 |
- out, err := exec.Command(pvCreate, "-f", cfg.Device).CombinedOutput() |
|
| 215 |
+ out, err := exec.Command("pvcreate", "-f", cfg.Device).CombinedOutput()
|
|
| 216 | 216 |
if err != nil {
|
| 217 | 217 |
return errors.Wrap(err, string(out)) |
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 |
- out, err = exec.Command(vgCreate, "docker", cfg.Device).CombinedOutput() |
|
| 220 |
+ out, err = exec.Command("vgcreate", "docker", cfg.Device).CombinedOutput()
|
|
| 221 | 221 |
if err != nil {
|
| 222 | 222 |
return errors.Wrap(err, string(out)) |
| 223 | 223 |
} |
| 224 | 224 |
|
| 225 |
- out, err = exec.Command(lvCreate, "--wipesignatures", "y", "-n", "thinpool", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpPercent)).CombinedOutput()
|
|
| 225 |
+ out, err = exec.Command("lvcreate", "--wipesignatures", "y", "-n", "thinpool", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpPercent)).CombinedOutput()
|
|
| 226 | 226 |
if err != nil {
|
| 227 | 227 |
return errors.Wrap(err, string(out)) |
| 228 | 228 |
} |
| 229 |
- out, err = exec.Command(lvCreate, "--wipesignatures", "y", "-n", "thinpoolmeta", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpMetaPercent)).CombinedOutput()
|
|
| 229 |
+ out, err = exec.Command("lvcreate", "--wipesignatures", "y", "-n", "thinpoolmeta", "docker", "--extents", fmt.Sprintf("%d%%VG", cfg.ThinpMetaPercent)).CombinedOutput()
|
|
| 230 | 230 |
if err != nil {
|
| 231 | 231 |
return errors.Wrap(err, string(out)) |
| 232 | 232 |
} |
| 233 | 233 |
|
| 234 |
- out, err = exec.Command(lvConvert, "-y", "--zero", "n", "-c", "512K", "--thinpool", "docker/thinpool", "--poolmetadata", "docker/thinpoolmeta").CombinedOutput() |
|
| 234 |
+ out, err = exec.Command("lvconvert", "-y", "--zero", "n", "-c", "512K", "--thinpool", "docker/thinpool", "--poolmetadata", "docker/thinpoolmeta").CombinedOutput()
|
|
| 235 | 235 |
if err != nil {
|
| 236 | 236 |
return errors.Wrap(err, string(out)) |
| 237 | 237 |
} |
| 238 | 238 |
|
| 239 | 239 |
profile := fmt.Sprintf("activation{\nthin_pool_autoextend_threshold=%d\nthin_pool_autoextend_percent=%d\n}", cfg.AutoExtendThreshold, cfg.AutoExtendPercent)
|
| 240 |
- err = ioutil.WriteFile("/etc/lvm/profile/docker-thinpool.profile", []byte(profile), 0600)
|
|
| 240 |
+ err = ioutil.WriteFile(lvmProfileDir+"/docker-thinpool.profile", []byte(profile), 0600) |
|
| 241 | 241 |
if err != nil {
|
| 242 | 242 |
return errors.Wrap(err, "error writing docker thinp autoextend profile") |
| 243 | 243 |
} |
| 244 | 244 |
|
| 245 |
- out, err = exec.Command(lvChange, "--metadataprofile", "docker-thinpool", "docker/thinpool").CombinedOutput() |
|
| 245 |
+ out, err = exec.Command("lvchange", "--metadataprofile", "docker-thinpool", "docker/thinpool").CombinedOutput()
|
|
| 246 | 246 |
return errors.Wrap(err, string(out)) |
| 247 | 247 |
} |
| ... | ... |
@@ -1860,7 +1860,7 @@ func (devices *DeviceSet) initDevmapper(doInit bool) (retErr error) {
|
| 1860 | 1860 |
|
| 1861 | 1861 |
if devices.thinPoolDevice == "" {
|
| 1862 | 1862 |
if devices.metadataLoopFile != "" || devices.dataLoopFile != "" {
|
| 1863 |
- logrus.Warn("devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section.")
|
|
| 1863 |
+ logrus.Warn("devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man dockerd` to refer to dm.thinpooldev section.")
|
|
| 1864 | 1864 |
} |
| 1865 | 1865 |
} |
| 1866 | 1866 |
|