Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -157,11 +157,11 @@ func (r *KubeadmConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques

// Look up the owner of this kubeadm config if there is one
configOwner, err := bsutil.GetTypedConfigOwner(ctx, r.Client, config)
if apierrors.IsNotFound(err) {
// Could not find the owner yet, this is not an error and will rereconcile when the owner gets set.
return ctrl.Result{}, nil
}
if err != nil {
if apierrors.IsNotFound(err) {
// Could not find the owner yet, this is not an error and will rereconcile when the owner gets set.
return ctrl.Result{}, nil
}
return ctrl.Result{}, errors.Wrapf(err, "failed to get owner")
}
if configOwner == nil {
Expand Down
10 changes: 6 additions & 4 deletions controlplane/kubeadm/internal/controllers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,21 @@ func (r *KubeadmControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.
if apierrors.IsNotFound(err) {
return ctrl.Result{}, nil
}
return ctrl.Result{Requeue: true}, nil
return ctrl.Result{}, err
}

// Fetch the Cluster.
cluster, err := util.GetOwnerCluster(ctx, r.Client, kcp.ObjectMeta)
if err != nil {
log.Error(err, "Failed to retrieve owner Cluster from the API Server")
return ctrl.Result{}, err
if !apierrors.IsNotFound(err) {
return ctrl.Result{}, err
}
}
if cluster == nil {
if apierrors.IsNotFound(err) || cluster == nil {
log.Info("Cluster Controller has not yet set OwnerRef")
return ctrl.Result{}, nil
}

log = log.WithValues("Cluster", klog.KObj(cluster))
ctx = ctrl.LoggerInto(ctx, log)

Expand Down
6 changes: 3 additions & 3 deletions controlplane/kubeadm/internal/controllers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestClusterToKubeadmControlPlaneOtherControlPlane(t *testing.T) {
g.Expect(got).To(BeNil())
}

func TestReconcileReturnErrorWhenOwnerClusterIsMissing(t *testing.T) {
func TestReconcileDoesNothingWhenOwnerClusterIsMissing(t *testing.T) {
g := NewWithT(t)

ns, err := env.CreateNamespace(ctx, "test-reconcile-return-error")
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestReconcileReturnErrorWhenOwnerClusterIsMissing(t *testing.T) {
g.Eventually(func() error {
_, err := r.Reconcile(ctx, ctrl.Request{NamespacedName: util.ObjectKey(kcp)})
return err
}, 10*time.Second).Should(HaveOccurred())
}, 10*time.Second).Should(BeNil())
}

func TestReconcileUpdateObservedGeneration(t *testing.T) {
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestReconcileNoCluster(t *testing.T) {
}

_, err = r.Reconcile(ctx, ctrl.Request{NamespacedName: util.ObjectKey(kcp)})
g.Expect(err).To(HaveOccurred())
g.Expect(err).ToNot(HaveOccurred())

machineList := &clusterv1.MachineList{}
g.Expect(fakeClient.List(ctx, machineList, client.InNamespace(metav1.NamespaceDefault))).To(Succeed())
Expand Down
1 change: 1 addition & 0 deletions internal/controllers/cluster/cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
}

// Error reading the object - requeue the request.
log.Error(err, "Failed to fetch Cluster")
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
if apierrors.IsNotFound(err) {
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
return ctrl.Result{}, err
}

Expand Down
2 changes: 0 additions & 2 deletions internal/controllers/machine/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
// For additional cleanup logic use finalizers.
return ctrl.Result{}, nil
}

// Error reading the object - requeue the request.
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
// For additional cleanup logic use finalizers.
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
// For additional cleanup logic use finalizers.
return ctrl.Result{}, nil
}

// Error reading the object - requeue the request.
log.Error(err, "Failed to fetch MachineHealthCheck")
return ctrl.Result{}, err
}

Expand Down
1 change: 0 additions & 1 deletion internal/controllers/machineset/machineset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re
// For additional cleanup logic use finalizers.
return ctrl.Result{}, nil
}
// Error reading the object - requeue the request.
return ctrl.Result{}, err
}

Expand Down