Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add notes/todos
  • Loading branch information
mafredri committed Mar 6, 2023
commit a57877a6ade47b6360ef8fec04338d11c13e19ef
4 changes: 4 additions & 0 deletions agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1318,9 +1318,12 @@ func (a *agent) Close() error {

// Close services before running shutdown script.
// TODO(mafredri): Gracefully shutdown:
// - Cancel startup script, if running
// - Close active SSH server connections
// - Close processes (send HUP, wait, etc.)

// TODO(mafredri): Only run shutdown script if the agent is 'ready'?

lifecycleState := codersdk.WorkspaceAgentLifecycleOff
if metadata, ok := a.metadata.Load().(agentsdk.Metadata); ok {
scriptDone := make(chan error, 1)
Expand Down Expand Up @@ -1359,6 +1362,7 @@ func (a *agent) Close() error {
// Set final state and wait for it to be reported because context
// cancellation will stop the report loop.
a.setLifecycle(ctx, lifecycleState)
// TODO(mafredri): What if the agent token is revoked, build outdated, etc.?
for s := range a.lifecycleReported {
if s == lifecycleState {
break
Expand Down