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

Canonicalize host #163

Closed
luqmana opened this issue May 8, 2023 · 5 comments
Closed

Canonicalize host #163

luqmana opened this issue May 8, 2023 · 5 comments
Milestone

Comments

@luqmana
Copy link
Contributor

luqmana commented May 8, 2023

I set the OXIDE_HOST environment variable to https://pluto.oxide-preview.com (note lack of trailing slash) and tried to run the cli but ran into a panic:

$ oxide current-user ssh-key create [...]
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: host https://pluto.oxide-preview.com not found', cli/src/main.rs:121:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

My ~/.config/oxide/hosts.toml has multiple entries (hence why I explcitily was selecting with the env var):

["https://venus.oxide-preview.com/"]
token = "..."
user = "..."

["https://pluto.oxide-preview.com/"]
token = "..."
user = "..."

Note those have the trailing slashes.

@askfongjojo askfongjojo added this to the FCS milestone May 21, 2023
@askfongjojo
Copy link

Bumped this to FCS as it's likely some users will stumble upon this and not know how to resolve or work around it.

@askfongjojo
Copy link

No longer ran into this error on commit 5756510ac1a272cb33c1d444750336037bd49b96. We can perhaps close this?

@askfongjojo
Copy link

I was wrong about the status of this issue. It doesn't happen when the OXIDE_TOKEN environment variable is already set but it shows up when the variable is unset.

$ export OXIDE_HOST=https://oxide.sys.rack2.eng.oxide.computer/
$ unset OXIDE_TOKEN
$ oxide auth login --host $OXIDE_HOST
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
Do you want to re-authenticate? no

$ export OXIDE_HOST=https://oxide.sys.rack2.eng.oxide.computer
$ oxide auth login --host $OXIDE_HOST
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: host https://oxide.sys.rack2.eng.oxide.computer not found', cli/src/cli_builder.rs:232:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(9), ...)', cli/src/main.rs:59:10

@askfongjojo askfongjojo modified the milestones: FCS, MVP Jul 13, 2023
@david-crespo
Copy link
Contributor

david-crespo commented Jan 12, 2024

This is still an issue IMO, though maybe in different form than stated above. I would state it in terms of a mismatch between what is required for oxide auth login to tell you you're already logged in (it is more flexible) and what OXIDE_HOST has to be in order for requests to actually work.

$ oxide auth login --host oxide.sys.rack2.eng.oxide.computer
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
Do you want to re-authenticate? no
 ~/oxide/oxide.rs  [main]
$ oxide auth login --host https://oxide.sys.rack2.eng.oxide.computer
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
Do you want to re-authenticate? no
 ~/oxide/oxide.rs  [main]
$ oxide auth login --host https://oxide.sys.rack2.eng.oxide.computer/
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
Do you want to re-authenticate? no
 ~/oxide/oxide.rs  [main]
$ OXIDE_HOST='oxide.sys.rack2.eng.oxide.computer' oxide ip-pool list
$OXIDE_HOST is set, but oxide.sys.rack2.eng.oxide.computer has no corresponding token.
Login without $OXIDE_HOST set or set $OXIDE_TOKEN.
 ~/oxide/oxide.rs  [main]
$ OXIDE_HOST='https://oxide.sys.rack2.eng.oxide.computer' oxide ip-pool list
$OXIDE_HOST is set, but https://oxide.sys.rack2.eng.oxide.computer has no corresponding token.
Login without $OXIDE_HOST set or set $OXIDE_TOKEN.
 ~/oxide/oxide.rs  [main]
$ OXIDE_HOST='https://oxide.sys.rack2.eng.oxide.computer/' oxide ip-pool list
# successfully prints IP pools...

You can see above that oxide auth login does not care if there is an protocol or a trailing slash on the host when you try to log in, but the actual API calls do. The failure mode for me as a user is that I run oxide auth login to check if I'm logged in:

$ oxide auth login --host oxide.sys.rack2.eng.oxide.computer
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
You're already logged into https://oxide.sys.rack2.eng.oxide.computer/
Do you want to re-authenticate? no

And it tells me I am! So I say ok great, I'll just set OXIDE_HOST=oxide.sys.rack2.eng.oxide.computer and be on my way.

$ OXIDE_HOST='oxide.sys.rack2.eng.oxide.computer' oxide ip-pool list
$OXIDE_HOST is set, but oxide.sys.rack2.eng.oxide.computer has no corresponding token.
Login without $OXIDE_HOST set or set $OXIDE_TOKEN.

But that doesn't work! So now I have to go through this back and forth to figure out what the working version of the host is. And (somewhat strangely IMO) it requires a trailing slash? Or maybe it only does because that's what I used when I initially authed? Or maybe because I have an old auth config? I reauthed and it behaves the same way.

@ahl
Copy link
Collaborator

ahl commented Jul 17, 2024

I believe the need for this has either been addressed or obviated by #727

@ahl ahl closed this as completed Jul 17, 2024
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

5 participants