Production plans on PRs: branch planner blocked for Forgejo #97
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lab/iac#97
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal: production plans for an iac PR appear on the PR, so nobody needs state or OpenBao credentials on a workstation.
Branch planner can't do it today
tofu-controller v0.16.4 added a Gitea provider to the branch planner (flux-iac/tofu-controller#1780). It can't be reached for a self-hosted Forgejo, and v0.16.6 (2026-10-26) still has the bug.
internal/informer/branch-planner/informer.gocallsprovider.RepoFromURL(obj.Spec.URL)and thenprovider.FromURL.kubescape/go-git-urlv0.0.33. ItsNewGitURLonly knows GitHub, Azure, Bitbucket and GitLab hosts, and returnsrepository host '<host>' not supportedfor anything else.ssh://git@git.animeteamspeak.moe/lab/iac.gitfails before the Gitea provider is ever created.The only override is
WithCustomProviderURLParserFn, an option the branch-planner binary doesn't expose.Options
--git-provider=giteaflag or an annotation on the GitRepository. The Gitea provider itself already exists, so the fix is small.tofu planwith read-only state access and an OpenBaoplannertoken, then posts the plan as a comment. This needs the read access from the local-plan issue.Option 1 keeps plans on the runner that applies, which is the reason to want the branch planner at all.
Correction after reading go-git-url v0.0.33: git.animeteamspeak.moe is not rejected. IsHostGitLab matches any host starting with "git.", so the planner treats Forgejo as GitLab and calls GitLab endpoints. No URL reaches the Gitea provider, because no parser returns "gitea".
A second bug shows up once the provider is reachable: Gitea/Forgejo list merged and closed pull requests when no state is given, so the planner would plan all 41 old lab/iac PRs every poll.
Both fixed in a local fork, ~/go/src/github.com/flux-iac/tofu-controller branch forgejo-provider: a --git-provider-host==gitea flag and Open: true on the list call. Live test against lab/iac lists the 3 open PRs.
Gap found 2026-11-17 (c1 VLAN-20 window, PRs #140/#141): the branch planner ConfigMap on mini lists only openbao-config, kanidm-config and harbor-config. The three routeros-* roots never get PR plans, and they run
approvePlan: autowith no dependsOn, so a router PR merge applies unseen.Workaround used tonight (manual, once): plan-only clones in flux-system (
planOnly: true,destroyResourcesOnDeletion: false,backendConfig.secretSuffix= the real object so they read real state, a GitRepository per PR branch), labelanimeteamspeak.moe/temporary=c1-window-plan, deleted afterwards. Caveats learned:data_json_woupdates, rollback hash re-arm), so plan a master clone as the baseline and diff against it.What a proper fix needs: a read-only router identity for PR plans (REST read user per device, like the #139 monitoring user, plus a read-only Bao policy for the vault_* data the roots touch), routeros-* added to the planner ConfigMap, runners in iac-plans without the apply secrets.