You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
investigate why run_on_stop doesn't work consistently #17108
Unless the provider is configured, it's very likely that either a wrong signal is sent or a timeout is hit early, killing the workspace before shutdown script has started or completed.
You're right, it wasn't. I actually merged a fix for that earlier today: #17110
I wonder if we could add some sort of warning when a stop script is specified and it doesn't complete
Hmm, perhaps we could. We could infer it from script timings and whether or not one was sent in for the stop script. But I'm not sure how/where we'd surface this info though.
I discovered an issued related to this, and I believe it may be what you observed @aslilac. Sometimes shutdown scripts run, other times they don't.
During shutdown the agent seems to be stuck in a loop trying to re-connect to coderd.
@spikecurtis had a few ideas for how to deal with this:
Coderd could be a little more graceful in its communication, and directly tell the agent that it should shut down, rather than unceremoniously killing the connection
When we get the SIGINT, we could tell the agent to stop trying to dial coderd, and proceed with any shutdown scripts it already knows about.
We do probably want both the network message and the signal --- if coderd tells the agent to shut down, you probably don't want it to actually exit until it gets an OS signal, lest it be restarted by K8s or whatever
-- Spike
For now, option 2 may be more robust and easier to implement. Let's say, for arguments sake, the agent loses network connectivity as part of a down provision, then option 1 may not complete as expected.
Activity
matifali commentedon Feb 27, 2025
At least 2 community members also reported this:
https://discord.com/channels/747933592273027093/1329720357472567296/1329720357472567296
mafredri commentedon Mar 26, 2025
@aslilac have you seen #6174 (also #6175)?
Unless the provider is configured, it's very likely that either a wrong signal is sent or a timeout is hit early, killing the workspace before shutdown script has started or completed.
aslilac commentedon Mar 26, 2025
I wonder if we could add some sort of warning when a stop script is specified and it doesn't complete
If that's really all that's going on, our dogfood template isn't set up correctly to allow for
run_on_stopscriptsmafredri commentedon Mar 26, 2025
You're right, it wasn't. I actually merged a fix for that earlier today: #17110
Hmm, perhaps we could. We could infer it from script timings and whether or not one was sent in for the stop script. But I'm not sure how/where we'd surface this info though.
mafredri commentedon Apr 1, 2025
I discovered an issued related to this, and I believe it may be what you observed @aslilac. Sometimes shutdown scripts run, other times they don't.
During shutdown the agent seems to be stuck in a loop trying to re-connect to coderd.
@spikecurtis had a few ideas for how to deal with this:
For now, option 2 may be more robust and easier to implement. Let's say, for arguments sake, the agent loses network connectivity as part of a down provision, then option 1 may not complete as expected.
Down the line, we should also consider #6175.
Here we see that the new workspace build provision has started and invalidated the agent token:
And we can observe that the agent shutdown has actually started:
But the shutdown scripts are never executed and
connecting to coderdis stuck in a loop.fix(agent): improve SSH server shutdown and continue after timeout
fix(agent): ensure SSH server shutdown with process groups (#17227)