Skip to content

fix(agents): keep an organization's content path when its last agent goes - #520

Merged
fiunchinho merged 1 commit into
mainfrom
fix-agent-delete-gitkeep
Dec 1, 2026
Merged

fiunchinho merged 1 commit into
mainfrom
fix-agent-delete-gitkeep

Conversation

@fiunchinho

Copy link
Copy Markdown
Member

Part of #502

Problem

An organization's content path can have no kustomization.yaml (an organization created in mode apply): Flux then generates its kustomization. When it holds only agent-manager/ with one agent, delete_agent in mode commit removes the agent's file and agent-manager/kustomization.yaml. Git keeps no empty directory, so after the merge the content path is gone. The organization's Kustomization then fails with "kustomization path not found" before it prunes, the agent's HelmRelease stays, and no later change of the organization is applied until a person restores the path (#502 item 3).

Change

  • In mode commit, when an agent write empties agent-manager's directory in an organization's content path (the plan removes agent-manager/kustomization.yaml), and the base branch has neither <content path>/kustomization.yaml nor <content path>/.gitkeep, the pull request also adds <content path>/.gitkeep. Flux's generator builds a path without YAML files as an empty kustomization, so the HelmRelease is pruned. A dry run shows the .gitkeep in commit.files.
  • This holds when the target is the content path because the caller may not read the organization's Kustomization, and when the caller reads that Kustomization and its target is the same repository, branch and directory as the content path.
  • No change when the content path has a kustomization.yaml (it stays, without the agent-manager entry), when agent-manager/ keeps other agents, or when the target is not an organization's content path (Follow-ups of leaving a content path without kustomization.yaml to Flux #502 item 4).
  • The marker has one definition, agents.KeepFile and agents.KeepContent, which the organization writes (leaveToFlux, from fix(organizations): leave a content path without kustomization.yaml to Flux's generated kustomization #503) now use too. Its content is unchanged.
  • The change is in agentCommit.open (internal/agents/commit.go); cmd/serve.go, internal/agents/service.go and internal/api/mcp.go are not changed.
  • docs/organizations-commit-mode.md has one new bullet.

Tests

TestCommitDeleteOfAnOrganizationsLastAgentKeepsItsContentPath (internal/agents/commit_test.go): delete of the last agent of a content path without kustomization.yaml, with the organization's Kustomization refused and read, adds the .gitkeep on the dry run and on the pull request's head; a content path with a kustomization.yaml, a .gitkeep already in git, and another agent in agent-manager/ add none. The two adding cases fail on main. go test ./internal/agents/ ./internal/organizations/ ./internal/api/ and golangci-lint pass.

Review

ID Severity Outcome Finding
F1 / R1-1 non-blocking / important deferred to #502 (item 5) delete_agent with a target the caller names (repository, branch, path) equal to the content path goes through explicitLocation, is not marked as the content path and gets no .gitkeep. The fix of #502 item 4 (the .gitkeep for every target) covers it.

…goes

delete_agent in mode commit of the last agent of a content path without kustomization.yaml adds <content path>/.gitkeep when git lacks it, so Flux builds an empty kustomization and prunes the HelmRelease. The marker is one definition, agents.KeepFile and agents.KeepContent, which the organization writes use too.

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

Copy link
Copy Markdown

Published Helm chart agent-manager

4.1.2-r998d20c7t20261201161749h37201e6
Chart agent-manager
Version 4.1.2-r998d20c7t20261201161749h37201e6
OCI reference oci://gsoci.azurecr.io/charts/giantswarm/agent-manager:4.1.2-r998d20c7t20261201161749h37201e6
Digest sha256:9121fca1e285fece9877ef7f3a9350a7378f4d6aa02e3ec228626297ac2240b4
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.2-r998d20c7t20261201161749h37201e6

Posted by architect-orb · build 14113 · commit 37201e6 · updated in place on every push

@fiunchinho
fiunchinho merged commit 02ce1da into main Dec 1, 2026
18 checks passed
@fiunchinho
fiunchinho deleted the fix-agent-delete-gitkeep branch December 1, 2026 16:42
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