fluidos-project / node

FLUIDOS Node and its essential components
https://fluidos-project.github.io/node/
Apache License 2.0
3 stars 7 forks source link

Controllers scope: cluster wide or namespaced? #51

Open andreacv98 opened 5 months ago

andreacv98 commented 5 months ago

Hello everyone,

With this issue, I want to raise a question: should the operators watch for CR created in every namespace?

This doubt comes from a bug: when you create a solver in the default namespace for example, instead of the fluidos namespace, the process is interrupted after the successful discovery creation and completion.

Looking inside the log of the rear-manager you can see the following:

I0502 09:29:43.443703       1 solver_controller.go:104] Reconciling Solver default/solver-sample-demo
I0502 09:29:43.451467       1 solver_controller.go:104] Reconciling Solver default/solver-sample-demo
I0502 09:29:43.552659       1 solver_controller.go:482] No PeeringCandidates found
I0502 09:29:43.552731       1 solver_controller.go:206] Solver solver-sample-demo has not found any candidate. Trying a Discovery
I0502 09:29:43.562508       1 solver_controller.go:104] Reconciling Solver default/solver-sample-demo
I0502 09:29:43.562554       1 solver_controller.go:230] Getting or creating Discovery for Solver solver-sample-demo
I0502 09:29:43.574271       1 solver_controller.go:92] Solver fluidos/solver-sample-demo not found, probably deleted
I0502 09:29:43.712979       1 solver_controller.go:92] Solver fluidos/solver-sample-demo not found, probably deleted

As you can see the solver-controller first correctly reconcile the solver created in the default namespace, but after the discovery creation, the subsequent reconciliation is performed over the original solver, but in the default fluidos namespace.

Moreover, looking inside the helm chart, the RBAC for the rear-manager are cluster wide (ClusterRole, ClusterRoleBinding, etc.).

In conclusion, I can see both an intention of watching for solver resources cluster wide and in the specific namespace, but I don't understand which one has been chosen. In my opinion, the controller can be forced to watch for only the solver resources inside the fluidos namespace, granting a better control and more specific RBAC.

Feel free to give me any feedback about this point

Thanks, Andrea

andreacv98 commented 5 months ago

I found that the specific behavior that I found in the log (first reconcile over a solver in the right namespace, than it is changed in the second iteration) can be caused by the mapping over the watches set for the reconcile of the rear-manager.

Starting from this point:

https://github.com/fluidos-project/node/blob/f71e8441ca8308c382d231a90aa404efe286d1c7/pkg/rear-manager/solver_controller.go#L577-L590

The code refers (concerning the discovery issue, but I think it can be extended to other resources watched by the reconciler):

https://github.com/fluidos-project/node/blob/f71e8441ca8308c382d231a90aa404efe286d1c7/pkg/rear-manager/solver_controller.go#L621-L631

Here, the namespace of the mapping is hard coded to the one of fluidos.