fix: add field_manager force_conflicts to all NetworkPolicy resources #156
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-platform!156
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "152-netpol-field-manager"
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?
Summary
field_manager { force_conflicts = true }to all 9kubernetes_manifestNetworkPolicy resourceskubectl patchis used during incident responseChanges
terraform/network-policies.tf: Addedfield_managerblock to netpol_monitoring, netpol_forgejo, netpol_woodpecker, netpol_harbor, netpol_minio, netpol_keycloak, netpol_postgres, netpol_ollama, netpol_cnpg_systemtofu plan Output
No functional infrastructure change.
field_manageris a provider-level directive that controls server-side apply field ownership. Existing resources will not be modified or recreated.Test Plan
tofu fmt -checkpassestofu plan -lock=falseshows no resource changeskubectl patchon any NetworkPolicy followed bytofu applyno longer produces field manager conflict errorsReview Checklist
Related
kubectl patchis used during incident responsekubernetes_manifestresources now haveforce_conflicts = truePR #156 Review
DOMAIN REVIEW
Tech stack: OpenTofu / Terraform Kubernetes provider (
kubernetes_manifestresources)Coverage verification: All 9
kubernetes_manifestNetworkPolicy resources interraform/network-policies.tfreceive thefield_managerblock. Confirmed via grep -- there are exactly 9netpol_*resources and 9NetworkPolicykind declarations in the entireterraform/directory, all in this single file. No NetworkPolicy resources exist elsewhere.Block placement: Each
field_manager { force_conflicts = true }block is placed at the resource top level, immediately after theresourcedeclaration line and before themanifestblock. This is the correct position --field_manageris a top-level attribute ofkubernetes_manifest, alongsidemanifest,depends_on,computed_fields, andwait.HCL syntax: Valid. Three-line block with proper indentation (2-space). Consistent across all 9 resources.
State safety:
field_manageris a provider-level directive controlling server-side apply behavior. It does not modify the resource state or trigger recreation.tofu planshould show zero resource changes, as claimed in the PR body.Semantic correctness:
force_conflicts = trueallows Terraform to take ownership of fields that were previously managed by other field managers (e.g.,kubectl patchduring incident response). This is the correct fix for the field manager conflict errors described in #152.BLOCKERS
None.
This is a pure configuration change with no new functionality, no user input, no secrets, and no auth paths. The BLOCKER criteria (test coverage, input validation, secrets, DRY auth) do not apply.
NITS
None. The diff is 27 lines of identical 3-line blocks added to 9 resources. Clean and mechanical.
SOP COMPLIANCE
152-netpol-field-managerreferences #152)Closes #152)tofu fmt -checkclaimed passing in Test Plantofu plan -lock=falselisted as verification stepPROCESS OBSERVATIONS
Low-risk, high-value fix. Eliminates a class of
tofu applyfailures caused by field manager conflicts after manualkubectl patchduring incident response. Directly improves MTTR -- operators can safely patch NetworkPolicies during incidents without breaking subsequent Terraform runs.The mechanical nature of this change (identical block added to 9 resources) suggests a future DRY opportunity -- a module or
for_eachpattern for NetworkPolicy resources -- but that is out of scope for this bug fix and would be a separate issue.VERDICT: APPROVED
PR #156 Review
DOMAIN REVIEW
Tech stack: OpenTofu / Kubernetes (NetworkPolicy via
kubernetes_manifestprovider)Terraform patterns -- verified correct:
field_manager { force_conflicts = true }is the correct provider-level directive forkubernetes_manifestresources that use server-side apply. When a human doeskubectl patchduring incident response, the field manager ownership changes from Terraform tokubectl. Withoutforce_conflicts = true, the nexttofu applyfails with a field manager conflict error because Terraform refuses to reclaim ownership. This fix is the canonical solution.The block is placed immediately inside the resource block, before
manifest, which is the conventional position and matchestofu fmtexpectations.All 9 NetworkPolicy resources in
terraform/network-policies.tfnow have the block:netpol_monitoringnetpol_forgejonetpol_woodpeckernetpol_harbornetpol_minionetpol_keycloaknetpol_postgresnetpol_ollamanetpol_cnpg_system6 other
kubernetes_manifestresources inmain.tf(PrometheusRule, ServiceMonitor, CNPG Cluster, ScheduledBackup) are intentionally excluded. These resource types are not typicallykubectl patch-ed during incident response, and the issue (#152) is specifically about NetworkPolicy conflicts. Scoping is correct -- no missed resources, no scope creep.No functional infrastructure change.
field_manageris a provider directive, not a manifest field. Existing resources will not be recreated or modified.tofu compliance:
tofu fmtcompliance: indentation and block structure are consistent with the rest of the filetofu planshould show 0 changes (provider-level directive only)BLOCKERS
None.
NITS
None. This is a minimal, well-scoped fix. The diff is +27/-0 (pure additive), touching exactly 1 file.
SOP COMPLIANCE
152-netpol-field-managerreferences issue #152)Closes #152)tofu fmtcompliance noted in Test PlanPROCESS OBSERVATIONS
tofu applyafter manual incident response patches. Currently, anykubectl patchon a NetworkPolicy would cause the next pipeline to fail, requiring manual state intervention. After this fix, Terraform will simply reclaim field ownership and apply cleanly.field_managerblock is a provider-level directive that does not alter the Kubernetes resource state.VERDICT: APPROVED