mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
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.
This commit is contained in:
parent
900567288b
commit
1276675512
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user