Skip to content
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

ManagedCluster controller test enhancement #822

Open
BROngineer opened this issue Dec 20, 2024 · 0 comments · May be fixed by #830
Open

ManagedCluster controller test enhancement #822

BROngineer opened this issue Dec 20, 2024 · 0 comments · May be fixed by #830
Assignees
Labels
bug Something isn't working

Comments

@BROngineer
Copy link
Contributor

Description

Current test suite runs reconciliation and checks whether error occurred or not:

It("should successfully reconcile the resource", func() {
By("Reconciling the created resource")
controllerReconciler := &ManagedClusterReconciler{
Client: k8sClient,
Config: &rest.Config{},
}
_, err := controllerReconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: typeNamespacedName,
})
Expect(err).NotTo(HaveOccurred())
})

However, reconciler exits after adding finalizer to the resource being reconciled:

// managedcluster_controller.go

...
func (r *ManagedClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
    ...
    return r.reconcileUpdate(ctx, managedCluster)
}

func (r *ManagedClusterReconciler) reconcileUpdate(ctx context.Context, mc *hmc.ManagedCluster) (_ ctrl.Result, err error) {
...

    if controllerutil.AddFinalizer(mc, hmc.ManagedClusterFinalizer) {
        if err := r.Client.Update(ctx, mc); err != nil {
            return ctrl.Result{}, fmt.Errorf("failed to update managedCluster %s/%s: %w", mc.Namespace, mc.Name, err)
        }
        return ctrl.Result{}, nil
    }
...

Expected behaviour

Object should be reconciled until it eventually enters desired state defined by test-case parameters or test should fail by timeout.

@BROngineer BROngineer self-assigned this Dec 20, 2024
@BROngineer BROngineer moved this from Todo to In Progress in Project 2A Dec 20, 2024
@DinaBelova DinaBelova added the bug Something isn't working label Dec 20, 2024
@BROngineer BROngineer linked a pull request Dec 23, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging a pull request may close this issue.

2 participants