Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuvaraj Kakaraparthi committed Jun 2, 2023
1 parent 418b52c commit df358cb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
29 changes: 14 additions & 15 deletions test/e2e/cluster_upgrade_runtimesdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"fmt"
"os"
"path/filepath"
"sigs.k8s.io/cluster-api/util/patch"
"strings"
"time"

Expand All @@ -43,6 +42,7 @@ import (
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/patch"
)

// The Cluster API test extension uses a ConfigMap named cluster-name + suffix to determine answers to the lifecycle hook calls;
Expand Down Expand Up @@ -324,24 +324,23 @@ func machineSetPreflightChecksTestHandler(ctx context.Context, c client.Client,
// Since the MachineDeployment is pending an upgrade at this point the topology controller will not push any changes
// to the MachineDeployment. Therefore, the changes made to the MachineDeployment here will not be replaced
// until the AfterControlPlaneUpgrade hook unblocks the upgrade.
*md.Spec.Replicas += 1
*md.Spec.Replicas++
Eventually(func() error {
return patchHelper.Patch(ctx, md)
}).Should(Succeed(), "Failed to scale up the MachineDeployment %s", klog.KObj(md))
// Verify the MachineDeployment updated replicas are not overridden.
// Note: This verifies that the topology controller in fact holds any reconciliation of this MachineDeployment.
Consistently(func(g Gomega) {
mds := framework.GetMachineDeploymentsByCluster(ctx, framework.GetMachineDeploymentsByClusterInput{
Lister: c,
ClusterName: clusterRef.Name,
Namespace: clusterRef.Namespace,
})
for i := range mds {
if mds[i].Name != md.Name {
continue
}
g.Expect(mds[i].Spec.Replicas).To(Equal(md.Spec.Replicas))
}
})
// Get the updated MachineDeployment.
targetMD := &clusterv1.MachineDeployment{}
// Wrap in an Eventually block for additional safety. Since all of this is in a Consistently block it
// will fail if we hit a transient error like a network flake.
Eventually(func() error {
return c.Get(ctx, client.ObjectKeyFromObject(md), targetMD)
}).Should(Succeed(), "Failed to get MachineDeployment %s", klog.KObj(md))
// Verify replicas are not overridden.
g.Expect(targetMD.Spec.Replicas).To(Equal(md.Spec.Replicas))
}, "10s", "1s")

// Verify that the MachineSet is not creating the new Machine.
Eventually(func(g Gomega) {
Expand All @@ -359,7 +358,7 @@ func machineSetPreflightChecksTestHandler(ctx context.Context, c client.Client,
// Scale down the MachineDeployment to the original replicas.
patchHelper, err = patch.NewHelper(md, c)
Expect(err).To(BeNil())
*md.Spec.Replicas -= 1
*md.Spec.Replicas--
Eventually(func() error {
return patchHelper.Patch(ctx, md)
}).Should(Succeed(), "Failed to scale down the MachineDeployment %s", klog.KObj(md))
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/cluster_upgrade_runtimesdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/utils/pointer"
)

var _ = Describe("When upgrading a workload cluster using ClusterClass with RuntimeSDK [PR-Informing] [ClusterClass] [PR-Blocking]", func() {
var _ = Describe("When upgrading a workload cluster using ClusterClass with RuntimeSDK [PR-Informing] [ClusterClass]", func() {
clusterUpgradeWithRuntimeSDKSpec(ctx, func() clusterUpgradeWithRuntimeSDKSpecInput {
version, err := semver.ParseTolerant(e2eConfig.GetVariable(KubernetesVersionUpgradeFrom))
Expect(err).ToNot(HaveOccurred(), "Invalid argument, KUBERNETES_VERSION_UPGRADE_FROM is not a valid version")
Expand Down
2 changes: 1 addition & 1 deletion test/framework/machineset_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package framework

import (
"context"
"sigs.k8s.io/controller-runtime/pkg/client"

. "github.com/onsi/gomega"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)
Expand Down

0 comments on commit df358cb

Please sign in to comment.