feat(proposal): runonce scripts, eqivalent to `.bashrc.d` but runs only once without any race conditions between several terminals
Description
As IDEs start without loading the login shell for quick startup, previous assumptions about race condition between .bashrc.d startup scripts are not ideal anymore. This introduces a new directory alongside .bashrc.d called .runonce. Scripts placed inside $HOME/.runonce will be executed once in the lifecycle of a workspace, and all task terminals will wait for .runonce scripts to complete before proceeding to execute the .gitpod.yml task commands. While scripts placed inside $HOME/.bashrc.d are used for modifying the shell environment (e.g. exporting env vars) each time a terminal is created and not for starting services.
| Currently | Proposed |
|---|---|
This PR only migrates the VNC startup to .runonce. I plan to create a followup PR to migrate rust, dotnet, mysql, postgres, vnc and yugabyte startup scripts as well (see https://github.com/axonasif/workspace-images/commit/7907f57e1d2cce93e70c05c67b56905b4528c748).
Related Issue(s)
Fixes https://github.com/gitpod-io/workspace-images/issues/1067, https://github.com/gitpod-io/gitpod/issues/18491, slack report, frontapp ticket.
How to test
Open https://gitpod.io/#https://github.com/axonasif/test/tree/vnc_test and check if all task terminals are attempting to start the vnc service.
Or if you want to emulate the race-condition environment from your existing workspace:
# Creates five bash login shells at the same time
docker run -e GITPOD_REPO_ROOT -v /workspace:/workspace -it axonasif/workspace-base-vnc:latest sh -c 'for i in 1 2 3 4 5; do bash -lic "echo Hello from BASH process $i" & done; wait'
Documentation
/hold
Overall it looks good, but it seems we've added too many tricks to bashrc that don't seem regular
Overall it looks good, but it seems we've added too many tricks to bashrc that don't seem regular
@iQQBot would it make sense to sync with @axonasif , to talk about next steps?
@axonasif I'm not sure if the IDE team planned on this work? suggestion: flip this back to draft, and plan next steps with @iQQBot in the context of a Linear issue, in the IDE team, but assigned to @axonasif. cc: @laushinka
if the IDE team planned on this work? suggestion: flip this back to draft, and plan next steps with @iQQBot in the context of a Linear issue, in the IDE team, but assigned to @axonasif
Thanks for mentioning, Kyle!
@axonasif Thank you for the initiative 👍🏽 As per Kyle's suggestion, Asif would you mind putting the issue to the IDE team's Triage? @iQQBot let's bring it up in team sync or teaming. I'd like to understand more, e.g. the tradeoffs of this approach.