Skip to content

Commit 45209b7

Browse files
committed
fixes
1 parent ef06f15 commit 45209b7

File tree

6 files changed

+15
-3
lines changed

6 files changed

+15
-3
lines changed

controllers/clustermodule_reconciler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ func (r Reconciler) fetchMachineOwnerObjects(ctx context.Context, clusterCtx *ca
300300
}
301301
}
302302

303-
mdList := &clusterv1beta1.MachineDeploymentList{}
303+
mdList := &clusterv1.MachineDeploymentList{}
304304
if err := r.Client.List(
305305
ctx, mdList,
306306
client.InNamespace(clusterCtx.VSphereCluster.GetNamespace()),

controllers/vspheremachine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (r *machineReconciler) reconcileNormal(ctx context.Context, machineCtx capv
396396
// 2) If the Cluster is supervisor-based continue to reconcile as InfrastructureProvisioned is not set to true until after the kube apiserver is available.
397397
if !r.supervisorBased {
398398
// vmwarev1.VSphereCluster doesn't set Cluster.Status.Ready until the API endpoint is available.
399-
if !machineCtx.GetCluster().Status.Initialization.InfrastructureProvisioned {
399+
if machineCtx.GetCluster().Status.Initialization == nil || !machineCtx.GetCluster().Status.Initialization.InfrastructureProvisioned {
400400
log.Info("Cluster infrastructure is not ready yet, skipping reconciliation")
401401
deprecatedconditions.MarkFalse(machineCtx.GetVSphereMachine(), infrav1.VMProvisionedCondition, infrav1.WaitingForClusterInfrastructureReason, clusterv1beta1.ConditionSeverityInfo, "")
402402
deprecatedv1beta2conditions.Set(machineCtx.GetVSphereMachine(), metav1.Condition{

controllers/vspheremachine_controller_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ var _ = Describe("VsphereMachineReconciler", func() {
165165
Eventually(func() error {
166166
ph, err := patch.NewHelper(capiCluster, testEnv)
167167
Expect(err).ShouldNot(HaveOccurred())
168+
if capiCluster.Status.Initialization == nil {
169+
capiCluster.Status.Initialization = &clusterv1.ClusterInitializationStatus{}
170+
}
168171
capiCluster.Status.Initialization.InfrastructureProvisioned = true
169172
return ph.Patch(ctx, capiCluster, patch.WithStatusObservedGeneration{})
170173
}, timeout).Should(Succeed())
@@ -178,6 +181,9 @@ var _ = Describe("VsphereMachineReconciler", func() {
178181
BeforeEach(func() {
179182
ph, err := patch.NewHelper(capiCluster, testEnv)
180183
Expect(err).ShouldNot(HaveOccurred())
184+
if capiCluster.Status.Initialization == nil {
185+
capiCluster.Status.Initialization = &clusterv1.ClusterInitializationStatus{}
186+
}
181187
capiCluster.Status.Initialization.InfrastructureProvisioned = true
182188
Expect(ph.Patch(ctx, capiCluster, patch.WithStatusObservedGeneration{})).To(Succeed())
183189
})

internal/test/helpers/vmware/intg_test_context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ func CreateAndWait(ctx context.Context, integrationTestClient client.Client, obj
174174
func ClusterInfrastructureProvisioned(ctx context.Context, c client.Client, clusterCache clustercache.ClusterCache, cluster *clusterv1.Cluster) {
175175
GinkgoHelper()
176176
patch := client.MergeFrom(cluster.DeepCopy())
177+
if cluster.Status.Initialization == nil {
178+
cluster.Status.Initialization = &clusterv1.ClusterInitializationStatus{}
179+
}
177180
cluster.Status.Initialization.InfrastructureProvisioned = true
178181
Expect(c.Status().Patch(ctx, cluster, patch)).To(Succeed())
179182

pkg/services/vmoperator/vmopmachine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ func (v *VmopMachineService) reconcileVMOperatorVM(ctx context.Context, supervis
460460
// Not all network providers (for example, NSX-VPC) provide support for VM
461461
// readiness probes. The flag PerformsVMReadinessProbe is used to determine
462462
// whether a VM readiness probe should be conducted.
463-
if v.ConfigureControlPlaneVMReadinessProbe && infrautilv1.IsControlPlaneMachine(supervisorMachineCtx.Machine) && supervisorMachineCtx.Cluster.Status.Initialization.ControlPlaneInitialized {
463+
if v.ConfigureControlPlaneVMReadinessProbe && infrautilv1.IsControlPlaneMachine(supervisorMachineCtx.Machine) && supervisorMachineCtx.Cluster.Status.Initialization != nil && supervisorMachineCtx.Cluster.Status.Initialization.ControlPlaneInitialized {
464464
vmOperatorVM.Spec.ReadinessProbe = &vmoprv1.VirtualMachineReadinessProbeSpec{
465465
TCPSocket: &vmoprv1.TCPSocketAction{
466466
Port: intstr.FromInt(defaultAPIBindPort),

pkg/services/vmoperator/vmopmachine_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ var _ = Describe("VirtualMachine tests", func() {
406406

407407
By("Setting cluster.Status.ControlPlaneReady to true")
408408
// Set the control plane to be ready so that the new VM will have a probe
409+
if cluster.Status.Initialization == nil {
410+
cluster.Status.Initialization = &clusterv1.ClusterInitializationStatus{}
411+
}
409412
cluster.Status.Initialization.ControlPlaneInitialized = true
410413

411414
vmopVM = getReconciledVM(ctx, vmService, supervisorMachineContext)

0 commit comments

Comments
 (0)