Android enrollment debug logging#49043
Conversation
There was a problem hiding this comment.
Pull request overview
Adds additional Android MDM diagnostic logging to help debug enrollment/profile verification and AMAPI policy patch edge cases.
Changes:
- Include non-compliance counts and pending profile counts in Android device policy verification logs.
- Add a warning when a non-modified AMAPI policy patch yields no policy version (leading to nil
IncludedInPolicyVersion). - Log how many hosts/profiles the Android profile reconciler processed per run.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| server/mdm/android/service/pubsub.go | Adds debug/warn logs during device policy verification to surface non-compliance and pending-profile state. |
| server/mdm/android/service/profiles.go | Adds reconciler run summary logging and warns when AMAPI “not modified” responses omit a policy version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if policyRequestUUID == "" { | ||
| var nilPolicyReqCount, nilVersionCount int | ||
| for _, p := range pendingInstallProfiles { | ||
| if p.PolicyRequestUUID == nil { | ||
| nilPolicyReqCount++ | ||
| } | ||
| if p.IncludedInPolicyVersion == nil { | ||
| nilVersionCount++ | ||
| } | ||
| } | ||
| svc.logger.WarnContext(ctx, "no matching policy request UUID found for non-compliance verification", | ||
| "host_uuid", hostUUID, "applied_policy_version", appliedPolicyVersion, | ||
| "pending_profiles", len(pendingInstallProfiles), | ||
| "nil_policy_request_uuid", nilPolicyReqCount, "nil_included_in_policy_version", nilVersionCount, | ||
| "non_compliance_count", len(device.NonComplianceDetails)) | ||
| } |
There was a problem hiding this comment.
We still want the info log for "policy request not found". Not a big deal querying the db one extra time.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis change adds diagnostic logging to Android MDM profile reconciliation and device policy verification code. In profiles.go, an informational log records host and profile counts before bulk upsert, and a warning logs when a policy patch is skipped without a valid policy version. In pubsub.go, additional debug logs report non-compliance counts and pending profile counts during verification, and a warning logs counts of pending profiles missing PolicyRequestUUID or IncludedInPolicyVersion when no matching policyRequestUUID is found. No exported entity signatures are changed. Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/mdm/android/service/profiles.go`:
- Around line 451-455: The warning in profiles.go undercounts affected profiles
because it uses len(bulkProfilesByUUID) before appendWithheld() adds withheld
profiles that also get nil IncludedInPolicyVersion. Update the warning in the
code path around the skip && !policyReq.PolicyVersion.Valid check to count the
full set of profiles that will be affected, including withheld ones, by using
the post-appendWithheld() collection or an equivalent combined count. Keep the
existing WarnContext call and fields such as host_uuid, policy_request_uuid, and
status_code, but replace profile_count with the corrected total.
🪄 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: f92658e9-87a8-49e7-81b7-4b309248ac0a
📒 Files selected for processing (2)
server/mdm/android/service/profiles.goserver/mdm/android/service/pubsub.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #49043 +/- ##
=======================================
Coverage 68.11% 68.12%
=======================================
Files 3731 3731
Lines 235434 235455 +21
Branches 12371 12371
=======================================
+ Hits 160375 160398 +23
+ Misses 60670 60669 -1
+ Partials 14389 14388 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Testing
Summary by CodeRabbit