gitpod-io/run-gp

lax port management causes confusing error messages

Opened this issue · 0 comments

Describe the bug

Because the docker run uses multiple host ports, including potentially user-declared ones from .gitpod.yml, it can easily get into a situation where they conflict. However, the reported error to the user is

time="2022-12-16T18:57:57-08:00" level=error msg="[starting] workspace image done" duration=357.860717ms failure="docker: Error response from daemon: driver failed programming external connectivity on endpoint rungp-1671245876866762152 (1d3b07052b0809dc49d4a0ae7dcdb3bfc017f706ae675a091e640ad068034768): Bind for 0.0.0.0:8080 failed: port is already allocated."

without any context of why that happened or what action the user can take to resolve it

To Reproduce
Steps to reproduce the behavior:

  1. Download or build run-gp v0.1.7
  2. Change into the suggested go-gin-app directory containing an existing .gitpod.yml
  3. Execute run-gp (optionally with a bunch of --verbose to see what's up)
  4. Observe the bad outcome because "--ide-port int port to expose open vs code server (default 8080)" and the 8080 port in .gitpod.yml collide in the docker run -p 8080:22999 ... -p 8080:8080 workspace-image:latest (it could have happened with the SSHPort, also, it just happened that the getting-started repo and the default IDEPort collided

Expected behavior

My patched version emits:

time="2022-12-16T19:08:08-08:00" level=warning msg="unable to Start Workspace: PortForwarding collision on 8080 (originally 8080) with opts.IDEPort"

because:

  • the StartWorkspace func keeps track of host port allocation and asserts they do not collide
  • the RunE go func stops swallowing err
  • I had to patch run-gp to log the docker run command to even start to investigate this bug

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Linux
  • CPU: amd64
  • Browser N/A
  • Version v0.1.7

Additional context
As mentioned, I have a potential fix for this, and will try to open a PR for it later but wanted to type this up while I had all the context in front of me