fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Turn off MDM option in UI is disabled when host is offline

Open ddribeiro opened this issue 1 year ago • 6 comments

  • @noahtalerman: User requested this because you can't click the "Turn off MDM" button if the host is offline. This felt like a bug. Why not? MDM commands like Lock and Wipe can be run when the host is offline.
    • @noahtalerman: In the interim the user can hit the Turn off MDM API endpoint: https://fleetdm.com/docs/rest-api/rest-api#turn-off-mdm-for-a-host
    • @noahtalerman: Eventually Fleet could enable the "Turn off MDM" button in the UI when the host is offline.

Goal

User story
As a Fleet user on the Host details page,
I want to turn off MDM even when a macOS device is offline
so that the command is queued and runs when it's back online.
  • [x] Pull request: #46651.

ddribeiro avatar Jan 07 '25 20:01 ddribeiro

@ddribeiro this is the expected behavior. We built it this way when we shipped the first iteration of turning off MDM and I don't think we've changed it since.

Can you please update this bug into a feature request? Thanks!

noahtalerman avatar Jan 08 '25 17:01 noahtalerman

Copying and pasting the original bug report here for context: Fleet version: 4.61.0

Web browser and operating system: Safari 18.2, macOS 15.2


💥  Actual behavior

When a macOS host is offline, the option to turn off MDM from the Actions menu on that host's details page is disabled.

🧑‍💻  Steps to reproduce

  1. Enroll a test macOS host in MDM. It does not matter if the MDM enrollment is automated or manual.
  2. Shut down the host, wait for Fleet to report that the host is offline.
  3. Click the Actions menu on the host's details page and observe that turn off MDM is grayed out.
  4. With the host still shut down, use the Turn off MDM for a host API endpoint to turn off MDM for the test host. The API should return a 200.
  5. Power on the test host, log in, and observe that after a few seconds, a notification appears that says the device was removed from management. The Fleet enrollment profile should be removed from the device.

🕯️ More info (optional)

Since Fleet seems to have the capability to queue up "Turn off MDM" actions via the API, it doesn't seem like the option should be disabled in the UI. I'm not sure if this was a deliberate choice when designing the feature, but it seems like a bug to me.

ddribeiro avatar Jan 13 '25 16:01 ddribeiro

Problem

As a Fleet admin, I want to remotely turn off MDM on a host using the Fleet UI. Today, I am able to do this, but only when the host is online. If the host is offline, the option to Turn off MDM from the Actions menu on the host's details page is disabled. This means I have to wait for the host to come online to turn off MDM.

What have you tried?

I tried to turn off MDM on an offline host, but the option in the Fleet UI was disabled.

Additionally, I can use the Fleet API (Turn off MDM for a host) to perform this action when a host is offline. The command to turn off MDM gets queued up and delivered when the host comes online.

Potential solutions

Fleet admins should be able to click Actions > Turn off MDM for all MDM-enrolled hosts, regardless of whether or not they are online.

What is the expected workflow as a result of your proposal?

As a result of this workflow, a Fleet admin who wants to turn off MDM on a host would not need to worry about whether the host is online. They would be able to select Actions > Turn off MDM if the host is offline. Offline hosts would have that action queued up, and it would get delivered when it comes back online.

noahtalerman avatar Jan 15 '25 19:01 noahtalerman

@georgekarrv This has been tested and is ready for review.

spalmesano0 avatar Jun 08 '26 14:06 spalmesano0

The core feature is verified; Turn off MDM is now enabled for offline macOS hosts. The unenroll command queues and delivers when the host reconnects, matching iOS/iPadOS. Verified in UI on both an online and an offline macOS host.

Verification

  • Offline macOS host: can turn off MDM via the Actions menu
  • Online macOS host: unchanged
  • A single offline turn-off queues exactly one RemoveProfile and writes one mdm_unenrolled activity, and delivers on reconnect - the device showed "removed from management" on wake
  • turn-off is not durable for ADE hosts - an ADE will re-enroll via DEP almost immediately on wake, as turning off MDM does not release or unassign the device in Apple Business Manager

Issue Found

Sending multiple "Turn off MDM" commands on an offline host queues duplicate unenroll commands and activities: https://github.com/fleetdm/fleet/issues/50103.

The action stays enabled after the first click (the host flips to Off server-side, but the Actions dropdown keeps stale enrollment state and doesn't refetch) and there is no server-side dedup, so N clicks = N RemoveProfile commands + N mdm_unenrolled activities (confirmed 5-for-5; host already Off after click 1). Low impact on manually-enrolled hosts (activity-feed + command-queue noise). Higher on ADE hosts: the stale queued unenrolls can land after the device has re-enrolled via DEP, tearing down the fresh enrollment and cycling it through an unenroll/re-enroll loop.

chrstphr84 avatar Jul 28 '26 23:07 chrstphr84

Offline host rests, "Turn off MDM" button shines, Ease in every click.

fleet-release avatar Aug 06 '26 02:08 fleet-release