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.
pull/6/head
Jan Safranek 2017-01-02 14:15:46 +01:00
parent dbb8bf5274
commit ba6ab902c9
1 changed files with 6 additions and 1 deletions

View File

@ -2484,7 +2484,12 @@ func (gce *GCECloud) CreateDisk(name string, diskType string, zone string, sizeG
return err 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 { func (gce *GCECloud) doDeleteDisk(diskToDelete string) error {