fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Auto update, pin, and rollback Fleet-maintained apps via UI/API

Open marko-lisica opened this issue 10 months ago • 19 comments

Goal

User story
As an IT admin,
I want to keep my Fleet-maintained apps up-to-date, pin them to a specific version, or roll back to the previous version via UI/API
so that I can make sure my hosts are patched with the latest version of the app or pin them to a specific version.

Changes

Product

  • [x] UI changes: Figma
  • [x] CLI (fleetctl) usage changes: No changes
  • [x] YAML changes: No changes. Can already pin/rollback via GitOps (YAML)
  • [x] REST API changes: #47274 (merged) — adds version body field to existing PATCH /api/v1/fleet/software/titles/:id/package
  • [x] Fleet's agent (fleetd) changes: No changes
  • [x] Fleet server configuration changes: No changes
  • [x] Exposed, public API endpoint changes: No changes
  • [x] fleetdm.com changes: No changes
  • [x] GitOps mode UI changes: Search Figma for mention of "GitOps mode"
  • [x] Activity changes: Extend existing edited_software activity with a pinned_version field (string or null). Display name on the dashboard remains "edited software".
  • [x] Permissions changes: Only maintainers and up can pin.
  • [x] Changes to paid features or tiers: Fleet Premium only
  • [x] My device and fleetdm.com/better changes: No changes
  • [x] Usage statistics: No changes
  • [x] Other reference documentation changes: No changes
  • [x] First draft of test plan added
  • [x] Once shipped, requester has been notified
  • [x] Once shipped, dogfooding issue has been filed. #49742

Engineering

  • [x] Test plan is finalized
  • [x] Contributor API changes: Docs PR #47274 is merged (docs-v4.88.0) — adds version body parameter to PATCH /api/v1/fleet/software/titles/:id/package. Remaining doc work: a follow-up against docs-v4.88.0 to document the extended GET /api/v1/fleet/software/titles/:id response carrying pinned_version and fleet_maintained_versions[]. Owned by #46728.
  • [x] Feature guide changes: Update Fleet-maintained apps guide — replace the "Update the app" delete-and-re-add instructions with new "Auto-update", "Pin a version", and "Roll back" sections describing both the UI workflow (Actions > Versions) and the GitOps version: key (already supported since 4.82). Owned by #46728.
  • [x] Database schema migrations: None. Reuse the existing software_installers.version column and the multi-version unique index (global_or_team_id, title_id, version) added by 20260218175704_FMAActiveInstallers.go.
  • [x] Load testing: Not required. The PATCH .../package endpoint is already load-tested for non-FMA installer updates; softwareInstallerPayloadFromSlug was load-tested for GitOps batch in 4.85. No new endpoint, no new write hot-paths.
  • [x] Pre-QA load test: Not required. Change does not measurably modify Fleet's load profile.
  • [x] Load testing/osquery-perf improvements: N/A
  • [x] This is a premium only feature: Yes. Core service short-circuits with ErrMissingLicense when version is set on the PATCH request; EE service holds the implementation. Test plan verifies both backend (402) and frontend (Versions action item hidden) gating.

ℹ️ Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".

QA

