Skip to content

🌱 add checker to validate conditions for v1beta2 #12111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/e2e/autoscaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,20 @@ func AutoscalerSpec(ctx context.Context, inputGetter func() AutoscalerSpecInput)
})
}

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/cluster_deletion.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ func ClusterDeletionSpec(ctx context.Context, inputGetter func() ClusterDeletion
},
}, clusterResources)

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

// Get all objects per deletion phase and the list of blocking objects.
var objectsPerPhase [][]client.Object
objectsPerPhase, blockingObjects = getDeletionPhaseObjects(ctx, input.BootstrapClusterProxy, clusterResources.Cluster, input.ClusterDeletionPhases)
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/cluster_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
})

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

if !input.SkipConformanceTests {
By("Running conformance tests")
// Start running the conformance test suite.
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/cluster_upgrade_runtimesdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,20 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
"AfterClusterUpgrade": "Success",
})).To(Succeed(), "Lifecycle hook calls were not as expected")

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/clusterclass_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,20 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
WaitForMachinePools: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
})

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("Deleting a MachineDeploymentTopology in the Cluster Topology and wait for associated MachineDeployment to be deleted")
deleteMachineDeploymentTopologyAndWait(ctx, deleteMachineDeploymentTopologyAndWaitInput{
ClusterProxy: input.BootstrapClusterProxy,
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/clusterclass_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,20 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
}, input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade")...).Should(Succeed())
assertClusterObjects(ctx, input.BootstrapClusterProxy, clusterResources.Cluster, clusterResources.ClusterClass, input.FilterMetadataBeforeValidation)

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
63 changes: 13 additions & 50 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,19 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
upgrade.PostUpgrade(managementClusterProxy, workloadCluster.Namespace, workloadCluster.Name)
}

Byf("[%d] Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines", i)
verifyV1Beta2ConditionsTrueV1Beta1(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
[]string{clusterv1.AvailableCondition, clusterv1.ReadyCondition})
Byf("[%d] Verify Cluster Available condition is true", i)
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: managementClusterProxy.GetClient(),
Name: workloadCluster.Name,
Namespace: workloadCluster.Namespace,
})

Byf("[%d] Verify Machines Ready condition is true", i)
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: managementClusterProxy.GetClient(),
Name: workloadCluster.Name,
Namespace: workloadCluster.Namespace,
})

// Note: It is a known issue on Kubernetes < v1.29 that SSA sometimes fail:
// https://github.com/kubernetes/kubernetes/issues/117356
Expand Down Expand Up @@ -801,53 +811,6 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
})
}

// verifyV1Beta2ConditionsTrueV1Beta1 checks the Cluster and Machines of a Cluster that
// the given v1beta2 condition types are set to true without a message, if they exist.
func verifyV1Beta2ConditionsTrueV1Beta1(ctx context.Context, c client.Client, clusterName, clusterNamespace string, v1beta2conditionTypes []string) {
cluster := &clusterv1beta1.Cluster{}
key := client.ObjectKey{
Namespace: clusterNamespace,
Name: clusterName,
}
Eventually(func() error {
return c.Get(ctx, key, cluster)
}, 3*time.Minute, 3*time.Second).Should(Succeed(), "Failed to get Cluster object %s", klog.KRef(clusterNamespace, clusterName))

if cluster.Status.V1Beta2 != nil && len(cluster.Status.V1Beta2.Conditions) > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we need a rebase (cluster.Status.v1beta2 doesn't exist anymore)

for _, conditionType := range v1beta2conditionTypes {
for _, condition := range cluster.Status.V1Beta2.Conditions {
if condition.Type != conditionType {
continue
}
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Cluster should be set to true", conditionType)
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Cluster should have an empty message", conditionType)
}
}
}

machineList := &clusterv1beta1.MachineList{}
Eventually(func() error {
return c.List(ctx, machineList, client.InNamespace(clusterNamespace),
client.MatchingLabels{
clusterv1.ClusterNameLabel: clusterName,
})
}, 3*time.Minute, 3*time.Second).Should(Succeed(), "Failed to list Machines for Cluster %s", klog.KObj(cluster))
for _, machine := range machineList.Items {
if machine.Status.V1Beta2 == nil || len(machine.Status.V1Beta2.Conditions) == 0 {
continue
}
for _, conditionType := range v1beta2conditionTypes {
for _, condition := range machine.Status.V1Beta2.Conditions {
if condition.Type != conditionType {
continue
}
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Machine %q should be set to true", conditionType, machine.Name)
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Machine %q should have an empty message", conditionType, machine.Name)
}
}
}
}

func setupClusterctl(ctx context.Context, clusterctlBinaryURL, clusterctlConfigPath string) (string, string) {
clusterctlBinaryPath := downloadToTmpFile(ctx, clusterctlBinaryURL)

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/k8s_conformance.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
)
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/kcp_adoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInpu
}
Expect(secrets.Items).To(HaveLen(4 /* pki */ + 1 /* kubeconfig */ + int(*replicas)))

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: cluster.Name,
Namespace: cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: cluster.Name,
Namespace: cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/kcp_remediations.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,20 @@ func KCPRemediationSpec(ctx context.Context, inputGetter func() KCPRemediationSp

By("CP BACK TO FULL OPERATIONAL STATE!")

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/machine_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ func MachinePoolSpec(ctx context.Context, inputGetter func() MachinePoolInput) {
WaitForMachinePoolToScale: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
})

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/md_remediations.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ func MachineDeploymentRemediationSpec(ctx context.Context, inputGetter func() Ma
WaitForMachineRemediation: input.E2EConfig.GetIntervals(specName, "wait-machine-remediation"),
})

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
15 changes: 15 additions & 0 deletions test/e2e/md_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ func MachineDeploymentRolloutSpec(ctx context.Context, inputGetter func() Machin
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
MachineDeployments: clusterResources.MachineDeployments,
})

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/md_scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,20 @@ func MachineDeploymentScaleSpec(ctx context.Context, inputGetter func() MachineD
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
})

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("Deleting the MachineDeployment with foreground deletion")
foreground := metav1.DeletePropagationForeground
framework.DeleteAndWaitMachineDeployment(ctx, framework.DeleteAndWaitMachineDeploymentInput{
Expand Down
14 changes: 14 additions & 0 deletions test/e2e/node_drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,20 @@ func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeo
}
}, nodeDrainTimeoutKCPInterval...).Should(Succeed())

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
14 changes: 14 additions & 0 deletions test/e2e/quick_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,20 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
},
}, clusterResources)

Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})

By("PASSED!")
})

Expand Down
Loading