feat(windows-rdp): add RDP keep-alive to extend workspace deadline #710
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
/claim #200
Summary
Adds an opt-in
keepalivefeature to the existingwindows-rdpmodule that prevents workspace autostop during active RDP sessions.How it works
When
keepalive = true, a background PowerShell script (coder_script) runs on workspace start that:keepalive_intervalseconds (default: 30) usingGet-NetTCPConnection -LocalPort 3389 -State EstablishedPUT /api/v2/workspaces/{workspace_id}/extendusing theCODER_AGENT_TOKENthat the Coder agent sets automaticallyThis uses the manual activity bump API recommended by @matifali in #200 (comment).
Why this approach
CODER_AGENT_TOKENrather than relying on stdout/stderr,coder stat, or registry keys (which only keep the TCP connection alive but don't tell Coder the workspace is active)keepalive = truefalse, no behavior change for existing userscoder_scriptresource, two new variablesUsage
Changes
main.tf: Addedkeepalive(bool) andkeepalive_interval(number) variables, conditionaldata.coder_workspacedata source, andcoder_script.windows-rdp-keepaliveresourcerdp-keepalive.ps1.tftpl: PowerShell script that monitors port 3389 and calls the extend APImain.tftest.hcl: Terraform plan tests for the new feature (and base module)main.test.ts: TypeScript tests verifying keepalive script creation and contentREADME.md: Version bump to 1.4.0, added keep-alive usage exampleTest plan
terraform test -verbosepasses in the module directorybun test main.test.tspasses (keepalive script creation, content validation, interval customization)keepalive = trueon a Windows workspace, connect via RDP, verify workspace deadline extends in Coder dashboard