Unwrap Nomad error for allocation exec
* This will allow us to inspect whether the websocket connection was closed normally
This commit is contained in:
@ -100,11 +100,14 @@ func (nc *nomadAPIClient) Execute(runnerID string,
|
|||||||
return 1, fmt.Errorf("error retrieving allocation info: %w", err)
|
return 1, fmt.Errorf("error retrieving allocation info: %w", err)
|
||||||
}
|
}
|
||||||
exitCode, err := nc.client.Allocations().Exec(ctx, allocation, TaskName, tty, command, stdin, stdout, stderr, nil, nil)
|
exitCode, err := nc.client.Allocations().Exec(ctx, allocation, TaskName, tty, command, stdin, stdout, stderr, nil, nil)
|
||||||
if err != nil && websocket.IsCloseError(err, websocket.CloseNormalClosure) {
|
if err != nil {
|
||||||
log.WithError(err).Info("The exit code could not be received.")
|
rootCause := errors.Unwrap(err)
|
||||||
return 0, nil
|
if rootCause != nil && websocket.IsCloseError(rootCause, websocket.CloseNormalClosure) {
|
||||||
} else if err != nil {
|
log.WithError(err).Info("The exit code could not be received.")
|
||||||
return 1, fmt.Errorf("error executing command in allocation: %w", err)
|
return 0, nil
|
||||||
|
} else {
|
||||||
|
return 1, fmt.Errorf("error executing command in allocation: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return exitCode, nil
|
return exitCode, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user