Skip to content

Agent: Call Rails API to fetch prerequisite information before starting reconciliation

MR: Shared namespace support (gitlab-org/cluster-integration/gitlab-agent!2351 - merged)

Description

Before the agent can start up, it needs to know about the namespaces on which it will start an informer. We do not want to read the value from the agent configuration because we have made this decision explicitly as it helps us to move away from a file based configuration in the future.

In Rails: Add API that agent will call to fetch in... (#519261 - closed) , the API will be introduced in Rails. This issue is about calling that API before starting the informers in the agent.

Acceptance criteria

  • The /internal/kubernetes/modules/remote_development/prerequisites API is called to determine the mode in which the agent is running - unique/shared.
  • If the agent is running in unique mode, the informers will watch in all namespaces. (existing behaviour)
  • If the agent is running in shared mode, the informers will watch in only the shared_namespace as passed from the API.

Implementation plan

  • Update internal/module/remote_development/agent/factory.go to call the /internal/kubernetes/modules/remote_development/prerequisites API.
  • Extract the two fields from it - workspace_namespace_mode and shared_namespace.
  • If workspace_namespace_mode is unique, existing behaviour of informers watching in all namespaces continue.
  • If workspace_namespace_mode is shared, the informers will be watching in the shared_namespace namespace only.

Reference implementation can be found in Draft: Spike: Workspaces in a single namespace (gitlab-org/cluster-integration/gitlab-agent!2239 - closed) .

Edited by Vishal Tak