fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.02k stars 419 forks source link

Backend: Prefill local account oobe macos setup #17401

Closed georgekarrv closed 6 months ago

georgekarrv commented 7 months ago
georgekarrv commented 7 months ago

Hey team! Please add your planning poker estimate with Zenhub @dantecatalfamo @ghernandez345 @gillespi314 @jahzielv @mna @roperzh

roperzh commented 6 months ago

@mna @ghernandez345 one thing I want to note that might help, the nano queue has a priority field:

https://github.com/fleetdm/fleet/blob/5c72cea3deecc3bee80f83e1d94be38bc2da1b74/server/datastore/mysql/schema.sql#L898

that might come in handy to achieve the order specified in the issue:

image
mna commented 6 months ago

@roperzh Just to sanity-check my understanding with you for that priority approach, as I don't think I grasp the nanomdm's flow as well as you:

If that's the case (that only NotNow is a problem), I think we could relatively easily handle this case by not returning the next command when we receive a NotNow and there is at least one command available with a priority > 0. Unless of course we want to release the device only after osquery verification, but I don't think that's the case?

roperzh commented 6 months ago

@mna what you described is exactly my understanding!

nanomdm does not store "Idle" statuses

to add more color to this, in case it helps. Idle is how the device starts the MDM session, so it's never a "result" of another command.

Do we retry commands that result in errors? If not, then this is a final state and I think the only problematic status (that could mess the ordering) would be "NotNow"?

currently we don't! we do retry things (eg: failed profiles) but we use a new command to retry those, so I think what you described is exactly right.

If that's the case (that only NotNow is a problem), I think we could relatively easily handle this case by not returning the next command when we receive a NotNow and there is at least one command available with a priority > 0. Unless of course we want to release the device only after osquery verification, but I don't think that's the case?

this sounds reasonable to me. I'm not sure if this is a problem, but the only danger I see with using priority is that every time we enqueue a command, we also send a push notification to the device.

if we don't enqueue all the commands we need delivered in order in the same transaction, then the device could reach out and get commands out of order (if that makes sense)

mna commented 6 months ago

@roperzh

the only danger I see with using priority is that every time we enqueue a command, we also send a push notification to the device. if we don't enqueue all the commands we need delivered in order in the same transaction, then the device could reach out and get commands out of order (if that makes sense)

Ah right, good call... That's going to be a problem.

roperzh commented 6 months ago

@mna that one is tricky... spitballing anything that comes to mind, in case any of this helps:

mna commented 6 months ago

@roperzh thanks for helping thinking this through, I know you're super busy with high-priority work too, I appreciate it! Did a bit more digging and it looks like all DEP commands get sent here: https://github.com/fleetdm/fleet/blob/61544f4beacb21570ef4cffbfa29c199fb8b491d/server/worker/apple_mdm.go#L83

So I think it would be doable to send them all in one transaction with the relevant priorities in this scenario. Only thing it wouldn't cover, and I'm not sure how easily we could, is the delivery of profiles - I assume those are profiles for the team the host enrolls in? And those run in the ReconcileAppleProfiles job so it's async and runs every 30s. (maybe by enqueuing another worker job to run later, and hope that by then - and with the help of some retries - all profiles have been delivered)

I'll try to go down that route, let me know if you see any concerns/blockers with it but otherwise I'll try to leave you alone! :D

fleet-release commented 6 months ago

In the cloud city, Fleet eases Mac setup steps, Devices freed, users rest.