From 1276675512f2289824e27057cd901a2c99df141f Mon Sep 17 00:00:00 2001 From: Justin Santa Barbara Date: Fri, 22 Jan 2016 12:22:55 -0500 Subject: [PATCH] Ubernetes-Lite: Error if a PD name is ambiguous We don't cope well if a PD is in multiple zones, but this is actually fairly easy to detect. This is probably justified purely on the basis that we never want to delete the wrong volume (DeleteDisk), but also because this means that we now warn on creation if a disk is in multiple zones (with the labeling admission controller). This also means that with the scheduling predicate in place, that many of our volume problems "go away" in practice: you still can't create or delete a volume when it is ambiguous, but thereafter the volume will be labeled with the zone, that will match it only to nodes with the same zone, and then we query for the volume in that zone when we attach/detach it. --- pkg/cloudprovider/providers/gce/gce.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/cloudprovider/providers/gce/gce.go b/pkg/cloudprovider/providers/gce/gce.go index 8ce4b960e86..9da69182411 100644 --- a/pkg/cloudprovider/providers/gce/gce.go +++ b/pkg/cloudprovider/providers/gce/gce.go @@ -1764,14 +1764,20 @@ func (gce *GCECloud) getDiskByNameUnknownZone(diskName string) (*gceDisk, error) // "us-central1-a/mydisk". We could do this for them as part of // admission control, but that might be a little weird (values changing // on create) + + var found *gceDisk for _, zone := range gce.managedZones { disk, err := gce.findDiskByName(diskName, zone) if err != nil { return nil, err } - if disk != nil { - return disk, nil + if found != nil { + return nil, fmt.Errorf("GCE persistent disk name was found in multiple zones: %q", diskName) } + found = disk + } + if found != nil { + return found, nil } return nil, fmt.Errorf("GCE persistent disk not found: %q", diskName) }