Skip to content

Android enrollment debug logging#49043

Open
ksykulev wants to merge 2 commits into
mainfrom
android-logging
Open

Android enrollment debug logging#49043
ksykulev wants to merge 2 commits into
mainfrom
android-logging

Conversation

@ksykulev

@ksykulev ksykulev commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Testing

  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • Bug Fixes
    • Improved Android MDM device policy logging during profile reconciliation and verification, including host and profile counts.
    • Added clearer warnings when policy updates are skipped while returning an invalid policy version, preventing missing policy metadata from going unnoticed.
    • Enhanced verification diagnostics with more detail on pending/failed/non-compliant profiles and warnings when expected policy request details cannot be matched.

Copilot AI review requested due to automatic review settings July 9, 2026 15:40
@ksykulev ksykulev requested a review from a team as a code owner July 9, 2026 15:40

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

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.

Comment on lines +1128 to +1143
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))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We still want the info log for "policy request not found". Not a big deal querying the db one extra time.

Comment thread server/mdm/android/service/profiles.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 9, 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: e1b78da6-548f-43e2-ad9c-e88afd1db4e2

📥 Commits

Reviewing files that changed from the base of the PR and between 540b225 and 4e36f67.

📒 Files selected for processing (1)
  • server/mdm/android/service/profiles.go
✅ Files skipped from review due to trivial changes (1)
  • server/mdm/android/service/profiles.go

Walkthrough

This 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

  • fleetdm/fleet#47223: Also changes Android profile reconciliation in server/mdm/android/service/profiles.go, overlapping with the same reconciliation flow and bulk profile handling path.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only covers manual QA and omits the required issue link and most checklist sections. Add the related issue and complete or remove each checklist section required by the template, including testing and any applicable safety items.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the Android logging changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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 android-logging

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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between 232c433 and 540b225.

📒 Files selected for processing (2)
  • server/mdm/android/service/profiles.go
  • server/mdm/android/service/pubsub.go

Comment thread server/mdm/android/service/profiles.go
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.09091% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.12%. Comparing base (232c433) to head (4e36f67).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
server/mdm/android/service/pubsub.go 68.75% 4 Missing and 1 partial ⚠️
server/mdm/android/service/profiles.go 33.33% 3 Missing and 1 partial ⚠️
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     
Flag Coverage Δ
backend 69.73% <59.09%> (+<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.

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.

2 participants