Skip to content

feat(device): PENDING_DELETION status while client uninstall is in flight - #1794

Open
aliaska-varieva wants to merge 3 commits into
mainfrom
feat/pending-deletion-status
Open

feat(device): PENDING_DELETION status while client uninstall is in flight#1794
aliaska-varieva wants to merge 3 commits into
mainfrom
feat/pending-deletion-status

Conversation

@aliaska-varieva

Copy link
Copy Markdown
Contributor

Summary

Between "dashboard triggered uninstall" and "agent finished uninstalling and deregistered", the device is still alive and heartbeating — so it kept flipping back to ONLINE and looked healthy in the dashboard. This PR makes that window explicit:

  • DeviceStatus.PENDING_DELETION — new status set by ForceClientUninstallService right after the uninstall command is published (machines already DELETED are skipped with a FAILED item instead of publishing a command that could only replay later).
  • MachineStatusService now ignores connect/disconnect/heartbeat events for machines in PENDING_DELETION or DELETED — device-side signals can no longer resurrect a device that is being (or has been) deleted. This is the single funnel for all device-driven status flips (ClientConnectionListener, MachineHeartbeatListener); the management-side offline-detection job only queries ONLINE machines, so it needs no change.
  • The agent's deregistration callback (POST /api/agents/uninstall) still transitions PENDING_DELETIONDELETED unchanged.

Deliberate escape hatch: an explicit /register or /reinstall still resets the status (to PENDING) — a human intentionally reinstalling the client on a machine outranks a stale pending deletion.

Status flow

ONLINE/OFFLINE → (force uninstall published) → PENDING_DELETION → (agent deregisters) → DELETED

Testing

  • mvn test-compile clean across touched modules; no exhaustive switches over DeviceStatus exist, so the new enum value is additive.

🤖 Generated with Claude Code

aliaska-varieva and others added 3 commits August 14, 2026 14:38
…ight

- Force client uninstall marks the machine PENDING_DELETION after
  publishing the command (skips machines already DELETED)
- MachineStatusService ignores connect/disconnect/heartbeat events for
  machines in PENDING_DELETION or DELETED, so the still-running agent
  can't flip the device back to ONLINE/OFFLINE before it uninstalls
- Agent deregistration callback still moves PENDING_DELETION -> DELETED

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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