Risk assessment

  • Requires testing in a hosted environment: Yes. Version caching uses S3, which requires a hosted environment with S3 configured (Fleet Cloud or dogfood) to populate multiple cached versions of an FMA for the same team.
  • Risk level: Low
  • Risk description: The backend is a wire-through to an engine that has shipped twice (4.82 #31919 rollback, 4.85 #38988 major-version pin). The PATCH endpoint and softwareInstallerPayloadFromSlug engine already handle every code path the new version field needs. The larger surface area to regression-test is frontend: the new Library section (collapsible rows, Latest/Pinned badges, expanded status counts), the new Versions modal (replaces the older "Pin version" modal design), the new Policies modal opened from the Auto install > pill, and the updated Actions ▾ dropdown — especially the GitOps-mode disabled states.

Test plan

Make sure to go through the list and consider all events that might be related to this story, so we catch edge cases earlier.

Run end-to-end on a real macOS host enrolled to a Premium Fleet:

  1. As admin, add Google Chrome (Fleet-maintained, macOS) to the Workstations team. Verify the Library section shows one collapsed row with Latest + All hosts.
  2. Populate a second cached version of Chrome for the team (via GitOps version: against dogfood, or by inserting a second software_installers row locally). Verify the Library section now shows two collapsed rows: the new active row with Latest + label-count badge; the older row greyed out with no badge and the rollback tooltip on hover.
  3. Install Chrome on a test host (Self-service or auto-install). Verify the latest version installs and the active row's Installed count increments. Expand the row and verify the labels block, hash + copy, and download icon all render and function.
  4. Click Actions ▾ → Versions. Verify the modal opens titled Versions with Automatically update to latest pre-selected. Select Pin to {older version} → Save. Verify the success flash, the modal closes, the older row picks up the Pinned badge, and a new install on a different host pulls the pinned older version. Verify an edited_software activity with the new pinned_version field appears.
  5. Open Versions again → select Pin to major version ({N}) → Save. Verify the Pinned badge sits on the cached row that satisfies the major and the activity feed shows pinned_version: "^N".
  6. Open Versions again → select Automatically update to latest → Save. Verify the newest cached row picks up Latest and the activity feed shows pinned_version: null.
  7. Enable GitOps mode. Verify: Versions item in Actions ▾ is disabled with the GitOps tooltip; per-row trash icon in the expanded Library row is disabled with the tooltip; Edit appearance / Edit software / Patch keep their existing GitOps treatment.
  8. Log in as observer. Verify the Versions action item is hidden and per-row trash icons are absent.
  9. Disable Premium licensing (or hit the core API). Verify PATCH .../package with version returns 402 and the Versions action item is hidden in the UI.
  10. Trigger error path: pin to ^999 (or any unavailable major). Verify the error flash and the modal stays open with the previous selection.
  11. Click the Auto install > pill in the Info card. Verify the Policies modal opens with the associated policies. Verify Done dismisses it.
  12. On a host already running the latest Chrome, pin to the older version → verify the host actually downgrades (not just future installs), and software inventory reflects the older build. This is the "roll back because of bugs" path.
  13. API-level: as observer, observer+, and the gitops role, hit PATCH .../package directly with a version body field → verify the right 403/role-specific error, independent of the UI gating.
  14. GitOps precedence: set a pin via UI/API, then run a GitOps apply that omits the version: field for the same FMA → verify which wins and document the resulting source-of-truth behavior.

Repeat steps 4–6 as a team-level maintainer to confirm permission gating. Observer and observer+ are covered in step 8.

Testing notes

  • A hosted environment with S3 is required to produce a second cached version (see step 2). On a local instance without S3, simulate by inserting a second software_installers row tied to the same title_id and fleet_maintained_app_id.
  • To inspect the active installer row in the database: SELECT id, title_id, version, fleet_maintained_app_id FROM software_installers WHERE title_id = ? AND (global_or_team_id = ? OR global_or_team_id IS NULL) ORDER BY version DESC;
  • Verify the activity feed shows edited_software with a non-null pinned_version after step 4 and null after step 6.

Confirmation

  1. [x] Engineer: Added comment to user story confirming successful completion of test plan.
  2. [ ] QA: Added comment to user story confirming successful completion of test plan.

marko-lisica avatar Jan 20 '26 11:01 marko-lisica

Noah: This was split off from this story in 4.82.0 and pushed into this release.

@marko-lisica Great job splitting this out, just a reminder to tag me when moving stories in milestones so I can make sure we're planning capacity correctly.

lukeheath avatar Jan 22 '26 21:01 lukeheath

@cdcme @georgekarrv Would you please t-shirt size this when you have a moment?

lukeheath avatar Jan 22 '26 21:01 lukeheath

@georgekarrv / @lukeheath Gave this a S assuming #31919 will be done before this is started.

cdcme avatar Jan 23 '26 18:01 cdcme

@mike-j-thomas new pin icon...what do you think?

Image

noahtalerman avatar May 21 '26 19:05 noahtalerman

@noahtalerman, lgtm 📌

mike-j-thomas avatar May 22 '26 05:05 mike-j-thomas

lgtm 📌

@mike-j-thomas sweet! Heads up that I added it to the design system in Figma:

Image

FYI @melpike @marko-lisica @rachaelshaw new pin icon.

noahtalerman avatar Jun 01 '26 12:06 noahtalerman

Sequence diagram for the flow.

Image

cdcme avatar Jun 01 '26 14:06 cdcme

https://us-65885.app.gong.io/call?id=6156917544735063440&highlights=%5B%7B%22type%22%3A%22SHARE%22%2C%22from%22%3A3513%2C%22to%22%3A3562%7D%5D reviewed the USR we never looked at the API it was just checked without pulling it up.

I think it would be much easier to just go with version key being set / cleared like we do in gitops to apply and clear the pins. We shouldn't add a whole new ep just for pin

georgekarrv avatar Jun 09 '26 16:06 georgekarrv

@georgekarrv, that makes sense for me. I will open a new PR.

@cdcme UI changes are ready

marko-lisica avatar Jun 10 '26 12:06 marko-lisica

Test plan

Completed!

  • [x] As admin, add Google Chrome (Fleet-maintained, macOS) to the Workstations team. Verify the Library section shows one collapsed row with Latest + All hosts.
  • [x] Populate a second cached version of Chrome for the team (via GitOps version: against dogfood, or by inserting a second software_installers row locally). Verify the Library section now shows two collapsed rows: the new active row with Latest + label-count badge; the older row greyed out with no badge and the rollback tooltip on hover.
    • ~~Small problem: tooltip is centered on box and not on text~~ intended change
    • ~~Small problem: selection box in Edit software modal still says it cant be done through UI.~~ Fixed
    • ~~Small problem: rows are showing the same filename for different versions.~~ Fixed
  • [x] Install Chrome on a test host (Self-service or auto-install). Verify the latest version installs and the active row's Installed count increments. Expand the row and verify the labels block, hash + copy, and download icon all render and function.
  • [x] Click Actions ▾ → Versions. Verify the modal opens titled Versions with Automatically update to latest pre-selected. Select Pin to {older version} → Save. Verify the success flash, the modal closes, the older row picks up the Pinned badge, and a new install on a different host pulls the pinned older version. Verify an edited_software activity with the new pinned_version field appears.
  • [x] Open Versions again → select Pin to major version ({N}) → Save. Verify the Pinned badge sits on the cached row that satisfies the major and the activity feed shows pinned_version: "^N".
  • [x] Open Versions again → select Automatically update to latest → Save. Verify the newest cached row picks up Latest and the activity feed shows pinned_version: null.
  • [x] Enable GitOps mode. Verify: Versions item in Actions ▾ is disabled with the GitOps tooltip; per-row trash icon in the expanded Library row is disabled with the tooltip; Edit appearance / Edit software / Patch keep their existing GitOps treatment.
  • [x] Log in as observer. Verify the Versions action item is hidden and per-row trash icons are absent.
    • Observer can't download the installer (403), is this intended?
  • [x] Disable Premium licensing (or hit the core API). Verify PATCH .../package with version returns 402 and the Versions action item is hidden in the UI.
  • [x] ~~Trigger error path: pin to ^999 (or any unavailable major). Verify the error flash and the modal stays open with the previous selection.~~ N/A, shouldn't be an error
  • [x] Click the Auto install > pill in the Info card. Verify the Policies modal opens with the linked patch policy names
    • ~~Patch policy only - still shows "Auto install" rather than "Patch policy"~~ Fixed
  • [x] On a host already running the latest Chrome, pin to the older version → verify the host actually downgrades (not just future installs), and software inventory reflects the older build. This is the "roll back because of bugs" path.
    • ~~Some apps like 1Password don't change back to older versions when a newer one is already installed. This might be a problem with the install script, as some apps like 8x8 Work do change between versions without uninstalling first. The host_software_installs record seemed correct, so more investigation is needed.~~ See #48355
  • [x] API-level: as observer, observer+, and the gitops role, hit PATCH .../package directly with a version body field → verify the right 403/role-specific error, independent of the UI gating.
  • [x] GitOps precedence: set a pin via UI/API, then run a GitOps apply that omits the version: field for the same FMA → verify which wins and document the resulting source-of-truth behavior.
  • [x] Repeat steps 4–6 as a team-level maintainer to confirm permission gating. Observer and observer+ are covered in step 8.
  • [x] Updating an FMA when it has custom install/uninstall scripts keeps the custom scripts

jkatz01 avatar Jun 25 '26 19:06 jkatz01

✅ Testing Complete - Issue #38504

All tests passed. Version pinning feature V 4.89.0.

Core Features

  • ✅ Version pinning (specific, major, auto-update)
  • ✅ UI updates correctly
  • ✅ Host deployment verified

Permission Gating

  • ✅ Observer: blocked (403)
  • ✅ Maintainer: allowed
  • ✅ Admin: allowed
  • ✅ Team-scoped users protected

Security

  • ✅ Authentication enforced (401)
  • ✅ Invalid inputs handled (400/404/422)
  • ✅ Cross-team access blocked (403)
  • ✅ Concurrent requests consistent

Ready for release.

Brajim20 avatar Jul 08 '26 20:07 Brajim20

Current behavior Right now, .pkg-based FMA apps cannot be downgraded on macOS. Once a host is on a newer version, there is no supported path back to an earlier version through Fleet. This affects all of our .pkg install scripts, not a single app. Downgrade fails for one of two reasons:

The app self-updates and refuses an older version (e.g. Chrome). The .pkg itself contains logic that blocks installing an older version.

Scope — this is limited to the .pkg subset Of the ~960 macOS FMAs, 819 install without any .pkg — they copy an app bundle from a .dmg or extract a .zip, so no .pkg is involved at any stage. These downgrade cleanly today. Only the .pkg apps are affected. Well-known safe (non-.pkg) picks: .dmg → hdiutil mount + cp -R (true drag-install)

Browsers: firefox, brave-browser, vivaldi, opera, tor-browser, mullvad-browser Apps: docker-desktop, chatgpt, claude, discord, telegram, signal, spotify, vlc, obs Dev/DB: iterm2, bbedit, db-browser-for-sqlite, dbeaver-community, mongodb-compass, tableplus Utilities: keepassxc, bitwarden, nordpass, little-snitch, lulu, rectangle, maccy, stats

.zip → unzip/ditto + cp -R

Editors: cursor, zed, sublime-text, sublime-merge, vscodium Affinity: affinity-designer, affinity-photo, affinity-publisher (and @1 variants) Other: abstract, acorn, sketch, bruno, insomnia

How downgrade works today (non-.pkg apps only) For the apps that do support it, the current flow is:

Pin the version — set the lower version (or major version). Required whenever the installed version is ahead of your target, or when you want to stop the host from updating to a later version. Uninstall the currently installed version. Reinstall — from the Software library (.../software?fleet_id=x) or the end user's My device page, click Install again. Verify the installed version matches the pinned version.

Takeaway At the moment, .pkg FMA apps block users from downgrading. The workaround above only applies to the .dmg/.zip install paths. A fix for the .pkg scripts is what this issue is tracking. https://github.com/fleetdm/fleet/issues/48355

Brajim20 avatar Jul 12 '26 18:07 Brajim20

✅ QA Verification — .dmg FMA downgrade/rollback (Amazon DCV)

Fleet version 4.89.0
Host qa.fleetdm.com/hosts/592
App Amazon DCV (nice-dcv-viewer, .dmg, arm64)

Tested the full update → rollback round trip on a .dmg-based FMA to confirm version pinning + reinstall behave correctly.

Steps

  • [x] Enrolled host 592
  • [x] Installed lower version nice-dcv-viewer-2024.0.8004.arm64.dmg and pinned it
  • [x] Verified 2024.0.8004 on the actual host
  • [x] Moved pin to higher version nice-dcv-viewer-2025.0.8846.arm64.dmg and reinstalled
  • [x] Verified update landed (2025.0.8846) on the host
  • [x] Moved pin back to 2024.0.8004 and reinstalled to roll back
  • [x] Verified host returned to 2024.0.8004

Result

Update and rollback both work for this .dmg FMA — pinning to a lower version and reinstalling correctly downgrades the app on the host. No version-check blocking like the .pkg case in #48355.

Brajim20 avatar Jul 12 '26 18:07 Brajim20

✅ QA Verification — .dmg FMA uninstall + reinstall with "Pin to major version" (Amazon DCV)

Fleet version 4.89.0
Host qa.fleetdm.com/hosts/592
App Amazon DCV (nice-dcv-viewer, .dmg, arm64)
Team Living on the EDGE

Same host, same instance, same Fleet version throughout. Focus: the Pin to major version option in the Versions modal.

Available versions in library

  • nice-dcv-viewer-2025.0.8846.arm64.dmg — 2025.0.8846 (latest)
  • nice-dcv-viewer-2024.0.8004.arm64.dmg — 2024.0.8004

Steps

  • [x] Pinned to specific version 2024.0.8004 and installed it
  • [x] Verified 2024.0.8004 on the actual host
  • [x] Uninstalled the app
  • [x] Set pin to Pin to major version (2025) and installed
  • [x] Verified the 2025 major-line version (2025.0.8846) installed on the host

Result

Uninstall followed by Pin to major version + reinstall works correctly for this .dmg FMA — selecting the major-version pin resolves to the latest release in that major line (2025.0.8846) and installs cleanly after the prior version was removed.

Brajim20 avatar Jul 12 '26 19:07 Brajim20

Hey @andreasn-work and @shc-sync, we shipped this story in 4.89.

marko-lisica avatar Jul 22 '26 14:07 marko-lisica

With each version's dawn, Apps updated, pinned, rolled back, Cloud city stays strong.

fleet-release avatar Jul 22 '26 14:07 fleet-release

notifed both customers of the update

andreasn-work avatar Jul 22 '26 16:07 andreasn-work

Notified customer-rembrandt - closing issue

shc-sync avatar Jul 22 '26 18:07 shc-sync

In Cloud City's glow, Apps pin, update, roll back smooth. Fleet sails, ever flow.

fleet-release avatar Jul 22 '26 18:07 fleet-release