Modify according to comments

1. rename zoneSeparator to gkeZoneSeparator
2. add example of regional PV's node affinity. modify test case description.

Signed-off-by: Xun Jiang <jxun@vmware.com>
This commit is contained in:
Xun Jiang
2022-02-22 16:06:39 +08:00
parent 1506913f75
commit cfc6eef0a8
3 changed files with 18 additions and 3 deletions

View File

@@ -385,7 +385,7 @@ const (
awsEbsCsiZoneKey = "topology.ebs.csi.aws.com/zone"
azureCsiZoneKey = "topology.disk.csi.azure.com/zone"
gkeCsiZoneKey = "topology.gke.io/zone"
zoneSeparator = "__"
gkeZoneSeparator = "__"
)
// takePVSnapshot triggers a snapshot for the volume/disk underlying a PersistentVolume if the provided
@@ -560,7 +560,7 @@ func zoneFromPVNodeAffinity(res *corev1api.PersistentVolume, topologyKeys ...str
}
if providerGke {
return gkeCsiZoneKey, strings.Join(zones, zoneSeparator)
return gkeCsiZoneKey, strings.Join(zones, gkeZoneSeparator)
}
return "", ""

View File

@@ -132,7 +132,22 @@ func Test_zoneFromPVNodeAffinity(t *testing.T) {
wantValue: "us-central",
},
{
name: "Volume with multiple valid keys, and provider is gke, returns the all match", // it should never happen
/* an valid example of node affinity in a GKE's regional PV
nodeAffinity:
required:
nodeSelectorTerms:
- matchExpressions:
- key: topology.gke.io/zone
operator: In
values:
- us-central1-a
- matchExpressions:
- key: topology.gke.io/zone
operator: In
values:
- us-central1-c
*/
name: "Volume with multiple valid keys, and provider is gke, returns all valid entries's first zone value",
pv: builder.ForPersistentVolume("multi-matching-pv").NodeAffinityRequired(
builder.ForNodeSelector(
*builder.NewNodeSelectorTermBuilder().WithMatchExpression("topology.gke.io/zone",