Handling Missing ~/.ssh Host entries can be improved #570

Open
opened 2024-02-11 16:52:53 +00:00 by basebuilder · 7 comments

When adding a new server via abra the process is not as user friendly as it can be #537. The requirement 1. a server with SSH access... implies simply being able to run ssh user@website.org and be into a server. However, as the Docs mention later:

... You should have a working SSH configuration before you can do this (e.g. a matching Host <server-domain> entry in ~/.ssh/config with the correct SSH connection details) ...

This is not as clear as it can be (as it needs a specifically formatted host entry #566). When following the New Operators Tutorial for the second time, I made the mistake to not add an SSH entry which then threw the following stacktrace.

$ abra server add website.org
INFO[0000] successfully created /home/user/.abra/servers/website.org 
panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
coopcloud.tech/abra/pkg/ssh.GetHostConfig({0x7ffde86dc163, 0xd})
	/home/decentral1se/work/coop-cloud/abra/pkg/ssh/ssh.go:50 +0x5d5
coopcloud.tech/abra/cli/server.glob..func1(0xc0001f9b80)
	/home/decentral1se/work/coop-cloud/abra/cli/server/add.go:161 +0x305
github.com/urfave/cli.HandleAction({0xd69820?, 0xf893e8?}, 0x3?)
	/home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:524 +0x50
github.com/urfave/cli.Command.Run({{0xed6fcc, 0x3}, {0x0, 0x0}, {0x1701ab0, 0x1, 0x1}, {0xf0c226, 0x22}, {0x0, ...}, ...}, ...)
	/home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:173 +0x63e
github.com/urfave/cli.(*App).RunAsSubcommand(0xc00022b6c0, 0xc0001f9760)
	/home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:405 +0xdc7
github.com/urfave/cli.Command.startApp({{0xedaf64, 0x6}, {0x0, 0x0}, {0x1701af0, 0x1, 0x1}, {0xef2006, 0xe}, {0x0, ...}, ...}, ...)
	/home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:378 +0xb58
github.com/urfave/cli.Command.Run({{0xedaf64, 0x6}, {0x0, 0x0}, {0x1701af0, 0x1, 0x1}, {0xef2006, 0xe}, {0x0, ...}, ...}, ...)
	/home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:102 +0x7e5
github.com/urfave/cli.(*App).Run(0xc00022afc0, {0xc0001d6040, 0x4, 0x4})
	/home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:277 +0xb07
coopcloud.tech/abra/cli.RunApp({0x1090018?, 0x1695f58?}, {0x1099d60?, 0xc0000061a0?})
	/home/decentral1se/work/coop-cloud/abra/cli/cli.go:203 +0x37
main.main()
	/home/decentral1se/work/coop-cloud/abra/cmd/abra/main.go:22 +0xa9

This is a confusing UX. The first message written is INFO[0000] successfully created... the result is an empty folder and is added to the servers list. I see two viable things to slightly improve the UX for new Operator onboarding and abra

  • Docs: specify a clear step Step 1. Create SSH host entry
  • abra: show a nice help error message such as
$ abra server add website.org
ERROR[0000] unable to create /home/user/.abra/servers/website.org

Please make sure you have an entry in your ~/.ssh/config file like

host website.org
    HostName website.org
    User root
    ...
When adding a new server via abra the process is not as user friendly as it can be #537. The requirement `1. a server with SSH access...` implies simply being able to run `ssh user@website.org` and be into a server. However, as the Docs mention later: ``` ... You should have a working SSH configuration before you can do this (e.g. a matching Host <server-domain> entry in ~/.ssh/config with the correct SSH connection details) ... ``` This is not as clear as it can be (as it needs a specifically formatted `host` entry #566). When following the [New Operators Tutorial](https://docs.coopcloud.tech/operators/tutorial/#deploy-your-first-app) for the second time, I made the mistake to not add an SSH entry which then threw the following stacktrace. ``` $ abra server add website.org INFO[0000] successfully created /home/user/.abra/servers/website.org panic: runtime error: index out of range [2] with length 2 goroutine 1 [running]: coopcloud.tech/abra/pkg/ssh.GetHostConfig({0x7ffde86dc163, 0xd}) /home/decentral1se/work/coop-cloud/abra/pkg/ssh/ssh.go:50 +0x5d5 coopcloud.tech/abra/cli/server.glob..func1(0xc0001f9b80) /home/decentral1se/work/coop-cloud/abra/cli/server/add.go:161 +0x305 github.com/urfave/cli.HandleAction({0xd69820?, 0xf893e8?}, 0x3?) /home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:524 +0x50 github.com/urfave/cli.Command.Run({{0xed6fcc, 0x3}, {0x0, 0x0}, {0x1701ab0, 0x1, 0x1}, {0xf0c226, 0x22}, {0x0, ...}, ...}, ...) /home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:173 +0x63e github.com/urfave/cli.(*App).RunAsSubcommand(0xc00022b6c0, 0xc0001f9760) /home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:405 +0xdc7 github.com/urfave/cli.Command.startApp({{0xedaf64, 0x6}, {0x0, 0x0}, {0x1701af0, 0x1, 0x1}, {0xef2006, 0xe}, {0x0, ...}, ...}, ...) /home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:378 +0xb58 github.com/urfave/cli.Command.Run({{0xedaf64, 0x6}, {0x0, 0x0}, {0x1701af0, 0x1, 0x1}, {0xef2006, 0xe}, {0x0, ...}, ...}, ...) /home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/command.go:102 +0x7e5 github.com/urfave/cli.(*App).Run(0xc00022afc0, {0xc0001d6040, 0x4, 0x4}) /home/decentral1se/go/pkg/mod/github.com/urfave/cli@v1.22.9/app.go:277 +0xb07 coopcloud.tech/abra/cli.RunApp({0x1090018?, 0x1695f58?}, {0x1099d60?, 0xc0000061a0?}) /home/decentral1se/work/coop-cloud/abra/cli/cli.go:203 +0x37 main.main() /home/decentral1se/work/coop-cloud/abra/cmd/abra/main.go:22 +0xa9 ``` This is a confusing UX. The first message written is `INFO[0000] successfully created...` the result is an empty folder and is added to the servers list. I see two viable things to slightly improve the UX for new Operator onboarding and `abra` - [ ] Docs: specify a clear step `Step 1. Create SSH host entry` - [ ] abra: show a nice help error message such as ``` $ abra server add website.org ERROR[0000] unable to create /home/user/.abra/servers/website.org Please make sure you have an entry in your ~/.ssh/config file like host website.org HostName website.org User root ... ```
basebuilder added the
bug
documentation
abra
labels 2024-02-11 16:52:53 +00:00
Owner

Oh yeh, totally agree 🤘 Great Report ™

Oh yeh, totally agree 🤘 Great Report ™
decentral1se added the
good first issue
label 2024-02-11 17:56:03 +00:00
Owner

@basebuilder curious on your thoughts here too. What happens now is just a plain 'ol timeout cus we don't parse the ~/.ssh/config anymore. So, you see the terminal hangup and if you pass --debug, you see it hanging:

./abra server add --debug test.foo.com
DEBU[0000] validated test.foo.com as domain argument  caller="/home/d/work/coop-cloud/abra/cli/internal/validate.go:116 ValidateDomain"
INFO[0000] successfully created /home/d/.abra/servers/test.foo.com  caller="/home/d/work/coop-cloud/abra/pkg/server/server.go:24 CreateServerDir"
DEBU[0000] creating context with domain test.foo.com  caller="/home/d/work/coop-cloud/abra/cli/server/add.go:70 newContext"
DEBU[0000] created the test.foo.com context     caller="/home/d/work/coop-cloud/abra/pkg/client/context.go:25 CreateContext"
INFO[0000] attempting to create client for test.foo.com  caller="/home/d/work/coop-cloud/abra/cli/server/add.go:165 glob..func1"
DEBU[0000] created client for test.foo.com      caller="/home/d/work/coop-cloud/abra/pkg/client/client.go:68 New"
DEBU[0000] commandconn: starting ssh with [-- test.foo.com docker system dial-stdio]  caller="/home/d/work/coop-cloud/abra/pkg/upstream/commandconn/commandconn.go:49 New"

I'm not really enthusiastic about parsing the ~/.ssh/config again cus it's hard to get right and tools like ssh -G ... actually spit out a default if there is a value missing, so I feel like this is again a documentation issue potentially.

We can then emphasise that if ssh ... doesn't work then abra ... won't work. And this will be more true going forward now that we've removed any SSH customisations behind the scenes...

This could be handled in the docs and the abra server add -h output?

@basebuilder curious on your thoughts here too. What happens now is just a plain 'ol timeout cus we don't parse the `~/.ssh/config` anymore. So, you see the terminal hangup and if you pass `--debug`, you see it hanging: ``` ./abra server add --debug test.foo.com DEBU[0000] validated test.foo.com as domain argument caller="/home/d/work/coop-cloud/abra/cli/internal/validate.go:116 ValidateDomain" INFO[0000] successfully created /home/d/.abra/servers/test.foo.com caller="/home/d/work/coop-cloud/abra/pkg/server/server.go:24 CreateServerDir" DEBU[0000] creating context with domain test.foo.com caller="/home/d/work/coop-cloud/abra/cli/server/add.go:70 newContext" DEBU[0000] created the test.foo.com context caller="/home/d/work/coop-cloud/abra/pkg/client/context.go:25 CreateContext" INFO[0000] attempting to create client for test.foo.com caller="/home/d/work/coop-cloud/abra/cli/server/add.go:165 glob..func1" DEBU[0000] created client for test.foo.com caller="/home/d/work/coop-cloud/abra/pkg/client/client.go:68 New" DEBU[0000] commandconn: starting ssh with [-- test.foo.com docker system dial-stdio] caller="/home/d/work/coop-cloud/abra/pkg/upstream/commandconn/commandconn.go:49 New" ``` I'm not really enthusiastic about parsing the `~/.ssh/config` again cus it's hard to get right and tools like `ssh -G ...` actually spit out a default if there is a value missing, so I feel like this is again a documentation issue potentially. We can then emphasise that if `ssh ...` doesn't work then `abra ...` won't work. And this will be more true going forward now that we've removed any SSH customisations behind the scenes... This could be handled in the docs *and* the `abra server add -h` output?
Owner

Actually yeh, a lot of room for improvement beyond my previous comment, working on it: coop-cloud/abra#421

Actually yeh, a lot of room for improvement beyond my previous comment, working on it: https://git.coopcloud.tech/coop-cloud/abra/pulls/421
Owner
https://git.coopcloud.tech/coop-cloud/docs.coopcloud.tech/commit/039bd4257a7a434aa8741a0a72eafddfbe8c8742
Author

@decentral1se ehh hey there 👋 sorry for lag in response but you seemed to have blasted ahead beyond your question.

I'm not sure I follow what exactly you changed and the "docs" is only in code comment. This will need to updated in the Operators Tutorial as per #537

Following the tutorial was there I initially ran into the problem when I was learning to use abra as I just relied on my existing and functioning SSH config declarations which adhered to: ssh ... doesn't work then abra ... won't work condition.

@decentral1se ehh hey there 👋 sorry for lag in response but you seemed to have blasted ahead beyond your question. I'm not sure I follow what exactly you changed and the "docs" is only in code comment. This will need to updated in the Operators Tutorial as per #537 Following the tutorial was there I initially ran into the problem when I was learning to use `abra` as I just relied on my existing and functioning SSH config declarations which adhered to: `ssh ... doesn't work then abra ... won't work` condition.
p4u1 reopened this issue 2024-07-24 15:32:21 +00:00

This still needs a update in abra to show better error messages:

abra $ abra server add foo.bar
 FATAL  unable to resolve ipv4 address for foo.bar, lookup foo.bar: no such host
abra $ abra server add foo.bar --no-domain-checks
 FATAL  could not resolve hostname for foo.bar

Instead it should say something like "Can't ssh to foo.bar. Make sure ssh foo.bar works"
Also the error message for a failed dns check should be improved

This still needs a update in abra to show better error messages: ``` abra $ abra server add foo.bar FATAL unable to resolve ipv4 address for foo.bar, lookup foo.bar: no such host abra $ abra server add foo.bar --no-domain-checks FATAL could not resolve hostname for foo.bar ``` Instead it should say something like "Can't ssh to foo.bar. Make sure ssh foo.bar works" Also the error message for a failed dns check should be improved

The current error shows like this:

 FATAL  <server/add.go:193> error during connect: Get "http://docker.example.com/v1.46/info": command [ssh -o ConnectTimeout=5 -- example.com docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh: connect to host example.com port 22: No route to host

That seems to be clearer than the stack trace already, what other improvements are pending here?

The current error shows like this: ``` FATAL <server/add.go:193> error during connect: Get "http://docker.example.com/v1.46/info": command [ssh -o ConnectTimeout=5 -- example.com docker system dial-stdio] has exited with exit status 255, please make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=ssh: connect to host example.com port 22: No route to host ``` That seems to be clearer than the stack trace already, what other improvements are pending here?
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: toolshed/organising#570
No description provided.