Skip to content

fix(agents): keep the target's path when its last agent goes, for every target - #522

Merged
fiunchinho merged 3 commits into
mainfrom
gitkeep-every-target
Dec 1, 2026
Merged

fiunchinho merged 3 commits into
mainfrom
gitkeep-every-target

Conversation

@fiunchinho

Copy link
Copy Markdown
Member

Part of #502

Problem

delete_agent in mode commit of the last agent removes agent-manager/. When the path above it (the target's path, which a Flux Kustomization builds) has no kustomization.yaml and no other file, git keeps no empty directory, so the merge removes the path. The Kustomization then fails with "kustomization path not found" before it prunes, so the agent's HelmRelease stays and no later change of that path is applied.

#520 fixed this for an organization's content path only. Two targets were still open:

  • item 4: the path of another Kustomization that applies the agent;
  • item 5: a path the caller names with repository, branch and path, also when it is an organization's content path.

Change

  • keepTargetPath (internal/agents/commit.go, from agentCommit.open) now runs for every target: a write that empties agent-manager/ adds <target path>/.gitkeep when that path has neither a kustomization.yaml nor a .gitkeep on the base branch. "Empties" is read from the plan (layout.Build removes agent-manager/kustomization.yaml); no listing.
  • No .gitkeep at the repository's root, which no merge removes.
  • The content-path mark of fix(agents): keep an organization's content path when its last agent goes #520 (commitLocation.content, sameLocation) and its ServiceAccount read of the organization namespace in ownerLocation are removed: the rule needs no knowledge of the target's kind.
  • agents.KeepContent, shared with the organization writes, no longer names an organization.
  • A dry run shows the .gitkeep in commit.files.
  • README "Write modes" and docs/organizations-commit-mode.md describe the rule.

Flux builds a path with no YAML file as an empty kustomization and prunes the old inventory: fluxcd/pkg kustomize v1.24.0 (kustomize-controller v1.7.3) generates namespace: _placeholder with no resources for it, and source-controller's default ignore list keeps .gitkeep.

Tests

TestCommitDeleteOfTheLastAgentKeepsItsTargetPath (the table test of #520, extended): a content path found through the F1 fallback and through the organization's own Kustomization, another Kustomization's path, a path the caller names, and the repository's root; no .gitkeep with a kustomization.yaml, with a .gitkeep already in git, or with another agent left.

  • On the code before the change, exactly the cases "another Kustomization's path" and "a path the caller names" fail (no .gitkeep, the path does not stay).
  • Without the root check, the root case fails.
  • go build ./..., go test of internal/agents, internal/api and internal/organizations, and pre-commit (golangci-lint included) pass.

Review

Id Reviewer Severity Outcome Finding
F1 Opus (deep) non-blocking fixed (ea6a866) No test covered the repository-root check.
F2 Opus (deep) non-blocking fixed (ea6a866) The README did not name the root exception.

Codex: round 1 on 023fdeb approved with no findings; round 2 skipped the small fixes, which the first reviewer confirmed.

…ry target

delete_agent in mode commit that empties agent-manager/ adds .gitkeep to the path above it when that path has no kustomization.yaml and no .gitkeep in git, for every target: an organization's content path, another Kustomization's path, and a path the caller names. The content-path mark and its ServiceAccount read of the organization namespace go.

Part of #502
@fiunchinho fiunchinho self-assigned this Dec 1, 2026
@fiunchinho
fiunchinho marked this pull request as ready for review December 1, 2026 18:08
@fiunchinho
fiunchinho requested a review from a team as a code owner December 1, 2026 18:08
@circleci-architect

Copy link
Copy Markdown

Published Helm chart agent-manager

4.1.3-rf94c02f8t20261201180225hea6a866
Chart agent-manager
Version 4.1.3-rf94c02f8t20261201180225hea6a866
OCI reference oci://gsoci.azurecr.io/charts/giantswarm/agent-manager:4.1.3-rf94c02f8t20261201180225hea6a866
Digest sha256:94e3fa06f6d754553b299b27243de595e5c91c887894b493de853afc8c7e5627
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 4.1.3-rf94c02f8t20261201180225hea6a866

Posted by architect-orb · build 14156 · commit ea6a866 · updated in place on every push

@fiunchinho
fiunchinho merged commit 24c1a1c into main Dec 1, 2026
20 of 21 checks passed
@fiunchinho
fiunchinho deleted the gitkeep-every-target branch December 1, 2026 18:10
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