diff --git a/cmd/3ncryptor/3ncryptor.go b/cmd/3ncryptor/3ncryptor.go index 12a44da48..b2ab4ff10 100644 --- a/cmd/3ncryptor/3ncryptor.go +++ b/cmd/3ncryptor/3ncryptor.go @@ -73,7 +73,7 @@ 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 { @@ -81,6 +81,11 @@ func mountVol(vol *api.Volume, path string, secret string) error { 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() @@ -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 } }