Commit 6f7eac63 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #46315 from wongma7/gcepdalready

Automatic merge from submit-queue (batch tested with PRs 38505, 41785, 46315) Fix provisioned GCE PD not being reused if already exists @jsafrane PTAL This is another attempt at https://github.com/kubernetes/kubernetes/pull/38702 . We have observed that `gce.service.Disks.Insert(gce.projectID, zone, diskToCreate).Do()` instantly gets an error response of alreadyExists, so we must check for it. I am not sure if we still need to check for the error after `waitForZoneOp`; I think that if there is an alreadyExists error, the `Do()` above will always respond with it instantly. But because I'm not sure, and to be safe, I will leave it.
parents 70dd10cc 11cb36e9
...@@ -245,7 +245,10 @@ func (gce *GCECloud) CreateDisk( ...@@ -245,7 +245,10 @@ func (gce *GCECloud) CreateDisk(
mc := newDiskMetricContext("create", zone) mc := newDiskMetricContext("create", zone)
createOp, err := gce.service.Disks.Insert(gce.projectID, zone, diskToCreate).Do() createOp, err := gce.service.Disks.Insert(gce.projectID, zone, diskToCreate).Do()
if err != nil { if isGCEError(err, "alreadyExists") {
glog.Warningf("GCE PD %q already exists, reusing", name)
return nil
} else if err != nil {
return mc.Observe(err) return mc.Observe(err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment