Skip to content

Opt-out option for Flux receiver creation

What does this MR do and why?

The MR is related to #472 (closed) and adds an option to enable/disable Flux integration.

Manual test (enable_project_reconciliation option)

The test was performed against GDK and the agent as well as KAS were set up by following doc/developing.md. The agent was not started as a pod, therefor an additional webhook_receiver_url was configured and the following agent configuration file was used:

flux:
  webhook_receiver_url: /api/v1/namespaces/flux-system/services/http:webhook-receiver:http/proxy
  enable_project_reconciliation: false

observability:
  logging:
    level: debug

Flux was set by following the flux tutorial.

With the enable_project_reconciliation option not set, the agent successfully triggers reconciliation instantly:

{"level":"debug","time":"2024-02-20T11:18:52.927+0100","msg":"Started watching projects for reconciliation","mod_name":"flux","projects_to_reconcile":["root/k8s-agent"],"agent_id":2}                   
{"level":"debug","time":"2024-02-20T11:19:24.598+0100","msg":"Applying configuration","commit_id":"001133ecec6e251a4688082eb14ef8b7e443b63f","agent_config":"{\"observability\":{\"logging\":{\"level\":\
"debug\"}}, \"agentId\":\"2\", \"projectId\":\"19\", \"projectPath\":\"root/k8s-agent\", \"flux\":{\"webhook_receiver_url\":\"/api/v1/namespaces/flux-system/services/http:webhook-receiver:http/proxy\"}
, \"gitlabExternalUrl\":\"https://gdk.test:3443\"}","agent_id":2}                                                                                                                                        
{"level":"debug","time":"2024-02-20T11:19:24.748+0100","msg":"Handling update of GitRepository","mod_name":"flux","agent_id":2}                                                                          
{"level":"debug","time":"2024-02-20T11:19:24.748+0100","msg":"Reconciling GitRepository","mod_name":"flux","namespaced_name":"flux-system/flux-system","gitrepository_url":"ssh://git@gdk.test:2222/root/k8s-agent","project_id":"root/k8s-agent","agent_id":2}
{"level":"debug","time":"2024-02-20T11:19:24.763+0100","msg":"Handling update of GitRepository","mod_name":"flux","agent_id":2}
{"level":"debug","time":"2024-02-20T11:19:24.778+0100","msg":"Successfully reconciled GitRepository","mod_name":"flux","namespaced_name":"flux-system/flux-system","agent_id":2}

When setting enable_project_reconciliation: false the reconciliation is triggered based on the set interval in the flux settings:

{"level":"debug","time":"2024-02-20T11:30:18.945+0100","msg":"Applying configuration","commit_id":"96c058c021624f691c9b9ae5a61f992b7b0f3bf3","agent_config":"{\"observability\":{\"logging\":{\"level\":\"debug\"}}, \"agentId\":\"2\", \"projectId\":\"19\", \"projectPath\":\"root/k8s-agent\", \"flux\":{\"webhook_receiver_url\":\"/api/v1/namespaces/flux-system/services/http:webhook-receiver:http/proxy\", \"enable_project_reconciliation\":false}, \"gitlabExternalUrl\":\"https://gdk.test:3443\"}","agent_id":2}
{"level":"debug","time":"2024-02-20T11:33:43.367+0100","msg":"Handling update of GitRepository","mod_name":"flux","agent_id":2}
{"level":"debug","time":"2024-02-20T11:33:43.368+0100","msg":"Reconciling GitRepository","mod_name":"flux","namespaced_name":"flux-system/flux-system","gitrepository_url":"ssh://git@gdk.test:2222/root/k8s-agent","project_id":"root/k8s-agent","agent_id":2}
{"level":"debug","time":"2024-02-20T11:33:43.391+0100","msg":"Successfully reconciled GitRepository","mod_name":"flux","namespaced_name":"flux-system/flux-system","agent_id":2}

Even though disabling the project reconciliation worked as expected, it did leave multiple debug logs, which could cause confusion. Moreover, the issue is to fully disable the flux integration, as the user could have already configured it and would like to opt-out completely of the integration instead of only from the reconciliation. See !1348 (comment 1780898152) for more details.

Manual test (enabled option)

The setup remained the same as above. Setting enabled: false stopped the GitRepository controller and project reconciliation:

{"level":"debug","time":"2024-02-23T08:30:03.003+0100","msg":"Shutting down GitRepository worker","mod_name":"flux","agent_id":2}
{"level":"info","time":"2024-02-23T08:30:03.003+0100","msg":"Stopped GitRepository controller","mod_name":"flux","agent_id":2}
{"level":"debug","time":"2024-02-23T08:30:03.003+0100","msg":"Reconciling GitRepository","mod_name":"flux","namespaced_name":"flux-system/flux-system","gitrepository_
url":"ssh://git@gdk.test:2222/root/k8s-agent","project_id":"root/k8s-agent","agent_id":2}
{"level":"debug","time":"2024-02-23T08:30:03.003+0100","msg":"ReconcileProjects request has been canceled, backing off and awaiting cancellation","mod_name":"flux","a
gent_id":2}
{"level":"debug","time":"2024-02-23T08:30:03.003+0100","msg":"Stopped watching projects for reconciliation","mod_name":"flux","projects_to_reconcile":["root/k8s-agent
"],"agent_id":2}

Any following changes to resources did not produce logs related to the reconciliation and the resources were still successfully updated by flux.

MR acceptance checklist

  • Add a new configuration option in the Flux agent configuration (enabled)
  • Disable module creation depending on the new configuration option
  • Add unit tests
  • Manually test behaviour

Tasks moved for a follow-up issue/MR(#538):

Edited by Hristiyan Ivanov

Merge request reports