Correctly handle migrations to a VHD setup

This commit is contained in:
Dane Everitt
2021-07-04 12:25:38 -07:00
committed by DaneEveritt
parent 265f8a6b39
commit d8a7bf2dde
4 changed files with 14 additions and 13 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"os"
"os/exec"
"path"
"strings"
"emperror.dev/errors"
@@ -182,6 +183,10 @@ func (d *Disk) Allocate(ctx context.Context) error {
} else if err != nil {
return errors.Wrap(err, "vhd: failed to check for existence of root disk")
}
trim := path.Base(d.diskPath)
if err := os.MkdirAll(strings.TrimSuffix(d.diskPath, trim), 0600); err != nil {
return errors.Wrap(err, "vhd: failed to create base vhd disk directory")
}
// We use 1024 as the multiplier for all of the disk space logic within the
// application. Passing "K" (/1024) is the same as "KiB" for fallocate, but
// is different than "KB" (/1000).