Skip to content

Commit

Permalink
Do not reset except on client connect error
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Nov 10, 2022
1 parent f484452 commit 2d0ce53
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (hosts *HostsController) sendMetric(host config.Host, client *Client) {
}
log.Error(errorContent)
//FIXME: what kind of errors do we especially want to reset driver for
if _, ok := err.(*driver.SSHError); ok {
if _, ok := err.(*driver.SSHConnectError); ok {
hosts.resetDriver(host)
}
message := &SendMessage{
Expand Down
22 changes: 18 additions & 4 deletions driver/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,22 @@ var (
port = 22
)

type SSHError struct {
type SSHConnectError struct {
content string
client string
}

func (e *SSHError) Error() string {
return fmt.Sprintf("SSH Error: %s", e.content)
func (e *SSHConnectError) Error() string {
return fmt.Sprintf("SSH Connect Error on %s: %s", e.client, e.content)
}

type SSHRunError struct {
content string
client string
}

func (e *SSHRunError) Error() string {
return fmt.Sprintf("SSH Run Error on %s: %s", e.client, e.content)
}

// SSH : Driver for handling ssh executions
Expand Down Expand Up @@ -102,7 +112,10 @@ func (d *SSH) RunCommand(command string) (string, error) {
log.Debugf("Running remote command %s", command)
client, err := d.Client()
if err != nil {
return ``, &SSHError{content: err.Error()}
return ``, &SSHConnectError{
content: err.Error(),
client: d.Host,
}
}
if len(d.EnvVars) != 0 {
// add env variable to command
Expand All @@ -120,6 +133,7 @@ func (d *SSH) GetDetails() SystemDetails {
if d.Info == nil {
// TODO: Check for goph specific errors
// within RunCommand and only return errors that are not
log.Debugf("Checking platform details for %s", d.Host)
// goph specific
uname, err := d.RunCommand(`uname`)
// try windows command
Expand Down

0 comments on commit 2d0ce53

Please sign in to comment.