Skip to content

Patch when closed: install skip, no-retry, and activity - #49858

Merged
cdcme merged 2 commits into
feat/39962-patch-when-closedfrom
49417-patch-when-closed-install-skip
Jul 28, 2026
Merged

Patch when closed: install skip, no-retry, and activity#49858
cdcme merged 2 commits into
feat/39962-patch-when-closedfrom
49417-patch-when-closed-install-skip

Conversation

@cdcme

@cdcme cdcme commented Jul 23, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #49417

Makes an "app was open" result on a patch-when-closed policy install a skip rather than a failure:

  • Detects the skip in SaveHostSoftwareInstallResult — policy patch_when_closed + empty pre-install output — and labels the installed_software activity with install_skipped_when_app_open.
  • Doesn't let the skip consume a retry attempt: stores attempt_number = 0 (excluded from the retry-sequence count) and doesn't queue an immediate retry — the next continuous-automation run re-fires.
  • Shows "The app was open" copy in install details, distinct from the generic pre-install-query-failed copy.
  • Keys on the managed policy flag, not on empty output, so an ordinary empty pre_install_query on a non-managed policy still fails and still counts toward the retry limit.

The changes/ entry for this feature lives on the base feature branch per the stacked-PR convention.

Checklist for submitter

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements).
  • Timeouts are implemented and retries are limited to avoid infinite loops.

Testing

  • Added/updated automated tests
  • Where appropriate, automated tests simulate multiple hosts and test for host isolation (updates to one host's records do not affect another)
  • QA'd all new/changed functionality manually
    • Drove the orbit software_install/result endpoint end-to-end against a running server: app-open result → failed_install, activity install_skipped_when_app_open: true, attempt_number = 0, no retry queued, and install details showing "The app was open".
    • Regression: an ordinary empty pre_install_query on a non-managed policy still fails, counts (attempt_number = 1), and queues a retry.

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feat/39962-patch-when-closed@61bae56). Learn more about missing BASE report.

Additional details and impacted files
@@                       Coverage Diff                       @@
##             feat/39962-patch-when-closed   #49858   +/-   ##
===============================================================
  Coverage                                ?   67.91%           
===============================================================
  Files                                   ?     3891           
  Lines                                   ?   248619           
  Branches                                ?    13022           
===============================================================
  Hits                                    ?   168847           
  Misses                                  ?    64553           
  Partials                                ?    15219           
Flag Coverage Δ
backend 69.29% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cdcme
cdcme marked this pull request as ready for review July 23, 2026 21:01
@cdcme
cdcme requested a review from a team as a code owner July 23, 2026 21:01
Comment thread server/service/orbit_test.go Outdated
// createFailingPolicy makes a global policy (optionally patch-when-closed) and marks it failing
// for the host so a retry would be eligible.
createFailingPolicy := func(t *testing.T, host *fleet.Host, patchWhenClosed bool) uint {
policy, err := ds.NewGlobalPolicy(ctx, &user.ID, fleet.PolicyPayload{

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.

I don't think a global policy can also have patch_when_closed (meaningfully). Should this test be using team policies instead?

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.

Yeah, good call! Switched the fixture to a team policy. The direct column set has to stay for now since the create path doesn't accept the flag until the API PR lands, but it's a valid team policy now. 👍

@jkatz01 jkatz01 linked an issue Jul 24, 2026 that may be closed by this pull request
@cdcme
cdcme merged commit 20fdf5d into feat/39962-patch-when-closed Jul 28, 2026
26 checks passed
@cdcme
cdcme deleted the 49417-patch-when-closed-install-skip branch July 28, 2026 15:01
@cdcme cdcme mentioned this pull request Aug 12, 2026
3 tasks
cdcme added a commit that referenced this pull request Aug 14, 2026
**Related issue:** Resolves #51052

Renames the `installed_software` activity detail flag from
`install_skipped_when_app_open` to `skipped_install`, the name Product
approved and the one `docs-v4.91.0` already publishes
(`audit-logs.md:1661`). The implementation (#49858) landed six days
before the activity docs (#49106), so the two diverged; since
patch-when-closed is unreleased, this renames outright rather than
aliasing.

The name is deliberately reason-agnostic: #39178 will set the same flag
for a second skip reason (notify-then-defer), where
`install_skipped_when_app_open` would be false.

Rename only — no behavior change. Covers the JSON tag, the Go field
(`InstallSkippedWhenAppOpen` → `SkippedInstall`), and the frontend,
where all four readers were swept: activity feed, host activity card,
policy automations table, and the install-details modal (including its
`installSkippedWhenAppOpen` prop). No endpoint paths changed.

Deliberately unchanged: `isAppOpenSkip` in `orbit.go` still names the
detection of the app-open case specifically, and the pre-existing
frontend-only `"skipped_install"` display status
(`interfaces/software.ts`) is not an API value — after this rename the
two simply agree.

No changes file: `~unreleased bug`, and
`changes/39962-patch-when-closed` already covers the feature. No
migration: activity details are an opaque `activity_past.details` JSON
blob and no SQL reads this key. A `renameto:` alias was considered and
rejected — aliases are applied before the INSERT, so it would
permanently double-write a never-released key into every row.

> [!IMPORTANT]
> `rc-minor-fleet-v4.91.0` was cut on 2026-08-11 and still carries the
old name. This needs a cherry-pick into that branch before the 4.91.0
cut, or 4.91.0 ships `install_skipped_when_app_open` while its own
reference docs document `skipped_install`.

# Checklist for submitter

## Testing

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

For unreleased bug fixes in a release candidate, one of:

- [x] Confirmed that the fix is not expected to adversely impact load
test results


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Updated installed-software activity handling to consistently identify
installations skipped because the app was open.
* Preserved skipped-install status messages, labels, icons, and detail
visibility across activity views and policy automation tables.

* **Refactor**
* Standardized the activity field name used for skipped installations
across the application.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

Patch when closed: install skip, no-retry, and activity

2 participants