Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ func TestReconcileInitializeControlPlane_withUserCA(t *testing.T) {
KubeadmConfigSpec: bootstrapv1.KubeadmConfigSpec{},
},
}
g.Expect(env.Create(ctx, kcp)).To(Succeed())
g.Expect(env.CreateAndWait(ctx, kcp)).To(Succeed())

corednsCM := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
8 changes: 8 additions & 0 deletions controlplane/kubeadm/internal/controllers/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/cluster-api/controllers/external"
"sigs.k8s.io/cluster-api/controlplane/kubeadm/internal"
clientutil "sigs.k8s.io/cluster-api/internal/util/client"
"sigs.k8s.io/cluster-api/internal/util/ssa"
"sigs.k8s.io/cluster-api/util/collections"
v1beta1conditions "sigs.k8s.io/cluster-api/util/conditions/deprecated/v1beta1"
Expand Down Expand Up @@ -447,6 +448,13 @@ func TestCloneConfigsAndGenerateMachineAndSyncMachines(t *testing.T) {
}})))

// Sync Machines

// Note: Ensure the client observed the latest objects so syncMachines below is not failing with conflict errors.
// Note: Not adding a WaitForCacheToBeUpToDate for infraObj for now as we didn't have test flakes because of it and
// WaitForCacheToBeUpToDate does not support Unstructured as of now.
g.Expect(clientutil.WaitForCacheToBeUpToDate(ctx, r.Client, "cloneConfigsAndGenerateMachine", &m)).To(Succeed())
g.Expect(clientutil.WaitForCacheToBeUpToDate(ctx, r.Client, "cloneConfigsAndGenerateMachine", kubeadmConfig)).To(Succeed())

controlPlane, err := internal.NewControlPlane(ctx, r.managementCluster, r.Client, cluster, kcp, collections.FromMachines(&m))
g.Expect(err).ToNot(HaveOccurred())
g.Expect(r.syncMachines(ctx, controlPlane)).To(Succeed())
Expand Down
3 changes: 1 addition & 2 deletions internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (retres ct

cluster, err := util.GetClusterByName(ctx, r.Client, m.Namespace, m.Spec.ClusterName)
if err != nil {
return ctrl.Result{}, errors.Wrapf(err, "failed to get cluster %q for machine %q in namespace %q",
m.Spec.ClusterName, m.Name, m.Namespace)
return ctrl.Result{}, err
}

// Initialize the patch helper
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/machine/machine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ func TestWatchesDelete(t *testing.T) {
},
}

g.Expect(env.Create(ctx, testCluster)).To(Succeed())
g.Expect(env.CreateAndWait(ctx, testCluster)).To(Succeed())
g.Expect(env.CreateKubeconfigSecret(ctx, testCluster)).To(Succeed())
g.Expect(env.Create(ctx, defaultBootstrap)).To(Succeed())
g.Expect(env.Create(ctx, infraMachine)).To(Succeed())
g.Expect(env.CreateAndWait(ctx, defaultBootstrap)).To(Succeed())
g.Expect(env.CreateAndWait(ctx, infraMachine)).To(Succeed())

defer func(do ...client.Object) {
g.Expect(env.Cleanup(ctx, do...)).To(Succeed())
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/clusterctl_upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,8 @@ func downloadToTmpFile(ctx context.Context, url string) string {
Expect(err).ToNot(HaveOccurred(), "failed to get clusterctl")
defer resp.Body.Close()

Expect(resp.StatusCode).To(Equal(http.StatusOK), "unexpected status code when downloading clusterctl")

// Write the body to file
_, err = io.Copy(tmpFile, resp.Body)
Expect(err).ToNot(HaveOccurred(), "failed to write temporary file")
Expand Down
2 changes: 1 addition & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func GetClusterByName(ctx context.Context, c client.Client, namespace, name stri
}

if err := c.Get(ctx, key, cluster); err != nil {
return nil, errors.Wrapf(err, "failed to get Cluster/%s", name)
return nil, errors.Wrapf(err, "failed to get Cluster %s", klog.KRef(namespace, name))
}

return cluster, nil
Expand Down
Loading