Skerit
Skerit
CCoder.com
Created by Skerit on 9/7/2022 in #help
Using a template without an explicit `user` breaks the workspace container
When starting the example docker-code-server as-is, I get this chdir - no such file or directory error:
2022-09-05 10:58:46.515 [WARN] <./agent/agent.go:170> (*agent).run.func1 agent script failed ...,
"error": run:,
github.com/coder/coder/agent.(*agent).runStartupScript,
/home/runner/work/coder/coder/agent/agent.go:375,
- chdir /home/skerit: no such file or directory,
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] using fake (no-op) tun device,
2022-09-05 10:58:46.518 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] magicsock: starting endpoint update (derp-map-update),
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] using fake (no-op) OS network configurator,
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] using fake (no-op) DNS configurator,
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 dns: using dns.noopManager
2022-09-05 10:58:46.515 [WARN] <./agent/agent.go:170> (*agent).run.func1 agent script failed ...,
"error": run:,
github.com/coder/coder/agent.(*agent).runStartupScript,
/home/runner/work/coder/coder/agent/agent.go:375,
- chdir /home/skerit: no such file or directory,
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] using fake (no-op) tun device,
2022-09-05 10:58:46.518 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] magicsock: starting endpoint update (derp-map-update),
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] using fake (no-op) OS network configurator,
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 [v1] using fake (no-op) DNS configurator,
2022-09-05 10:58:46.516 [DEBUG] (tailnet.wgengine) <./tailnet/conn.go:521> Logger.func1 dns: using dns.noopManager
I made an issue for it on Github https://github.com/coder/coder/issues/3870 There we found out the HOME environment somehow gets set to the username of user 1000 of the host server: (It's set to /home/skerit when it should be /home/coder)
[skerit@test1 coder]$ env
HOSTNAME=test1
PWD=/home/coder
HOME=/home/skerit
ENTRYPOINTD=/entrypoint.d
LANG=en_US.UTF-8
CODER_AGENT_TOKEN=xxx
TERM=xterm
USER=coder
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/sbin/env
[skerit@test1 coder]$ env
HOSTNAME=test1
PWD=/home/coder
HOME=/home/skerit
ENTRYPOINTD=/entrypoint.d
LANG=en_US.UTF-8
CODER_AGENT_TOKEN=xxx
TERM=xterm
USER=coder
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
_=/usr/sbin/env
The workaround for this was to add this to the workspace resource:
resource "docker_container" "workspace" {
...
user = "coder:coder"
}
resource "docker_container" "workspace" {
...
user = "coder:coder"
}
This is on an Arch server, btw 😄
12 replies
CCoder.com
Created by Skerit on 9/6/2022 in #help
Agent token is invalid inside of workspace container
After finding a good workaround for my issue #3870 (unable open a terminal session, which was because my user inside the workspace containers was wrong), I've got a new problem 😬 My workspace containers are complaining about an invalid agent token:
2022-09-05 16:20:46.013 [INFO] <./agent/agent.go:450> (*agent).init generating host key
2022-09-05 16:20:46.213 [INFO] <./agent/agent.go:141> (*agent).run connecting
2022-09-05 16:20:46.215 [WARN] <./agent/agent.go:150> (*agent).run failed to dial {"error": "GET https://coder.mydomain.be/api/v2/workspaceagents/me/metadata: unexpected status code 401: Agent token is invalid.: Try logging in using 'coder login \u003curl\u003e'."}
2022-09-05 16:20:46.013 [INFO] <./agent/agent.go:450> (*agent).init generating host key
2022-09-05 16:20:46.213 [INFO] <./agent/agent.go:141> (*agent).run connecting
2022-09-05 16:20:46.215 [WARN] <./agent/agent.go:150> (*agent).run failed to dial {"error": "GET https://coder.mydomain.be/api/v2/workspaceagents/me/metadata: unexpected status code 401: Agent token is invalid.: Try logging in using 'coder login \u003curl\u003e'."}
I deleted the existing workspaces & templates, restarted coder & made the templates & workspaces again, but it's still happening. Any thoughts on what the issue could be?
109 replies
CCoder.com
Created by Skerit on 9/5/2022 in #help
Setting up a database in a template
First of all: Coder is running on my server at the office, and I want to host the workspaces on it too with Docker. I've got a PHP project I'm trying to create a template for. It requires a MySQL/MariaDB database to run, so I'm trying to set that up now, but I'm not sure how to go about it. Do I create another terraform resource for it, like:
resource "docker_image" "mariadb" {
name = "docker.io/mariadb:latest"
keep_locally = false
}

resource "docker_container" "mariadb" {
image = docker_image.mariadb.latest
name = "${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-mariadb"
ports {
internal = 3306
external = 3306
}
env = ["MARIADB_ROOT_PASSWORD=elastic"]
}

provider "mysql" {
endpoint = "localhost:3306"
username = "root"
password = "elastic"
}

resource "mysql_database" "app" {
name = "project_db_name"
}
resource "docker_image" "mariadb" {
name = "docker.io/mariadb:latest"
keep_locally = false
}

resource "docker_container" "mariadb" {
image = docker_image.mariadb.latest
name = "${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}-mariadb"
ports {
internal = 3306
external = 3306
}
env = ["MARIADB_ROOT_PASSWORD=elastic"]
}

provider "mysql" {
endpoint = "localhost:3306"
username = "root"
password = "elastic"
}

resource "mysql_database" "app" {
name = "project_db_name"
}
Or is there another preferred way to do it?
15 replies