Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Commit

Permalink
Modify logic to determine stretch supervisor (#3021)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvrahav authored Jul 26, 2022
1 parent 9813bd4 commit 3e9c9f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
12 changes: 3 additions & 9 deletions addons/controllers/csi/vspherecsiconfig_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,17 +380,11 @@ func (r *VSphereCSIConfigReconciler) isStretchedSupervisorCluster(ctx context.Co
return false, err
}

if len(azList.Items) == 0 {
if len(azList.Items) <= 1 {
// by default every non-stretched cluster contains a single zone,
// if there is only one AZ we assume it is non-stretched cluster
return false, nil
}

if len(azList.Items) == 1 {
// by default every cluster contains legacy availability zone,
// if only the legacy AZ is present, return false
if azList.Items[0].Name == LegacyZoneName {
return false, nil
}
}

return true, nil
}
16 changes: 12 additions & 4 deletions addons/controllers/vspherecsiconfig_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,26 +274,34 @@ var _ = Describe("VSphereCSIConfig Reconciler", func() {
})

Context("reconcile VSphereCSIConfig manifests in paravirtual mode", func() {
var availabilityZone *topologyv1alpha1.AvailabilityZone
var availabilityZone1, availabilityZone2 *topologyv1alpha1.AvailabilityZone
BeforeEach(func() {
// (deliberate decision): There is no watch on AvailabilityZone in vspherecsiconfig_controller so any change to it will not trigger reconcile
// of resources. Based on discussions with TKGS team, availability zone is created at supervisor cluster init time
// and does not really change after that. The test will only check for the presence of non legacy availability
// zone and set zone to true
availabilityZone = &topologyv1alpha1.AvailabilityZone{
availabilityZone1 = &topologyv1alpha1.AvailabilityZone{
ObjectMeta: metav1.ObjectMeta{
Name: "test-az",
},
}

Expect(k8sClient.Create(ctx, availabilityZone)).Should(Succeed())
availabilityZone2 = &topologyv1alpha1.AvailabilityZone{
ObjectMeta: metav1.ObjectMeta{
Name: "test-az-2",
},
}

Expect(k8sClient.Create(ctx, availabilityZone1)).Should(Succeed())
Expect(k8sClient.Create(ctx, availabilityZone2)).Should(Succeed())
clusterName = "test-cluster-pv-csi"
clusterResourceFilePath = "testdata/test-vsphere-csi-paravirtual.yaml"
enduringResourcesFilePath = "testdata/vmware-csi-system-ns.yaml"
})

AfterEach(func() {
Expect(k8sClient.Delete(ctx, availabilityZone)).Should(Succeed())
Expect(k8sClient.Delete(ctx, availabilityZone1)).Should(Succeed())
Expect(k8sClient.Delete(ctx, availabilityZone2)).Should(Succeed())
})

It("Should reconcile VSphereCSIConfig and create data values secret for VSphereCSIConfig on management cluster", func() {
Expand Down

0 comments on commit 3e9c9f2

Please sign in to comment.