More logging around error causes

Come back exceptions, all is forgiven!
This commit is contained in:
Justin Santa Barbara 2015-04-03 09:34:23 -07:00
parent a366f9ee88
commit f0cedd7375
2 changed files with 10 additions and 0 deletions

View File

@ -254,18 +254,22 @@ func (pd *awsPersistentDisk) TearDown() error {
func (pd *awsPersistentDisk) TearDownAt(dir string) error { func (pd *awsPersistentDisk) TearDownAt(dir string) error {
mountpoint, err := mount.IsMountPoint(dir) mountpoint, err := mount.IsMountPoint(dir)
if err != nil { if err != nil {
glog.V(2).Info("Error checking if mountpoint ", dir, ": ", err)
return err return err
} }
if !mountpoint { if !mountpoint {
glog.V(2).Info("Not mountpoint, deleting")
return os.Remove(dir) return os.Remove(dir)
} }
refs, err := mount.GetMountRefs(pd.mounter, dir) refs, err := mount.GetMountRefs(pd.mounter, dir)
if err != nil { if err != nil {
glog.V(2).Info("Error getting mountrefs for ", dir, ": ", err)
return err return err
} }
// Unmount the bind-mount inside this pod // Unmount the bind-mount inside this pod
if err := pd.mounter.Unmount(dir, 0); err != nil { if err := pd.mounter.Unmount(dir, 0); err != nil {
glog.V(2).Info("Error unmounting dir ", dir, ": ", err)
return err return err
} }
// If len(refs) is 1, then all bind mounts have been removed, and the // If len(refs) is 1, then all bind mounts have been removed, and the
@ -274,6 +278,7 @@ func (pd *awsPersistentDisk) TearDownAt(dir string) error {
// pd.pdName is not initially set for volume-cleaners, so set it here. // pd.pdName is not initially set for volume-cleaners, so set it here.
pd.pdName = path.Base(refs[0]) pd.pdName = path.Base(refs[0])
if err := pd.manager.DetachDisk(pd); err != nil { if err := pd.manager.DetachDisk(pd); err != nil {
glog.V(2).Info("Error detaching disk ", pd.pdName, ": ", err)
return err return err
} }
} }
@ -284,6 +289,7 @@ func (pd *awsPersistentDisk) TearDownAt(dir string) error {
} }
if !mountpoint { if !mountpoint {
if err := os.Remove(dir); err != nil { if err := os.Remove(dir); err != nil {
glog.V(2).Info("Error removing mountpoint ", dir, ": ", err)
return err return err
} }
} }

View File

@ -91,17 +91,21 @@ func (util *AWSDiskUtil) DetachDisk(pd *awsPersistentDisk) error {
// Unmount the global PD mount, which should be the only one. // Unmount the global PD mount, which should be the only one.
globalPDPath := makeGlobalPDName(pd.plugin.host, pd.pdName) globalPDPath := makeGlobalPDName(pd.plugin.host, pd.pdName)
if err := pd.mounter.Unmount(globalPDPath, 0); err != nil { if err := pd.mounter.Unmount(globalPDPath, 0); err != nil {
glog.V(2).Info("Error unmount dir ", globalPDPath, ": ", err)
return err return err
} }
if err := os.Remove(globalPDPath); err != nil { if err := os.Remove(globalPDPath); err != nil {
glog.V(2).Info("Error removing dir ", globalPDPath, ": ", err)
return err return err
} }
// Detach the disk // Detach the disk
volumes, err := pd.getVolumeProvider() volumes, err := pd.getVolumeProvider()
if err != nil { if err != nil {
glog.V(2).Info("Error getting volume provider for pd ", pd.pdName, ": ", err)
return err return err
} }
if err := volumes.DetachDisk("", pd.pdName); err != nil { if err := volumes.DetachDisk("", pd.pdName); err != nil {
glog.V(2).Info("Error detaching disk ", pd.pdName, ": ", err)
return err return err
} }
return nil return nil