From 98392532335407f948ade593cb8cd777673600ec Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Mon, 25 May 2015 08:13:30 -0400 Subject: [PATCH] Add logging to volume tear-down to help understand mount behaviour --- pkg/util/mount/mount.go | 12 +++++++++--- pkg/volume/aws_ebs/aws_ebs.go | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pkg/util/mount/mount.go b/pkg/util/mount/mount.go index 9733f5a02eb..73311749b48 100644 --- a/pkg/util/mount/mount.go +++ b/pkg/util/mount/mount.go @@ -18,6 +18,8 @@ limitations under the License. // an alternate platform, we will need to abstract further. package mount +import "github.com/golang/glog" + type Interface interface { // Mount mounts source to target as fstype with given options. Mount(source string, target string, fstype string, options []string) error @@ -66,9 +68,13 @@ func GetMountRefs(mounter Interface, mountPath string) ([]string, error) { // Find all references to the device. var refs []string - for i := range mps { - if mps[i].Device == deviceName && mps[i].Path != mountPath { - refs = append(refs, mps[i].Path) + if deviceName == "" { + glog.Warningf("could not determine device for path: %s", mountPath) + } else { + for i := range mps { + if mps[i].Device == deviceName && mps[i].Path != mountPath { + refs = append(refs, mps[i].Path) + } } } return refs, nil diff --git a/pkg/volume/aws_ebs/aws_ebs.go b/pkg/volume/aws_ebs/aws_ebs.go index f276db68e31..b10ed14a422 100644 --- a/pkg/volume/aws_ebs/aws_ebs.go +++ b/pkg/volume/aws_ebs/aws_ebs.go @@ -289,6 +289,9 @@ func (pd *awsElasticBlockStore) TearDownAt(dir string) error { glog.V(2).Info("Error getting mountrefs for ", dir, ": ", err) return err } + if len(refs) == 0 { + glog.Warning("Did not find pod-mount for ", dir, " during tear-down") + } // Unmount the bind-mount inside this pod if err := pd.mounter.Unmount(dir); err != nil { glog.V(2).Info("Error unmounting dir ", dir, ": ", err) @@ -307,6 +310,8 @@ func (pd *awsElasticBlockStore) TearDownAt(dir string) error { glog.V(2).Info("Error detaching disk ", pd.volumeID, ": ", err) return err } + } else { + glog.V(2).Infof("Found multiple refs; won't detach EBS volume: %v", refs) } mountpoint, mntErr := pd.mounter.IsMountPoint(dir) if mntErr != nil {