Skip to content

fix(agents): follow an organization Namespace's Flux labels when the caller cannot read it - #504

Merged
fiunchinho merged 1 commit into
mainfrom
fix/namespace-flux-labels-sa-read
Nov 30, 2026
Merged

fiunchinho merged 1 commit into
mainfrom
fix/namespace-flux-labels-sa-read

Conversation

@fiunchinho

Copy link
Copy Markdown
Member

Part of #498

Problem

Item 3 (R1-2) of #498. In mode commit, create_agent looks for the target of a new agent in this order: the agent chart source, the agent releases applied from git, the Namespace, and then, in an organization namespace, the organization's content path. The Namespace is cluster-scoped, and an organization's members may not get it. namespaceLocation dropped a failed read of the Namespace. So when the organization Namespace carries Flux labels to another repository or directory, and no chart source or agent release of the namespace comes from git, a member's commit went to the content path, not to the target that the Namespace's labels name.

Change

  • When the caller's read of an organization Namespace is forbidden, create_agent follows the Flux Kustomization labels that agent-manager's ServiceAccount reads on the Namespace. This is the read that organizations.Service.ContentLocation already does (Namespaces.Get). The read gives only the two Flux labels (kustomize.toolkit.fluxcd.io/name and /namespace).
  • The labels go through ownerLocation, as for a Namespace that the caller can read. The Kustomization and its source are read as the caller. When the labels name the organization's own Kustomization and the caller may not read it, the target is the content path (the fallback of fix(agents): commit an organization member's agent writes to the content path when the Kustomization cannot be read #500). When the labels name another Kustomization that the caller may not read, the answer is forbidden: get Kustomization <namespace>/<name>, not the content path.
  • A Namespace without the labels leaves the target to the content path, as before. In an organization namespace, a read of the Namespace that fails for another reason than forbidden or not found is an error.
  • Other namespaces, and sites on a workload cluster, keep their behavior. No new RBAC rights.
  • The Namespace is now read only when no chart source or agent release names a target.
  • Wiring: agents.Config.OrganizationContent returns agents.OrganizationNamespace (the content path and the Namespace's Flux labels) in place of provenance.Location. This changes 3 lines in cmd/serve.go and the field in internal/agents/service.go. git merge-tree with the branch of feat: tool approval for agents: settings and grants on an agent's tools, migrate hop to agent chart 3.0 #483 (tool-approval) shows no conflict.
  • docs/organizations-commit-mode.md has one new item on this.

Tests

  • TestCommitFollowsTheFluxLabelsOfAnOrganizationNamespaceTheCallerCannotRead (internal/api) uses the real organizations and agent tools. agent-manager's ServiceAccount reads the Namespace from its own fake client, and the caller may not get the Namespace. The test checks five states: no labels (content path), labels to a Kustomization that the caller can read (its repository and directory), a Kustomization that the caller cannot read (error that names it), the organization's own Kustomization (content path), and a 500 on the Namespace read (error). On main the second and third states go to the content path, so the test fails.
  • go test ./... passes.

Review

An independent review (deep mode) and a Codex review (one round, verdict=approve) found no findings.

…caller cannot read it

In mode commit, when the caller's read of an organization's Namespace is forbidden, create_agent follows the Flux Kustomization labels that agent-manager's ServiceAccount reads on the Namespace, instead of falling back to the organization's content path. The Kustomization and its source are still read as the caller. A read that fails for another reason is an error in an organization namespace.

Part of #498
@fiunchinho fiunchinho self-assigned this Nov 30, 2026
@fiunchinho
fiunchinho marked this pull request as ready for review November 30, 2026 12:02
@fiunchinho
fiunchinho requested a review from a team as a code owner November 30, 2026 12:02
@circleci-architect

Copy link
Copy Markdown

Published Helm chart agent-manager

3.5.12-r0a67631ct20261130114608hded983b
Chart agent-manager
Version 3.5.12-r0a67631ct20261130114608hded983b
OCI reference oci://gsoci.azurecr.io/charts/giantswarm/agent-manager:3.5.12-r0a67631ct20261130114608hded983b
Digest sha256:c5b74c50ff321bc0fef32a5e517bb37c77398d646d310b7ec2d63a1734d00780
Registry public — gsoci.azurecr.io
Git catalog giantswarm-test-catalog (index)
Pull this chart
helm pull oci://gsoci.azurecr.io/charts/giantswarm/agent-manager --version 3.5.12-r0a67631ct20261130114608hded983b

Posted by architect-orb · build 13588 · commit ded983b · updated in place on every push

@fiunchinho
fiunchinho merged commit e87331f into main Nov 30, 2026
18 checks passed
@fiunchinho
fiunchinho deleted the fix/namespace-flux-labels-sa-read branch November 30, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant