Skip to content

Remove apple profile and decl from bulk set pending - #46321

Merged
MagnusHJensen merged 4 commits into
mainfrom
remove-apple-profile-decl-from-bulk-set-pending
May 29, 2026
Merged

Remove apple profile and decl from bulk set pending#46321
MagnusHJensen merged 4 commits into
mainfrom
remove-apple-profile-decl-from-bulk-set-pending

Conversation

@MagnusHJensen

@MagnusHJensen MagnusHJensen commented May 28, 2026

Copy link
Copy Markdown
Member

Follow up work as discovery made on the Apple reconciler changes.

One more follow up PR will come with a clean up of all old and unused code.

Summary by CodeRabbit

  • Tests

    • Updated integration tests to use batched reconciliation workflows instead of direct database manipulation.
    • Improved test determinism by explicitly awaiting async profile-schedule triggers before state assertions.
    • Enhanced test failure diagnostics with more detailed profile comparison messages.
  • Chores

    • Marked internal reconciliation methods for future deletion with TODO annotations.

Review Change Stack

@codecov

codecov Bot commented May 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.76%. Comparing base (b42a154) to head (9fa5db1).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46321      +/-   ##
==========================================
- Coverage   66.90%   66.76%   -0.14%     
==========================================
  Files        2797     2797              
  Lines      223494   223484      -10     
  Branches    11297    11297              
==========================================
- Hits       149519   149206     -313     
- Misses      60432    60735     +303     
  Partials    13543    13543              
Flag Coverage Δ
backend 68.50% <100.00%> (-0.17%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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.

@MagnusHJensen

Copy link
Copy Markdown
Member Author

Vuln test unrelated failure

@MagnusHJensen
MagnusHJensen force-pushed the remove-apple-profile-decl-from-bulk-set-pending branch from a3e1589 to 960ff51 Compare May 29, 2026 07:52
@MagnusHJensen
MagnusHJensen marked this pull request as ready for review May 29, 2026 07:53
@MagnusHJensen
MagnusHJensen requested a review from a team as a code owner May 29, 2026 07:53
Copilot AI review requested due to automatic review settings May 29, 2026 07:53

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

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.

Pull request overview

This PR removes Apple configuration profile + DDM declaration side effects from BulkSetPendingMDMHostProfiles, shifting expectations to the reconciliation crons/batched reconcilers, and updates integration/datastore tests accordingly.

Changes:

  • Updates MDM integration tests to explicitly run the profile schedule/reconcilers instead of relying on synchronous “bulk set pending” behavior.
  • Switches Apple DDM reconciliation tests to ReconcileAppleDeclarationsBatched.
  • Removes large datastore tests that asserted legacy BulkSetPendingMDMHostProfiles behavior, and adjusts remaining tests for the new flow.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
server/service/integration_mdm_test.go Tweaks profile assertion to improve failure output via require.Len.
server/service/integration_mdm_profiles_test.go Runs profile schedule in more places; adjusts expectations for pending operations and Fleet-managed profiles.
server/service/integration_mdm_ddm_test.go Uses batched Apple declaration reconciler and removes now-invalid immediate host profile assertions.
server/datastore/mysql/mysql.go Adds a TODO comment on a test hook field.
server/datastore/mysql/microsoft_mdm_test.go Updates Windows LocURI protection test to run the Windows reconciler instead of calling BulkSetPendingMDMHostProfiles.
server/datastore/mysql/microsoft_mdm_eager_test.go Marks Windows eager-hook helpers as TODO for deletion.
server/datastore/mysql/mdm.go Stops bulk “pending” work for Apple (Android-only), leaves Windows eager hook for tests, and removes Apple declaration bulk-set logic.
server/datastore/mysql/mdm_test.go Removes legacy bulk-set-pending tests; narrows remaining coverage to Android-only behavior.
server/datastore/mysql/apple_mdm.go Marks bulkSetPendingMDMAppleHostProfilesDB as slated for deletion and suppresses unused lint.
server/datastore/mysql/apple_mdm_test.go Updates several tests to use batched reconcilers; adds ABM asset setup in some test paths.
Comments suppressed due to low confidence (1)

server/datastore/mysql/mdm.go:894

  • The comment above BulkSetPendingMDMHostProfiles still describes Apple profiles/declarations being reconciled eagerly in this method, but the implementation now only updates Android (and optionally triggers a Windows test hook). Updating this comment avoids misleading future readers about what this function actually does.
// TODO(MHJ): Document the oddity this now only handles Android
func (ds *Datastore) BulkSetPendingMDMHostProfiles(
	ctx context.Context,
	hostIDs, teamIDs []uint,
	profileUUIDs, hostUUIDs []string,

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

Comment thread server/datastore/mysql/apple_mdm_test.go
Comment thread server/datastore/mysql/apple_mdm_test.go
Comment thread server/service/integration_mdm_profiles_test.go
Comment thread server/datastore/mysql/mdm.go
@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

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: 7719f1c7-e01a-4c7b-a92a-740b62612f72

📥 Commits

Reviewing files that changed from the base of the PR and between 960ff51 and 9fa5db1.

📒 Files selected for processing (3)
  • server/datastore/mysql/apple_mdm_test.go
  • server/datastore/mysql/mdm_test.go
  • server/service/integration_mdm_profiles_test.go
💤 Files with no reviewable changes (1)
  • server/datastore/mysql/apple_mdm_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • server/service/integration_mdm_profiles_test.go

Walkthrough

This PR reduces the shared bulk pending-host-profile helper to Android-only and marks the Apple helper for deletion, deprecates Windows eager-hook test helpers, and updates datastore and service tests to call batched reconcilers (ReconcileAppleDeclarationsBatched, ReconcileAppleProfilesBatched, ReconcileWindowsProfiles). Tests are wired with MDMAppleCommander, mocked KV where required, include ABM asset setup, and integration tests now await the profile-schedule trigger before asserting host profile state.

Possibly related PRs

  • fleetdm/fleet#45573: Implements the ReconcileAppleProfilesBatched and ReconcileAppleDeclarationsBatched batched reconciliation service methods that this PR now invokes throughout the test suite.
  • fleetdm/fleet#46111: Also modifies bulkSetPendingMDMHostProfilesDB behavior and addresses cleanup of stale pending MDM profiles during global disable operations.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and lacks required details such as issue reference, testing confirmation, and migration/configuration checks from the template. Complete the PR description by adding a related issue number, checking appropriate boxes from the template (testing, database migrations if applicable), and providing more context about the changes.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: removing Apple profile and declaration handling from the bulk set pending operations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 remove-apple-profile-decl-from-bulk-set-pending

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 and usage tips.

@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/apple_mdm_test.go`:
- Around line 6554-6558: The test contains a dead setup: a local
mock.AdvancedKVStore assigned to mockKV and its MGetFunc configured but never
used because ReconcileAppleDeclarationsBatched(ctx, ds, commander, ds.logger)
does not accept or use mockKV; remove the unused mockKV creation and MGetFunc
assignment from the declaration reconcile test blocks (leave the profiles tests
that call ReconcileAppleProfilesBatched unchanged) so the test only sets up
mocks actually passed to or used by ReconcileAppleDeclarationsBatched.

In `@server/datastore/mysql/microsoft_mdm_eager_test.go`:
- Line 26: Do not delete the deprecated Windows eager-test helpers yet: restore
or keep bulkSetPendingMDMWindowsHostProfilesForTests,
EnableTestWindowsEagerHook, and the eager-hook plumbing (testWindowsEagerHook
and its invocation) so existing tests still compile; add a clear TODO comment
referencing the remaining test call-site in mdm_test.go that must be migrated
before removal, and ensure service.ReconcileWindowsProfiles usages remain
unchanged—only remove these helpers after
bulkSetPendingMDMWindowsHostProfilesForTests call sites are migrated and tests
updated.
🪄 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: bc63896a-dae1-465d-b328-439442d2702b

📥 Commits

Reviewing files that changed from the base of the PR and between b42a154 and 960ff51.

📒 Files selected for processing (10)
  • server/datastore/mysql/apple_mdm.go
  • server/datastore/mysql/apple_mdm_test.go
  • server/datastore/mysql/mdm.go
  • server/datastore/mysql/mdm_test.go
  • server/datastore/mysql/microsoft_mdm_eager_test.go
  • server/datastore/mysql/microsoft_mdm_test.go
  • server/datastore/mysql/mysql.go
  • server/service/integration_mdm_ddm_test.go
  • server/service/integration_mdm_profiles_test.go
  • server/service/integration_mdm_test.go

Comment thread server/datastore/mysql/apple_mdm_test.go Outdated
Comment thread server/datastore/mysql/microsoft_mdm_eager_test.go
})
}

// TODO(MHJ): Document the oddity this now only handles Android

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 be worth dropping a note in #g-power-to-pc about this I saw them making some other Android profile reconciliation changes

@MagnusHJensen
MagnusHJensen merged commit 4c7f9f4 into main May 29, 2026
42 checks passed
@MagnusHJensen
MagnusHJensen deleted the remove-apple-profile-decl-from-bulk-set-pending branch May 29, 2026 14:24
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