When a Gitpod workspace times out, is there a configurable grace period for process cleanup?
0 reputation · 28 Jul 2024, 04:56 UTC
0 reputation · 28 Jul 2024, 04:56 UTC
I am trying to determine whether Gitpod offers a configurable grace period for in-flight processes when an inactivity timeout triggers workspace termination. The goal is to allow long-running tasks—such as test suites or build jobs—to flush state or exit cleanly before the workspace stops, rather than being killed abruptly.
Current documentation covers task-level timeouts in .gitpod.yml and explains that pinning a workspace prevents automatic inactivity stops, but it does not clearly define a universal shutdown grace period for arbitrary user processes. Additionally, Gitpod Classic and Gitpod Flex manage workspace lifecycle differently, so timeout and cancellation semantics may not transfer between the two platforms.
Does Gitpod send a termination signal to user processes before a timed-out workspace enters the stopped state? Is there a configuration option to extend or customize that grace period, and do Classic and Flex behave identically in this regard?
33775 reputation · 28 Jul 2024, 15:54 UTC
Gitpod does not expose a documented, user-configurable grace period for arbitrary in-flight processes when an inactivity timeout stops a workspace. The only user-facing controls are the inactivity timeout itself and workspace pinning. Neither option extends a post-timeout cleanup window.
Confirmed product behavior: you can adjust the inactivity timeout at the user or team level, and pinning a workspace prevents automatic inactivity stops. The .gitpod.yml tasks section controls startup commands only; there is no documented shutdown or pre-termination hook for arbitrary processes.
For Gitpod Classic, workspaces run as Kubernetes pods. That means container termination follows standard Kubernetes pod shutdown semantics—typically a SIGTERM followed by SIGKILL after the pod's termination grace period. However, Gitpod does not surface that grace period as a product setting, nor does it guarantee that arbitrary user processes receive meaningful cleanup time. Treat the Kubernetes grace period as an infrastructure default, not a Gitpod feature.
Gitpod Flex uses a different workspace lifecycle architecture. Its timeout and cancellation semantics are not documented in the same terms as Classic, so you should not assume the two platforms behave identically.
Because documentation does not guarantee a cleanup window and Flex behavior may differ, verify empirically before relying on any signal handling. Create a small script that traps SIGTERM and appends to a file in your project directory, run it in the background, let the workspace time out, then restart the workspace and inspect the file.
#!/bin/bash\ntrap 'echo "SIGTERM at $(date)" >> ./shutdown-test.log; exit 0' TERM\nwhile true; do sleep 1; doneIf the log entry appears after restart, the workspace delivered a termination signal and allowed the trap to run. If the file is empty or missing, the process was killed before it could flush state. Repeat the test separately on Flex if you use both platforms.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.