17170: Improve error messages and command help text.
authorTom Clegg <tom@curii.com>
Wed, 3 Feb 2021 20:35:33 +0000 (15:35 -0500)
committerTom Clegg <tom@curii.com>
Wed, 3 Feb 2021 20:35:33 +0000 (15:35 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

cmd/arvados-client/container_gateway.go
lib/controller/localdb/container_gateway.go

index 6dbc241bca3cb7252f8488a8c061bb43a94aa3c1..e3b6b9332c23c92c0d62ab9417c3af6d56d0c9c2 100644 (file)
@@ -13,6 +13,7 @@ import (
        "net/url"
        "os"
        "os/exec"
+       "path/filepath"
        "strings"
        "syscall"
 
@@ -28,6 +29,7 @@ func (shellCommand) RunCommand(prog string, args []string, stdin io.Reader, stdo
        f := flag.NewFlagSet(prog, flag.ContinueOnError)
        f.SetOutput(stderr)
        f.Usage = func() {
+               _, prog := filepath.Split(prog)
                fmt.Fprint(stderr, prog+`: open an interactive shell on a running container.
 
 Usage: `+prog+` [options] [username@]container-uuid [ssh-options] [remote-command [args...]]
@@ -105,8 +107,12 @@ func (connectSSHCommand) RunCommand(prog string, args []string, stdin io.Reader,
        f := flag.NewFlagSet(prog, flag.ContinueOnError)
        f.SetOutput(stderr)
        f.Usage = func() {
+               _, prog := filepath.Split(prog)
                fmt.Fprint(stderr, prog+`: connect to the gateway service for a running container.
 
+NOTE: You almost certainly don't want to use this command directly. It
+is meant to be used internally. Use "arvados-client shell" instead.
+
 Usage: `+prog+` [options] [username@]container-uuid
 
 Options:
index e509278773ae288f9368e78e98ee059f656560a8..3b40eccaff68c138e498b9ec497f5f704e249f64 100644 (file)
@@ -63,15 +63,15 @@ func (conn *Conn) ContainerSSH(ctx context.Context, opts arvados.ContainerSSHOpt
 
        switch ctr.State {
        case arvados.ContainerStateQueued, arvados.ContainerStateLocked:
-               err = httpserver.ErrorWithStatus(fmt.Errorf("gateway is not available, container is %s", strings.ToLower(string(ctr.State))), http.StatusServiceUnavailable)
+               err = httpserver.ErrorWithStatus(fmt.Errorf("container is not running yet (state is %q)", ctr.State), http.StatusServiceUnavailable)
                return
        case arvados.ContainerStateRunning:
                if ctr.GatewayAddress == "" {
-                       err = httpserver.ErrorWithStatus(errors.New("container is running but gateway is not available"), http.StatusServiceUnavailable)
+                       err = httpserver.ErrorWithStatus(errors.New("container is running but gateway is not available -- installation problem or feature not supported"), http.StatusServiceUnavailable)
                        return
                }
        default:
-               err = httpserver.ErrorWithStatus(fmt.Errorf("gateway is not available, container is %s", strings.ToLower(string(ctr.State))), http.StatusGone)
+               err = httpserver.ErrorWithStatus(fmt.Errorf("container has ended (state is %q)", ctr.State), http.StatusGone)
                return
        }
        // crunch-run uses a self-signed / unverifiable TLS