Skip to content

Commit 1895afe

Browse files
committed
Fix e2e test issues introduced by chained upgrades
Signed-off-by: Stefan Büringer [email protected]
1 parent 4b3a973 commit 1895afe

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

internal/webhooks/cluster.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,8 @@ func (webhook *Cluster) validateTopology(ctx context.Context, oldCluster, newClu
334334
allErrs = append(allErrs, validateAutoscalerAnnotationsForCluster(newCluster, clusterClass)...)
335335

336336
if oldCluster != nil { // On update
337-
// The ClusterClass must exist to proceed with update validation. Return an error if the ClusterClass was
338-
// not found.
339-
if apierrors.IsNotFound(clusterClassPollErr) {
337+
// Return an error if we couldn't get the ClusterClass (either because it was not found or not reconciled).
338+
if clusterClassPollErr != nil {
340339
allErrs = append(
341340
allErrs, field.InternalError(
342341
fldPath.Child("class"),
@@ -402,16 +401,6 @@ func (webhook *Cluster) validateTopology(ctx context.Context, oldCluster, newClu
402401

403402
// If the ClusterClass referenced in the Topology has changed compatibility checks are needed.
404403
if oldCluster.GetClassKey() != newCluster.GetClassKey() {
405-
if clusterClassPollErr != nil {
406-
allErrs = append(
407-
allErrs, field.Forbidden(
408-
fldPath.Child("class"),
409-
fmt.Sprintf("cannot rebase to ClusterClass %q: %s",
410-
newCluster.GetClassKey(), clusterClassPollErr.Error())))
411-
// Return early with errors if the new ClusterClass can't be retrieved.
412-
return allWarnings, allErrs
413-
}
414-
415404
// Check to see if the ClusterClass referenced in the old version of the Cluster exists.
416405
oldClusterClass, err := webhook.pollClusterClassForCluster(ctx, oldCluster)
417406
if err != nil {

test/e2e/cluster_upgrade_runtimesdk_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ var _ = Describe("When performing chained upgrades for workload cluster using Cl
100100
DeployClusterClassInSeparateNamespace: true,
101101
// Setting Kubernetes version from
102102
KubernetesVersionFrom: e2eConfig.MustGetVariable(KubernetesVersionChainedUpgradeFrom),
103-
// use Kubernetes versions from the kind mapper.
104-
KubernetesVersions: kind.GetKubernetesVersions(),
103+
// use Kubernetes versions from the kind mapper
104+
// Note: Ensure KUBERNETES_VERSION_UPGRADE_TO is always part of the list, this is required for cases where
105+
// KUBERNETES_VERSION_UPGRADE_TO is not in the kind mapper, e.g. in the `e2e-latestk8s` prowjob.
106+
KubernetesVersions: appendIfNecessary(kind.GetKubernetesVersions(), e2eConfig.MustGetVariable(KubernetesVersionUpgradeTo)),
105107
// The runtime extension gets deployed to the test-extension-system namespace and is exposed
106108
// by the test-extension-webhook-service.
107109
// The below values are used when creating the cluster-wide ExtensionConfig to refer
@@ -112,3 +114,12 @@ var _ = Describe("When performing chained upgrades for workload cluster using Cl
112114
}
113115
})
114116
})
117+
118+
func appendIfNecessary(versions []string, v string) []string {
119+
for _, version := range versions {
120+
if version == v {
121+
return versions
122+
}
123+
}
124+
return append(versions, v)
125+
}

test/framework/deployment_helpers.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,12 @@ func dumpPodMetrics(ctx context.Context, client *kubernetes.Clientset, metricsPa
412412
}
413413

414414
if !errorRetrievingMetrics {
415-
Expect(verifyMetrics(data)).To(Succeed())
415+
Expect(verifyMetrics(data, &pod)).To(Succeed())
416416
}
417417
}
418418
}
419419

420-
func verifyMetrics(data []byte) error {
420+
func verifyMetrics(data []byte, pod *corev1.Pod) error {
421421
var parser expfmt.TextParser
422422
mf, err := parser.TextToMetricFamilies(bytes.NewReader(data))
423423
if err != nil {
@@ -458,7 +458,7 @@ func verifyMetrics(data []byte) error {
458458
}
459459

460460
if len(errs) > 0 {
461-
return kerrors.NewAggregate(errs)
461+
return errors.Wrapf(kerrors.NewAggregate(errs), "panics occurred in %s", klog.KObj(pod))
462462
}
463463

464464
return nil

0 commit comments

Comments
 (0)