From f4d6136236c4cf6d384bf6e0ca38cf5bc2fd5fbb Mon Sep 17 00:00:00 2001 From: Martin Angers Date: Tue, 9 Apr 2024 18:12:51 -0400 Subject: [PATCH] Ignore pending DDM profiles when waiting to release a device (#18159) #18160 # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/` or `orbit/changes/`. - [x] Manual QA for all new/changed functionality --- .../18160-fix-release-device-with-pending-ddm-profiles | 1 + server/worker/apple_mdm.go | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 changes/18160-fix-release-device-with-pending-ddm-profiles diff --git a/changes/18160-fix-release-device-with-pending-ddm-profiles b/changes/18160-fix-release-device-with-pending-ddm-profiles new file mode 100644 index 0000000000..d780f184f3 --- /dev/null +++ b/changes/18160-fix-release-device-with-pending-ddm-profiles @@ -0,0 +1 @@ +* Fixed an issue with automatic release of the device after setup when a DDM profile is pending. diff --git a/server/worker/apple_mdm.go b/server/worker/apple_mdm.go index 01624d85d0..0537af05e8 100644 --- a/server/worker/apple_mdm.go +++ b/server/worker/apple_mdm.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "strings" "time" "github.com/fleetdm/fleet/v4/server/contexts/ctxerr" @@ -238,6 +239,13 @@ func (a *AppleMDM) runPostDEPReleaseDevice(ctx context.Context, args appleMDMArg return ctxerr.Wrap(ctx, err, "failed to get host MDM profiles") } for _, prof := range profs { + // NOTE: DDM profiles (declarations) are ignored because while a device is + // awaiting to be released, it cannot process a DDM session (at least + // that's what we noticed during testing). + if strings.HasPrefix(prof.ProfileUUID, fleet.MDMAppleDeclarationUUIDPrefix) { + continue + } + // if it has any pending profiles, then its profiles are not done being // delivered (installed or removed). if prof.Status == nil || *prof.Status == fleet.MDMDeliveryPending {