From ba6ab902c968dde2ac135450806e57460a93e8ed Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 2 Jan 2017 14:15:46 +0100 Subject: [PATCH] gce: Reuse unsuccessfully provisioned volumes. GCE PD names generated by Kubernetes are guaranteed to be unique - they contain name of the cluster and UID of the PVC that is behind it. Presence of a GCE PD that has the same name as we want to provision indicates that previous provisioning did not go well and most probably the controller manager process was restarted in the meantime. Kubernetes should reuse this volume and not provision a new one. --- pkg/cloudprovider/providers/gce/gce.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/cloudprovider/providers/gce/gce.go b/pkg/cloudprovider/providers/gce/gce.go index bf430e51bd4..587f92758d5 100644 --- a/pkg/cloudprovider/providers/gce/gce.go +++ b/pkg/cloudprovider/providers/gce/gce.go @@ -2484,7 +2484,12 @@ func (gce *GCECloud) CreateDisk(name string, diskType string, zone string, sizeG return err } - return gce.waitForZoneOp(createOp, zone) + err = gce.waitForZoneOp(createOp, zone) + if isGCEError(err, "alreadyExists") { + glog.Warningf("GCE PD %q already exists, reusing", name) + return nil + } + return err } func (gce *GCECloud) doDeleteDisk(diskToDelete string) error {