fix: catch more ssh failure modes with help
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5237c7ed50
commit
bfeda40e34
@ -410,6 +410,24 @@ Good luck!
|
|||||||
|
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var ServerAddFailMsg = `
|
||||||
|
Failed to add server %s.
|
||||||
|
|
||||||
|
This could be caused by two things.
|
||||||
|
|
||||||
|
Abra isn't picking up your SSH configuration or you need to specify it on the
|
||||||
|
command-line (e.g you use a non-standard port or username to connect). Run
|
||||||
|
"server add" with "-d/--debug" to learn more about what Abra is doing under the
|
||||||
|
hood.
|
||||||
|
|
||||||
|
Docker is not installed on your server. You can pass "-p/--provision" to
|
||||||
|
install Docker and initialise Docker Swarm mode. See help output for "server
|
||||||
|
add"
|
||||||
|
|
||||||
|
See "abra server add -h" for more.
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
// SubCommandBefore wires up pre-action machinery (e.g. --debug handling).
|
// SubCommandBefore wires up pre-action machinery (e.g. --debug handling).
|
||||||
func SubCommandBefore(c *cli.Context) error {
|
func SubCommandBefore(c *cli.Context) error {
|
||||||
if Debug {
|
if Debug {
|
||||||
|
@ -463,14 +463,17 @@ developer machine.
|
|||||||
|
|
||||||
cl, err := newClient(c, domainName)
|
cl, err := newClient(c, domainName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
cleanUp(domainName)
|
||||||
|
logrus.Debugf("failed to construct client for %s, saw %s", domainName, err.Error())
|
||||||
|
logrus.Fatalf(fmt.Sprintf(internal.ServerAddFailMsg, domainName))
|
||||||
}
|
}
|
||||||
|
|
||||||
if provision {
|
if provision {
|
||||||
logrus.Debugf("attempting to construct SSH client for %s", domainName)
|
logrus.Debugf("attempting to construct SSH client for %s", domainName)
|
||||||
sshCl, err := ssh.New(domainName, sshAuth, username, port)
|
sshCl, err := ssh.New(domainName, sshAuth, username, port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
cleanUp(domainName)
|
||||||
|
logrus.Fatalf(fmt.Sprintf(internal.ServerAddFailMsg, domainName))
|
||||||
}
|
}
|
||||||
defer sshCl.Close()
|
defer sshCl.Close()
|
||||||
logrus.Debugf("successfully created SSH client for %s", domainName)
|
logrus.Debugf("successfully created SSH client for %s", domainName)
|
||||||
@ -485,7 +488,7 @@ developer machine.
|
|||||||
|
|
||||||
if _, err := cl.Info(context.Background()); err != nil {
|
if _, err := cl.Info(context.Background()); err != nil {
|
||||||
cleanUp(domainName)
|
cleanUp(domainName)
|
||||||
logrus.Fatalf("couldn't make a remote docker connection to %s? use --provision/-p to attempt to install", domainName)
|
logrus.Fatalf(fmt.Sprintf(internal.ServerAddFailMsg, domainName))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -27,7 +27,11 @@ func New(contextName string) (*client.Client, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
helper := commandconnPkg.NewConnectionHelper(ctxEndpoint)
|
helper, err := commandconnPkg.NewConnectionHelper(ctxEndpoint)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
httpClient := &http.Client{
|
httpClient := &http.Client{
|
||||||
// No tls, no proxy
|
// No tls, no proxy
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
|
@ -67,13 +67,13 @@ func getConnectionHelper(daemonURL string, sshFlags []string) (*connhelper.Conne
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConnectionHelper(daemonURL string) *connhelper.ConnectionHelper {
|
func NewConnectionHelper(daemonURL string) (*connhelper.ConnectionHelper, error) {
|
||||||
helper, err := GetConnectionHelper(daemonURL)
|
helper, err := GetConnectionHelper(daemonURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return helper
|
return helper, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDockerEndpoint(host string) (docker.Endpoint, error) {
|
func getDockerEndpoint(host string) (docker.Endpoint, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user