Add patch_when_closed to GitOps and generate-gitops - #49844
Merged
cdcme merged 7 commits intoJul 28, 2026
Conversation
…install query Thread patch_when_closed through the team-policy create/update API and the update-package endpoint, and resolve the Fleet-managed "is app open" query at install time. Policy create/update: - Add patch_when_closed to the create request, payload mapping, and modify path. - Require type=patch (with a patch_software_title_id) when enabling it. - Auto-set continuous_automations_enabled when patch_when_closed is on, and reject an explicit continuous_automations_enabled=false in the same request. - Persist the column in the INSERT, UPDATE, ApplyPolicySpecs upsert, and the shared policy read column list; add PatchWhenClosed to PolicySpec. Update-package: - Add patch and patch_when_closed (FMA-only) to the request/payload. - Reconcile the title's patch policy: create/update on patch=true, delete on patch=false, keyed on patch_software_title_id. - Reject a direct pre_install_query edit while the managed query owns it. - Return patch_when_closed from GetPatchPolicy. GetSoftwareInstallDetails: - Join the triggering policy and return app_open_query as the pre-install condition only on the policy-automation path when patch_when_closed is set; self-service, manual, and setup-experience installs keep the user query.
Collapse the two-phase planPatchPolicy/applyPatchPolicyPlan (struct, managed method, and both functions) into one reconcilePatchPolicy call. It validates, rejects a managed pre-install query edit, and creates, updates, or deletes the title's patch policy. Keep the FMA-only guard as an early fail-fast at the call site, and run the reconcile at the "persist changes" boundary so a validation error can't leave a stray policy behind. Reconcile re-derives state from the datastore, so a retry after a partial failure converges without special conflict handling. Consolidate the plan/apply tests into TestReconcilePatchPolicy and cover the FMA-only rejection through the update-package flow.
… query in Go Update-package: a newly created patch policy defaults patch_when_closed on (Force patch is the explicit false), matching the documented default. An existing policy keeps its value. GetSoftwareInstallDetails: select the raw pre_install_query, app_open_query, and the triggering policy's patch_when_closed, and pick the managed query in Go instead of a SQL CASE. Policy-automation installs of a patch-when-closed policy get the managed app-open query; every other path keeps the user query.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feat/39962-patch-when-closed #49844 +/- ##
===============================================================
Coverage ? 67.91%
===============================================================
Files ? 3891
Lines ? 248602
Branches ? 13022
===============================================================
Hits ? 168840
Misses ? 64547
Partials ? 15215
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
cdcme
changed the base branch from
49416-patch-when-closed-policy-package-api
to
feat/39962-patch-when-closed
July 23, 2026 20:09
cdcme
force-pushed
the
49418-patch-when-closed-gitops
branch
from
July 23, 2026 20:17
4dddf8c to
1de95db
Compare
…ackage-api' into 49418-patch-when-closed-gitops
jkatz01
reviewed
Jul 24, 2026
| return updatedInstaller, nil | ||
| } | ||
|
|
||
| func (svc *Service) reconcilePatchPolicy(ctx context.Context, payload *fleet.UpdateSoftwareInstallerPayload, installer *fleet.SoftwareInstaller) error { |
Member
There was a problem hiding this comment.
Heads up that I changed this a lot on the 49416-... branch so there will be a merge conflict here for this or the other PR.
jkatz01
approved these changes
Jul 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue: Resolves #49418
Adds
patch_when_closedsupport to GitOps for patch policies and round-trips it throughfleetctl generate-gitops.patch_when_closedin the patch-policy YAML: reject an explicitcontinuous_automations_enabled: falsealongside it (GitOps is declarative — the datastore would otherwise silently force it on), auto-set it when omitted, and reject apre_install_queryon the referenced Fleet-maintained app (Fleet manages that query).patch_when_closedfromfleetctl generate-gitops.Checklist for submitter
SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.Testing
New Fleet configuration settings
Follow this checklist for GitOps-enabled settings:
fleetctl generate-gitops