Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detach the PD disk from the VM in some failure cases. #3845

Merged
merged 1 commit into from
Jan 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/kubelet/volume/gce_pd/gce_pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ type gcePersistentDisk struct {
legacyMode bool
}

func detachDiskLogError(pd *gcePersistentDisk) {
err := pd.manager.DetachDisk(pd, "/dev/disk/by-id/google-"+pd.pdName)
if err != nil {
glog.Warningf("Failed to detach disk: %v (%v)", pd, err)
}
}

// SetUp attaches the disk and bind mounts to the volume path.
func (pd *gcePersistentDisk) SetUp() error {
if pd.legacyMode {
Expand Down Expand Up @@ -178,6 +185,8 @@ func (pd *gcePersistentDisk) SetUp() error {

volPath := pd.GetPath()
if err := os.MkdirAll(volPath, 0750); err != nil {
// TODO: we should really eject the attach/detach out into its own control loop.
detachDiskLogError(pd)
return err
}

Expand All @@ -186,6 +195,8 @@ func (pd *gcePersistentDisk) SetUp() error {
err = pd.mounter.Mount(globalPDPath, pd.GetPath(), "", mount.FlagBind|flags, "")
if err != nil {
os.RemoveAll(pd.GetPath())
// TODO: we should really eject the attach/detach out into its own control loop.
detachDiskLogError(pd)
return err
}

Expand Down