Skip to content

Commit

Permalink
Manually unmount before detaching, shared volumes didn't like the unm…
Browse files Browse the repository at this point in the history
…ountbeforedetach param

Signed-off-by: Paul Theunis <[email protected]>
  • Loading branch information
Paul Theunis committed Jul 1, 2021
1 parent 7ec0444 commit 7d6fd40
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions cmd/3ncryptor/3ncryptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,19 @@ func attachVol(vol *api.Volume, options map[string]string) error {

func detachVol(vol *api.Volume, secret string) error {
vd := sdk.GetVolumeDriver()
return vd.Detach(vol.Id, map[string]string{options.OptionsUnmountBeforeDetach: "true"})
return vd.Detach(vol.Id, map[string]string{})
}

func mountVol(vol *api.Volume, path string, secret string) error {
vd := sdk.GetVolumeDriver()
return vd.Mount(vol.Id, path, nil)
}

func unmountVol(vol *api.Volume, dir string, secret string) error {
vd := sdk.GetVolumeDriver()
return vd.Unmount(vol.Id, dir, map[string]string{})
}

func createVol(locator *api.VolumeLocator, spec *api.VolumeSpec) (*api.Volume, error) {
vd := sdk.GetVolumeDriver()

Expand Down Expand Up @@ -516,16 +521,24 @@ func newEncryptCommand() *cobra.Command {

logrus.Infof("Detaching and unmounting snapshot: %v", snapVol.Locator.Name)
if !dryRun {
if err := unmountVol(snapVol, dir, enc_secret); err != nil {
logrus.Errorf("unmountVol failed to unmount snapshot %v with: %v", snapVol.Locator.Name, err)
}

if err := detachVol(snapVol, enc_secret); err != nil {
logrus.Errorf("detachVol failed to detach and unmount snapshot %v with: %v", snapVol.Locator.Name, err)
logrus.Errorf("detachVol failed to detach snapshot %v with: %v", snapVol.Locator.Name, err)
return
}
}

logrus.Infof("Detaching and unmounting encrypted volume: %v", encVol.Locator.Name)
if !dryRun {
if err := unmountVol(encVol, encDir, enc_secret); err != nil {
logrus.Errorf("unmountVol failed to unmount encrypted volume %v with: %v", snapVol.Locator.Name, err)
}

if err := detachVol(encVol, enc_secret); err != nil {
logrus.Errorf("detachVol failed to detach and unmount encrypted volume %v with: %v", encVol.Locator.Name, err)
logrus.Errorf("detachVol failed to detach encrypted volume %v with: %v", encVol.Locator.Name, err)
return
}
}
Expand Down

0 comments on commit 7d6fd40

Please sign in to comment.