Add the key for GKE zone for AZ collection

Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
Daniel Jiang
2021-11-20 15:58:31 +08:00
parent 11abff4e8d
commit 748cf86aa7
3 changed files with 16 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
Add the key for GKE zone for AZ collection
+2 -1
View File
@@ -401,6 +401,7 @@ const (
awsEbsCsiZoneKey = "topology.ebs.csi.aws.com/zone"
azureCsiZoneKey = "topology.disk.csi.azure.com/zone"
gkeCsiZoneKey = "topology.gke.io/zone"
)
// takePVSnapshot triggers a snapshot for the volume/disk underlying a PersistentVolume if the provided
@@ -439,7 +440,7 @@ func (ib *itemBackupper) takePVSnapshot(obj runtime.Unstructured, log logrus.Fie
if !labelFound {
var k string
log.Infof("label %q is not present on PersistentVolume", zoneLabelDeprecated)
k, pvFailureDomainZone = zoneFromPVNodeAffinity(pv, awsEbsCsiZoneKey, azureCsiZoneKey, zoneLabel, zoneLabelDeprecated)
k, pvFailureDomainZone = zoneFromPVNodeAffinity(pv, awsEbsCsiZoneKey, azureCsiZoneKey, gkeCsiZoneKey, zoneLabel, zoneLabelDeprecated)
if pvFailureDomainZone != "" {
log.Infof("zone info from nodeAffinity requirements: %s, key: %s", pvFailureDomainZone, k)
} else {
+13
View File
@@ -51,7 +51,9 @@ func Test_zoneFromPVNodeAffinity(t *testing.T) {
keys := []string{
awsEbsCsiZoneKey,
azureCsiZoneKey,
gkeCsiZoneKey,
zoneLabel,
zoneLabelDeprecated,
}
tests := []struct {
name string
@@ -81,6 +83,17 @@ func Test_zoneFromPVNodeAffinity(t *testing.T) {
wantKey: "topology.disk.csi.azure.com/zone",
wantValue: "us-central",
},
{
name: "GCP CSI Volume",
pv: builder.ForPersistentVolume("gcpcsi").NodeAffinityRequired(
builder.ForNodeSelector(
*builder.NewNodeSelectorTermBuilder().WithMatchExpression("topology.gke.io/zone",
"In", "us-west1-a").Result(),
).Result(),
).Result(),
wantKey: "topology.gke.io/zone",
wantValue: "us-west1-a",
},
{
name: "AWS CSI Volume with multiple zone value, returns the first",
pv: builder.ForPersistentVolume("awscsi").NodeAffinityRequired(