Skip to content

Redirect FMA installs to the active version after auto-update - #49525

Merged
cdcme merged 3 commits into
mainfrom
fix-49495-stale-fma-installer-id
Jul 18, 2026
Merged

Redirect FMA installs to the active version after auto-update#49525
cdcme merged 3 commits into
mainfrom
fix-49495-stale-fma-installer-id

Conversation

@cdcme

@cdcme cdcme commented Jul 17, 2026

Copy link
Copy Markdown
Member

Related issue: Resolves #49495

Redirects queued Fleet-maintained app installs to the newly-active installer (canceling already-dispatched ones) atomically when an auto-update or pin change flips the active version, and re-resolves install retries to the active installer, so a host no longer installs a superseded cached version.

Checklist for submitter

  • Changes file added for user-visible changes in changes/.
    See Changes files for more information.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • Bug Fixes
    • Fleet-maintained app installs now consistently use the currently active version after automatic promotions, preventing stale installer targeting.
    • Queued installs tied to an older promoted installer are redirected to the newly active installer instead of being canceled.
    • Install retry flows now re-resolve to the active installer at retry time, avoiding stale retries after version changes.
  • Tests
    • Added datastore coverage for active-installer redirection and updated retry tests to verify the correct installer ID is used.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.81%. Comparing base (8a33fcd) to head (b2fd5f1).

Files with missing lines Patch % Lines
server/datastore/mysql/software_installers.go 71.42% 13 Missing and 7 partials ⚠️
server/service/orbit.go 60.00% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #49525   +/-   ##
=======================================
  Coverage   67.81%   67.81%           
=======================================
  Files        3890     3888    -2     
  Lines      247565   247614   +49     
  Branches    13135    13134    -1     
=======================================
+ Hits       167886   167928   +42     
- Misses      64521    64523    +2     
- Partials    15158    15163    +5     
Flag Coverage Δ
backend 69.22% <70.00%> (+<0.01%) ⬆️

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 17, 2026 21:33
@cdcme
cdcme requested a review from a team as a code owner July 17, 2026 21:33
Copilot AI review requested due to automatic review settings July 17, 2026 21:33
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8bcf61b9-72fa-4925-98be-5ef14ca5405e

📥 Commits

Reviewing files that changed from the base of the PR and between aa0679c and b2fd5f1.

📒 Files selected for processing (6)
  • server/datastore/mysql/software_installers.go
  • server/datastore/mysql/software_installers_fma_redirect_test.go
  • server/fleet/datastore.go
  • server/mock/datastore_mock.go
  • server/service/orbit.go
  • server/service/orbit_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • server/datastore/mysql/software_installers_fma_redirect_test.go
  • server/service/orbit_test.go
  • server/datastore/mysql/software_installers.go

Walkthrough

Fleet-maintained installer promotion now redirects queued installs to the newly active version while canceling already-dispatched work. Retry paths resolve frozen installer IDs to the current active installer before enqueueing retries. Auto-update and pinned-version flows rely on this datastore transition, with updated service tests and new MySQL coverage for Fleet-maintained and custom installers.

Possibly related PRs

  • fleetdm/fleet#49519: Also changes active Fleet-maintained installer promotion and updates patch-policy installer data.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main behavior change around redirecting FMA installs after auto-update.
Description check ✅ Passed The description includes the related issue, summarizes the fix, and fills the required checklist items that apply.
Linked Issues check ✅ Passed The changes address #49495 by redirecting queued installs and retry resolution to the active FMA installer version.
Out of Scope Changes check ✅ Passed The modified files stay focused on the active-installer redirect and retry flow, with no evident unrelated scope creep.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-49495-stale-fma-installer-id

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@server/datastore/mysql/software_installers.go`:
- Around line 793-803: Update ResolveActiveInstallerForFrozen to resolve only
when the frozen and active installers share the same non-null
fleet_maintained_app_id; otherwise return frozenInstallerID unchanged. Add the
matching-app filter to the SQL and remove reliance on LIMIT 1 so ordinary
multi-package titles cannot select an arbitrary active sibling.

In `@server/service/orbit.go`:
- Around line 1814-1825: The retry flow must preserve attempt lineage when
ResolveActiveInstallerForFrozen switches software installer IDs. Update the
policy retry logic at server/service/orbit.go lines 1814-1825 and the non-policy
retry logic at lines 1843-1854 so attempts remain associated by stable
policy/title identity or the next attempt ordinal is explicitly carried through
HostSoftwareInstallOptions; ensure both paths continue enforcing the configured
retry cap rather than restarting attempts under the new installer ID.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c92ab38d-2d06-4d4c-a805-060429433e9b

📥 Commits

Reviewing files that changed from the base of the PR and between fd4f92a and 981d300.

📒 Files selected for processing (10)
  • changes/49495-stale-fma-installer-version
  • ee/server/service/maintained_apps_auto_update.go
  • ee/server/service/maintained_apps_auto_update_test.go
  • ee/server/service/software_installers.go
  • server/datastore/mysql/software_installers.go
  • server/datastore/mysql/software_installers_fma_redirect_test.go
  • server/fleet/datastore.go
  • server/mock/datastore_mock.go
  • server/service/orbit.go
  • server/service/orbit_test.go

Comment thread server/datastore/mysql/software_installers.go Outdated
Comment thread server/service/orbit.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

This PR addresses installs of Fleet-maintained apps (FMAs) targeting a stale/superseded cached installer after an auto-update promotion or pin change. It does this by atomically switching the active installer and redirecting still-queued install activities to the newly-active version, and by ensuring install retries re-resolve to the currently-active installer for the title.

Changes:

  • Redirect queued (not-yet-activated) software install activities from the previous active FMA installer to the newly-active one during SetFleetMaintainedAppActiveInstaller.
  • Add ResolveActiveInstallerForFrozen to re-resolve retries to the currently-active installer for the title, used by Orbit retry paths.
  • Add MySQL integration coverage for the redirect + resolve behavior; remove now-redundant side-effect processing in EE pin/auto-update flows.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/service/orbit.go Retry logic now resolves retries to the currently-active installer for the title.
server/service/orbit_test.go Updates retry tests to capture installer ID and adds a case for “active installer after version change” (non-policy).
server/mock/datastore_mock.go Extends datastore mock with ResolveActiveInstallerForFrozen.
server/fleet/datastore.go Adds ResolveActiveInstallerForFrozen to the Datastore interface with docstring.
server/datastore/mysql/software_installers.go Implements active-installer flipping with queued-install redirect + new resolver query.
server/datastore/mysql/software_installers_fma_redirect_test.go New integration test verifying queued redirect, dispatched cancel, and active resolution.
ee/server/service/software_installers.go Removes explicit side-effects call on pin-only changes (now handled by datastore method).
ee/server/service/maintained_apps_auto_update.go Removes explicit side-effects call after promotion (now handled atomically in datastore method).
ee/server/service/maintained_apps_auto_update_test.go Updates expectations to no longer require ProcessInstallerUpdateSideEffects during promotion.
Files excluded by content exclusion policy (1)
  • changes/49495-stale-fma-installer-version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/service/orbit.go
Comment thread server/datastore/mysql/software_installers.go Outdated
jkatz01
jkatz01 previously approved these changes Jul 17, 2026
@cdcme
cdcme merged commit 7cb2399 into main Jul 18, 2026
45 checks passed
@cdcme
cdcme deleted the fix-49495-stale-fma-installer-id branch July 18, 2026 10:01
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 policy installs run against a stale cached version of Fleet-maintained apps

3 participants