t.Errorf("Provision() returned unexpected value for %s: %v",kubeletapis.LabelZoneFailureDomain,persistentSpec.Labels[kubeletapis.LabelZoneFailureDomain])
return"",fmt.Errorf("both zone and zones StorageClass parameters must not be used at the same time")
returnnil,fmt.Errorf("both zone and zones StorageClass parameters must not be used at the same time")
}
// pick zone from node if present
varzoneFromNodestring
// pick one zone from node if present
ifnode!=nil{
// DynamicProvisioningScheduling implicit since node is not nil
ifzoneParameterPresent||zonesParameterPresent{
return"",fmt.Errorf("zone[s] cannot be specified in StorageClass if VolumeBindingMode is set to WaitForFirstConsumer. Please specify allowedTopologies in StorageClass for constraining zones.")
returnnil,fmt.Errorf("zone[s] cannot be specified in StorageClass if VolumeBindingMode is set to WaitForFirstConsumer. Please specify allowedTopologies in StorageClass for constraining zones")
}
// pick node's zone and ignore any allowedTopologies (since scheduler is assumed to have accounted for it already)
return"",fmt.Errorf("no matchLabelExpressions with %s key found in allowedTopologies. Please specify matchLabelExpressions with %s key",kubeletapis.LabelZoneFailureDomain,kubeletapis.LabelZoneFailureDomain)
returnnil,fmt.Errorf("no matchLabelExpressions with %s key found in allowedTopologies. Please specify matchLabelExpressions with %s key",kubeletapis.LabelZoneFailureDomain,kubeletapis.LabelZoneFailureDomain)
}
ifallowedZones.Len()>0{
// DynamicProvisioningScheduling implicit since allowedZones present
ifzoneParameterPresent||zonesParameterPresent{
return"",fmt.Errorf("zone[s] cannot be specified in StorageClass if allowedTopologies specified")
returnnil,fmt.Errorf("zone[s] cannot be specified in StorageClass if allowedTopologies specified")
}
// scheduler will guarantee if node != null above, zoneFromNode is member of allowedZones.
// so if zoneFromNode != "", we can safely assume it is part of allowedZones.
returnnil,fmt.Errorf("zone cannot be specified if desired number of replicas for pv is greather than 1. Please specify zones or allowedTopologies to specify desired zones")
returnnil,fmt.Errorf("not enough zones found in zones parameter to provision a volume with %d replicas. Found %d zones, need %d zones",numReplicas,zonesParameter.Len(),numReplicas)
}
// directly choose from zones parameter; no zone from node need to be considered
returnnil,fmt.Errorf("invalid number of replicas passed")
}
ifuint32(zones.Len())<numReplicas{
returnnil,fmt.Errorf("not enough zones found to provision a volume with %d replicas. Need at least %d distinct zones for a volume with %d replicas",numReplicas,numReplicas,numReplicas)
}
ifzoneToInclude!=""&&!zones.Has(zoneToInclude){
returnnil,fmt.Errorf("zone to be included: %s needs to be member of set: %v",zoneToInclude,zones)