Coder.comC
Coder.com2y ago
16 replies
Plotly Mike

"The agent cannot authenticate until the workspace provision job has been completed."

I am trying to provision a Coder agent on a VM. I am doing this by creating a systemd unit that runs the Coder agent.

However, when the unit starts, as part of a remote exec provisioner, it just keeps repeating this:
Aug 29 07:07:09 mike9-services.redacted coder[7482]: 2024-08-29 07:07:09.252 [info]  connecting to coderd
Aug 29 07:07:09 mike9-services.redacted coder[7482]: 2024-08-29 07:07:09.257 [warn]  run exited with error ...
Aug 29 07:07:09 mike9-services.redacted coder[7482]:     error= GET https://coder.redacted/api/v2/workspaceagents/me/rpc?version=2.2: unexpected status code 401: Workspace agent not authorized.: Try logging in using >
Aug 29 07:07:09 mike9-services.redacted coder[7482]:                    Error: The agent cannot authenticate until the workspace provision job has been completed. If the job is no longer running, this agent is invalid.

Restarting the systemd unit has no effect.
The token is being passed through from the coder_agent resource (coder_agent.main.token).
With coder state pull I can see that the token on the agent resource is correct compared to the one on disk, but I cannot get this agent to associated.

I've tried adding a coder_agent_instance but it doesn't help.

I see an old closed issue https://github.com/coder/coder/issues/5704 as being similar, but there's no clear fix present there.

Perhaps worth mentioning:
- Using an AWS instance, but in a different account, so using token auth, not aws instance identity
- AWS instance is created by a module that is intended to work independently of Coder; seems to pose some issues for knitting the agent together with the instance, couldn't get coder_metadata to work either
- Actual instance is spun up fine and seems happy except for the agent connection
GitHub
I am using the vSphere plugin to clone virtual machines from templates on vSphere. After cloning, I used remote-exec provisioner and did an init of coder_agent and got the following error null_reso...
Was this page helpful?