Skip to content

chore: ensure coder is logged before querying orgs #15618

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

Merged
merged 1 commit into from
Nov 21, 2024
Merged

Conversation

dannykopping
Copy link
Contributor

#15603 and #13923 introduced steps into develop.sh which use the coder CLI to execute queries (both for organizations, at it turns out).

However, these commands assume there's a value API token issued and used by the CLI. If not, develop.sh fails to start up with the following error:

/home/coder/coder/build/coder_2.17.2-devel+78f9f43c9_linux_amd64
== CMD: /home/coder/coder/scripts/coder-dev.sh server --http-address 0.0.0.0:3000 --swagger-enable --dangerous-allow-cors-requests=true --enable-terraform-debug-mode
== Waiting for Coder to become ready
[API] Started HTTP listener at http://0.0.0.0:3000/
[API] Using built-in PostgreSQL (/home/coder/coder/.coderv2/postgres)
[API] Opening tunnel so workspaces can connect to your deployment. For production scenarios, specify an external access URL
[API] ╔═══════════════════════════════════════════════╗
[API] ║               View the Web UI:                ║
[API] ║   https://4be2pat11602q.pit-1.try.coder.app/   ║
[API] ╚═══════════════════════════════════════════════╝
...
Encountered an error running "coder organizations show", see "coder organizations show --help" for more information
error: You are signed out or your session has expired. Please sign in again to continue.
Suggestion: Try logging in using 'coder login'.
== FAIL: Script encountered an error
[API] Interrupt caught, gracefully exiting. Use ctrl+\ to force quit
[API] Shutting down API server...
[API] 
[API] Gracefully shut down API server
...

We have "${PROJECT_ROOT}/.coderv2/developsh-did-first-setup" is used as a state file to indicate that the first user has been setup. This change forces this branch to always be followed if auth fails. If the first user already exists, it'll fail gracefully.

A future improvement to this would be to avoid trying to recreate the first (and regular) user.

Signed-off-by: Danny Kopping <danny@coder.com>
@dannykopping dannykopping merged commit f38f746 into main Nov 21, 2024
28 checks passed
@dannykopping dannykopping deleted the dk/dev.sh branch November 21, 2024 15:04
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

Successfully merging this pull request may close these issues.

2 participants