Skip to content

[YAML] Patch policies: Install new version when app is closed - #49022

Merged
rachaelshaw merged 8 commits into
docs-v4.91.0from
marko/39962-yaml-docs
Jul 22, 2026
Merged

[YAML] Patch policies: Install new version when app is closed#49022
rachaelshaw merged 8 commits into
docs-v4.91.0from
marko/39962-yaml-docs

Conversation

@marko-lisica

@marko-lisica marko-lisica commented Jul 9, 2026

Copy link
Copy Markdown
Member

Documents the proposed only_when_closed key on Fleet-maintained-app
patch policies, for design review ahead of implementation.
@marko-lisica
marko-lisica requested a review from rachaelshaw as a code owner July 9, 2026 13:05
@marko-lisica
marko-lisica marked this pull request as draft July 9, 2026 13:09
@marko-lisica marko-lisica changed the title Draft GitOps YAML design: patch policy install-when-closed (#39962) [YAML] Patch policies: Install new version when app is closed Jul 9, 2026
Comment thread docs/Configuration/yaml-files.md Outdated
type: patch
fleet_maintained_app_slug: zoom/darwin
continuous_automations_enabled: true
only_when_closed: true # default; update is skipped (and retried later) while Zoom is open

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
only_when_closed: true # default; update is skipped (and retried later) while Zoom is open
patch_only_when_closed: true # default; update is skipped (and retried later) while Zoom is open

Comment thread docs/Configuration/yaml-files.md Outdated
Comment thread docs/Configuration/yaml-files.md Outdated
Comment thread docs/Configuration/yaml-files.md Outdated
To automatically install the app when this policy fails, you can add an automation by setting `install_software` to `true`.
To automatically patch the app when this policy fails, whether or not the app is open, set `install_software` to `true`.

To automatically patch the app when this policy fails and app is not open, set `patch_when_closed` to `true`. With this option Fleet adds a read-only pre-install query that skips automatic install while the app is open and retries on the next policy run, and it doesn't retry 2 more times. Also, the `continuous_automations_enabled` is automatically set to `true`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make sense to clarify what happens after those retries hit the maximum. (Does it install even though the app is open, or not install?)

@rachaelshaw rachaelshaw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one note about a clarification we may want to add

Comment thread docs/Configuration/yaml-files.md Outdated
@marko-lisica
marko-lisica requested a review from rachaelshaw July 22, 2026 11:06
Co-authored-by: Marko Lisica <83164494+marko-lisica@users.noreply.github.com>
@rachaelshaw
rachaelshaw merged commit b1ccc2a into docs-v4.91.0 Jul 22, 2026
6 checks passed
@rachaelshaw
rachaelshaw deleted the marko/39962-yaml-docs branch July 22, 2026 16:56
cdcme added a commit that referenced this pull request Jul 28, 2026
**Related issue:** Resolves #49418

Adds `patch_when_closed` support to GitOps for patch policies and
round-trips it through `fleetctl generate-gitops`.

- Validate `patch_when_closed` in the patch-policy YAML: reject an
explicit `continuous_automations_enabled: false` alongside it (GitOps is
declarative — the datastore would otherwise silently force it on),
auto-set it when omitted, and reject a `pre_install_query` on the
referenced Fleet-maintained app (Fleet manages that query).
- Emit `patch_when_closed` from `fleetctl generate-gitops`.

# Checklist for submitter

- [x] Input data is properly validated, `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

- [x] Added/updated automated tests
- [x] QA'd all new/changed functionality manually

## New Fleet configuration settings

Follow this checklist for GitOps-enabled settings:

- [x] Verified that the setting is exported via `fleetctl
generate-gitops`
- [x] Verified the setting is documented in a separate PR to [the GitOps
documentation](https://github.com/fleetdm/fleet/blob/main/docs/Configuration/yaml-files.md)
(#49022)
- [x] Verified that the setting is cleared on the server if it is not
supplied in a YAML file

---------

Co-authored-by: Jonathan Katz <yehonatankatz@gmail.com>
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.

3 participants