Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 error for requests to coder.example.com after "Update" option following template change #262

Open
kujenga opened this issue Jul 2, 2024 · 3 comments

Comments

@kujenga
Copy link

kujenga commented Jul 2, 2024

I am seeing an issue where when I use the "Update" option in the coder dashboard after a template change, the coder process get stuck in this state, where it gets 401 errors trying to talk to the coder agent URL. The issue is resolved by using the "Restart" option instead.

2024-06-12 19:43:20.920 [info]  connecting to coderd
2024-06-12 19:43:20.934 [warn]  run exited with error ...
    error= GET https://coder.example.com/api/v2/workspaceagents/me/rpc?version=2.1: unexpected status code 401: unexpected non-JSON response "": Try logging in using 'coder login'.
               Error: no response body

I am using "token" authentication with the coder agent, with config passed to the container for the auth as:

      {
        name  = "CODER_AGENT_TOKEN"
        value = try(coder_agent.main[0].token, "")
      },
      {
        name  = "CODER_AGENT_URL"
        value = data.coder_workspace.me.access_url
      },

This issue does away after doing a "restart" of the instance.

Discord discussion here: https://discord.com/channels/747933592273027093/1250538421789790271/1250538421789790271

@johnstcn
Copy link
Member

johnstcn commented Jul 3, 2024

@kujenga what version of Coder are you seeing this behaviour on?

@kujenga
Copy link
Author

kujenga commented Jul 23, 2024

@johnstcn We are still seeing this issue on Coder version v2.13.0+56bf386

Also worth just to clarify, the example.com in the post is a replacement of our internal hostname for the coder instance I'm running, it's correct in the logs.

@johnstcn
Copy link
Member

@kujenga I think this is mainly down to a combination of confusing wording in the Coder UI and a lack of clarity on what the 'update' and 'restart' buttons actually do.
The 'restart' button is probably what you want instead of 'update'.
See coder/coder#13539 (comment) for some more context.

When a workspace is started, an agent token is generated. This token is linked to the currently active workspace build. What appears to be happening is that the 'update' button is creating a workspace build in the 'start' state, which results in a new agent token being created and the existing agent token being revoked.

My guess would be that your template, for some reason, isn't updating the workspace VM / container with the updated agent token?

Do you see the same behaviour if you 'Change Version' of an active workspace instead of clicking 'Update'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants