Add software > App store > Android: scope software with labels
Goal
| User story |
|---|
| As an IT admin adding software, |
| I want to target hosts based on the labels |
| so that I can make software available for install on a more specific set of hosts. |
Changes
Product
- [ ] UI changes: Figma wireframes
- [ ] CLI (fleetctl) usage changes: No changes
- [ ] YAML changes: No changes
- [ ] REST API changes: No changes
- [ ] Fleet's agent (fleetd) changes: No changes
- [ ] Fleet server configuration changes: No changes
- [ ] Exposed, public API endpoint changes: No changes
- [ ] fleetdm.com changes: No changes
- [ ] GitOps mode UI changes: No changes
- [ ] GitOps generation changes:
fleetctl generate-gitopsshould outputlabels_*for Androidapp_store_appswhen set - [ ] Activity changes: No changes
- [ ] Permissions changes: No changes
- [ ] Changes to paid features or tiers: No changes
- [ ] My device and fleetdm.com/better changes: No changes
- [ ] Usage statistics: No changes
- [ ] Compatibility: No changes
- [ ] Other reference documentation changes: No changes
- [ ] First draft of test plan added
- [ ] Once shipped, requester has been notified
- [ ] Once shipped, dogfooding issue has been filed: https://github.com/fleetdm/fleet/issues/59053
Engineering
- [x] Test plan is finalized
- [ ] Contributor API changes: No changes. This should be a frontend-only change to expose existing backend functionality.
- [ ] Feature guide changes: Update install-app-store-apps.md. "Add an app" section should mention that you can choose a target when adding an Android app. A note similar to "You may also choose to limit which hosts receive auto-updates using the Target option" should be added to the Android section.
- [ ] Database schema migrations: No changes.
- [ ] Load testing: Labels introduce a new pattern where a single UI action can trigger app delivery or removal across many devices simultaneously.
- [ ] Pre-QA load test: The per-host AMAPI batching and stagger mechanism is unchanged. No new load profile introduced.
- [ ] Load testing/osquery-perf improvements: Not required. Osquery perf's Android agent and the AMAPI mock already support app delivery. No new fields or flows to simulate. Load testing should verify that a label-scoped app targeting 1,000+ Android hosts completes delivery without saturating the AMAPI quota to the point of blocking other Android operations.
Additional Context
The actual code change for this issue seems pretty small and frontend-only. The SoftwareAndroidForm (Add flow) needs the DropdownTargetLabelSelector component, and SoftwareAppStoreAndroid needs to fetch custom labels and pass them to the form. We have this patter in the SoftwareVppForm. The edit flow should already work. EditSoftwareModal at renders SoftwareVppForm for all app store apps. It doesn't use SoftwareAndroidForm at all. And SoftwareVppForm already has DropdownTargetLabelSelector. So editing labels on an existing Android app should already work.
Android apps sit in vpp_apps table with platform = 'android', vpp_apps_teams for team assignment, and vpp_app_team_labels for label scoping.
ℹ️ Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".
Risk assessment
- Requires testing in a hosted environment: No. Can be done locally + android load testing osquery.
- Requires load testing: Technically no new backend codepaths. The AMAPI batching and stagger mechanism will be unchanged by this issue. However, we should just run a local load test with the osquery AMAPI to ensure nothing breaks.
- Risk level: Low
- Risk description: Labels make it easier for admins to trigger large-scope changes. But the underlying batching infrastructure (100-host batches, 60s stagger, 429 retry logic) is already in place and is not being modified.
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.
Core flow
Test on both company-owned and BYOD.
FYI, will not work with dynamic labels due to Android not supported via Osquery
- Create a manual label "Android pilot" and add host A (work profile) and host B (fully managed). Leave host C out.
- Add a Google Play app (e.g.
com.google.android.gm) with Custom > Include any > Android pilot. Verify it appears in managed Play Store on A and B, but not C. - Install app on A and B.
- Edit the app to Exclude any > Android pilot. Verify the app is uninstalled from A and B and becomes available on C.
- Install on C.
- Add host C to "Android pilot". Verify the app is uninstalled from C without editing the app.
- Repeat with Include all using two labels.
- Via GitOps, set
labels_include_anyon an Androidapp_store_appsentry, runfleetctl gitops, then runfleetctl generate-gitopsand verify the labels round-trip. - Verify the
added_app_store_appandedited_app_store_appactivities show the label targets. - Verify the host details > Software tab and the software title's install status counts only include in-scope hosts.
UI
- Add Software > App Store > Android: verify Target section renders with "All hosts" and "Custom" radio buttons
- Select "Custom": verify dropdown appears with "Include any", "Exclude any", "Include all" options
- Verify custom labels load in the label checkbox list
- Select labels and submit: verify app is created with correct label scope
- Edit an existing Android app: verify the edit modal shows current label scope and allows changing it
- Edit labels and save: verify the scope change takes effect (in-scope hosts get the app, out-of-scope hosts lose it)
Edge cases
- Set labels when adding the app (UI and API), not only when editing. Scope applies on first delivery.
- Include all with two labels: a host in only one of the labels doesn't get the app. Delete the app: only hosts in both labels have it removed.
- Remove all labels from a scoped app: hosts that were out of scope get the app.
- Label membership changed outside the UI host picker:
- Manual label's
hosts:list changed viafleetctl gitops. - Host vitals label (IdP group or department): change the user's group in the IdP.
- Manual label's
- Transfer an in-scope host to a fleet without the app, then back: app is removed, then re-added with labels respected.
- Enroll a new host, and re-enroll an existing one, that's already in the label: it gets only in-scope apps.
- Two apps with different scopes in the same fleet (App1 → L1, App2 → L2): a host in L1 only has App1 only, after a UI edit and after
fleetctl gitops. - App with managed configuration using
$FLEET_VAR_HOST_*: config goes only to in-scope hosts, and to a host that comes into scope later. - App installed by the end user from managed Google Play, then host goes out of scope: app is uninstalled (confirm intended, since app data is lost).
- Delete a label used by an Android app: blocked with a readable error.
- Dynamic (query) labels never match Android hosts: include → no Android hosts, exclude → all Android hosts. Label picker matches Figma.
- Cross-story check: see #51582. If this story is completed after #51582, you shouldn't be able to manually install an app from the host details page that is out of scope via labels.
- Can you scope a web app (created via API with
com.google.enterprise.webapp.*ID) with labels? The backend should handle it identically. But should be explicitly tested.
GitOps (generate + run)
- [x]
labels_include_anyandlabels_exclude_anyon the same app returns an error - [x]
labels_include_allon an Android app:fleetctl gitopsapplies successfully,fleetctl generate-gitopsround-trips the value - [x] Non-existent label returns an error on
fleetctl gitops --dry-runand on a real run - [x] Create a new fleet with a label-scoped Android app in the same run
- [x] GitOps mode: label targeting in the edit app modal is read-only
Upgrade / data migration
- [x] Upgrade a server with Android apps that have no labels: no apps are removed from hosts
- [x] Upgrade a server where Android apps already have labels stored (accepted via GitOps/edit before this release): confirm whether out-of-scope hosts lose the app after upgrade; add a release note if so
Feature in isolation (MDM / platform independence)
- [x] Android-only server (Apple MDM off, no VPP token): label targeting works
Testing notes
- Removing an app from a host's Android policy uninstalls it (Fleet uses the default allowlist Play Store mode), so scope changes are destructive.
- Label changes on a label with 100+ Android hosts are delivered in batches; watch for Android Management API rate limits. The load test environment can't turn on Android MDM (#52494), so test scale locally with osquery-perf and the AMAPI mock.
Supplemental testing
Confirmation
- [ ] Engineer: Added comment to user story confirming successful completion of test plan (include any special setup, test data, or configuration used during development/testing if applicable).
- [ ] QA: Added comment to user story confirming successful completion of test plan.
- [ ] QA: Determined whether this story needs Playwright automation.
- Needs automation: Yes / No
- If yes, filed a follow-up issue in the :help-qa project with status "Needs automation":
Hey !
Is the targetting of Google Play Store App by labels going to be tackled in this issue aswell ?
@lukeheath why is this in confirm and celebrate? Is there another story that covers this request?
@melpike Because it was a story that was milestoned for 4.92.0, so it got swept into the automation that moves all milestoned stories. I'm not sure what the intended status was, but feel free to remove the milestone and set it back to the appropriate state/column/board.
@Leanngove I noticed in the test plan it mentioned "App with Install during setup and an exclude label: confirm whether the excluded host gets it during setup." There is an issue filed for this feature: https://github.com/fleetdm/fleet/issues/53964 [Setup experience: scope software via labels on Android] Should this be part of the test plan in this issue or deferred until #53964
@ksykulev , the setup flow is a different flow than what this issue targets. I believe Marko's issue is addressing this flow
I didn't add that part to the test plan. I will remove it since it's not applicable here.
QA'd on rc-minor-fleet-v4.95.0 (local dev server). This includes #56204 and the app sync from #57039. The uninstall checks were on 3d5344437e, which includes #57752. I used one Pixel 8a, as a personal device (work profile) and as company-owned. For each step I checked the UI, the request Fleet sent to Google, and the phone.
Everything passes. Details below.
Personal device (work profile)
| Flow | What I did | Expected | Result |
|---|---|---|---|
| Add form | Add software > App store > Android, picked Custom with no label, then a bad app ID | Errors on submit ("Select at least one label" and the app ID error), nothing saved | Pass |
| Include any | Gmail on Include any > Android pilot. Phone out of the label, then added | Nothing sent while out; shows in the work Play Store once added | Pass |
| Exclude any | Slack changed from Include any > pilot to Exclude any > pilot | Slack removed from the phone | Pass. Uninstall covered below |
| Phone leaves a label | Excel on Android L3. Phone removed from L3, then added back | Excel removed, then comes back | Pass. Uninstall covered below |
| Include all | Zoom on Include all > pilot + L2. Phone in pilot only, then added to L2 | Only sent once the phone is in both labels | Pass |
| Back to All hosts | Slack changed back to All hosts | Slack shows up again | Pass |
| Fleet isolation | Teams in the Zero-touch fleet, scoped to pilot. My phone is in pilot but in another fleet | Phone doesn't get Teams | Pass |
| Delete a label in use | Labels > Android pilot > Delete | Blocked with "Couldn't delete. Software uses this label as a custom target..." | Pass |
| Dynamic label | Outlook on Include any > "Apple Silicon macOS hosts", then Exclude any | Include: no Android phones get it. Exclude: all of them do | Pass |
| Two apps, two labels | Word on pilot, Excel on L3. Phone in pilot only, then added to L3 | Word only, then Excel too | Pass |
| Software library and counts | Software > Library and the Word title page | Only this fleet's apps listed; counts are 0 because Android self-service installs aren't tracked | Pass. The host's Software > Library tab says "not supported" for Android, which is by design (#51582) |
| GitOps | New fleet with include_any, include_all and exclude_any apps, then reapplied with changes; generate-gitops export; include + exclude on one app; unknown label; edit modal in GitOps mode |
Saved targets and export match the YAML; both errors rejected in dry run and real run; edit modal read-only | Pass |
| Config with a host variable | Excel config using $FLEET_VAR_HOST_UUID, saved while the phone was out of scope, then the phone added to L3 |
Nothing sent while out; sent with the phone's UUID filled in once in | Pass |
| Web app | Web app made through the API, added with Exclude any > L3, then changed to Include any > L3 | Not sent while excluded; shows up once included | Pass. I had to change the target through the API because of #57959 |
| API add with labels | POST /api/v1/fleet/software/app_store_apps with each target type, two types at once, and an unknown label |
Valid targets saved and applied; invalid ones return 400 and nothing is saved | Pass |
| Re-enroll | Removed the work profile and enrolled again while in pilot, L2 and L3 | Same host and labels; only in-scope apps sent | Pass |
Company-owned
| Flow | What I did | Expected | Result |
|---|---|---|---|
| Enroll | Factory reset, QR enrollment | New host with no labels; only apps that need no label are sent | Pass |
| Include any / Include all | Added to pilot, then to L2 | The matching apps show up | Pass |
| Phone leaves a label | Removed from L2, with an app installed and without | Apps removed and uninstalled | Pass |
| Exclude any, app installed | Slack installed, then changed to Exclude any > pilot | Slack uninstalled | Pass, in about 40 seconds |
| Include all, delete the app | Slack on Include all > L1 + L2, then deleted. Also Zoom on L1 + L2 with the phone in L1 only, then deleted | Slack removed only from phones in both labels; nothing sent for Zoom | Pass |
Uninstall when an app goes out of scope
I ran each check with Slack installed first:
| Flow | Company-owned | Personal (work profile) |
|---|---|---|
| Changed to Exclude any | Pass | Pass. Slack gone within about a minute |
| Phone leaves the label | Pass | Pass. Slack gone a few minutes later |
| App deleted | Pass | Pass |
Upgrade and Android-only server
I upgraded a second local server from 4.94 RC to 4.95 RC. That server has no Apple MDM and no VPP token, so it also covers the Android-only check. Before upgrading, on 4.94, I set up Slack (no labels), Zoom (Include any > A), OneDrive (Exclude any > B) and Word (Include any > C), and installed all four. Then I took the phone out of label C. 4.94 doesn't react to that, so Word stayed on the phone even though it shouldn't.
| Flow | Expected | Result |
|---|---|---|
| Upgrade, apps without labels | Slack stays | Pass |
| Upgrade, apps with labels | Zoom and OneDrive stay. Does Word get removed? | Zoom and OneDrive stay. Word is removed and uninstalled right after the upgrade |
| Android-only: add an app with a label | Excel added with Include any > B, phone not in B: not sent | Pass |
| Android-only: phone joins a label | Phone added to B: Excel shows up, OneDrive (Exclude any > B) is removed | Pass |
About Word: 4.95 now applies label changes that 4.94 skipped, so apps on phones that left a label are removed after the upgrade. PM confirmed this is the correct behavior and doesn't need a release note.
Bug found: you can't edit an Android web app from its software page. Saving always fails with "Couldn't edit. Android web apps don't support configurations.", even with Configuration left empty. It's already in the released version, so it doesn't block this story. Editing through the API works. #57959
Notes:
- After the upgrade, Fleet sends the migration's placeholder
TEMPORARY_FOR_MIGRATIONto Google once per Android phone. Google ignores it and nothing breaks, but it shouldn't be sent. Filed as a low-priority bug: #58298 - On 4.94, the add API accepts labels for Android apps but silently drops them. Only editing the app saved them.
- The PR description says Add stays disabled until a label is picked. It actually stays enabled and shows an error on submit, which matches our other forms.
- Gmail is a built-in app on Pixel, so it can be hidden but not uninstalled. Use another app to test uninstalls.
Load test: ✅ Pass. Label-scoped Google Play app on 20,000 Android hosts (4.95.0 RC 7bddb9a, osquery-perf + AMAPI mock).
- [x] A label-scoped app targeting 1,000+ Android hosts completes delivery without saturating the AMAPI quota to the point of blocking other Android operations
- Include any, 2,000 hosts, added during the enrollment backlog: all delivered, 0 hosts outside the label. Took 2h17m because it waited for the backlog to clear.
- Label membership change, no app edit (+2,000 hosts): first send after 33 s, all delivered in 20 min.
- Flip to exclude any (4,000 removals + 16,000 adds): all 20,000 done in 1h46m, one AMAPI call per host, 0 errors.
- Delete the scoped app: removed from the 7,099 hosts that had it in 35 min, no host in the label touched.
- AMAPI stayed at ~200 calls/min (~17% of the 1,200/min shared cap) with 0 errors, and enrollment and profile delivery kept going.
Issues found
| Issue | Impact on this story |
|---|---|
| #58191 | Every GitOps run re-sends all Android profiles. An app scope change made right after one waits behind the re-send (avg 56 min at 20k hosts). |
Other Android MDM scale bugs from the same run are tracked on #57401.
Notified customer-cisneros-a