-
Notifications
You must be signed in to change notification settings - Fork 26
Tracking errors and properly exiting with error code #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,16 +15,59 @@ type CommandOutputSafe struct { | |
| Output []*ssm.SendCommandOutput | ||
| } | ||
|
|
||
| // Status ... | ||
| type Status string | ||
|
|
||
| const ( | ||
| // CommandSuccess indicates ssm successfully ran a command on target(s) | ||
| CommandSuccess Status = "Success" | ||
|
|
||
| // CommandFailed indicates ssm ran a command on target(s) that failed | ||
| CommandFailed Status = "Failed" | ||
|
|
||
| // CommandPending indicates ssm ran a command on target(s) that is pending | ||
| CommandPending Status = "Pending" | ||
|
|
||
| // CommandInProgress The command has been sent to the instance but has not reached a terminal state. | ||
| CommandInProgress Status = "In Progress" | ||
|
|
||
| // CommandDeliveryTimedOut The command was not delivered to the instance before the delivery timeout expired. Delivery timeouts do not count against the parent command's MaxErrors limit, but they do contribute to whether the parent command status is Success or Incomplete. This is a terminal state. | ||
| CommandDeliveryTimedOut Status = "Delivery Timed Out" | ||
|
|
||
| // CommandExecutionTimedOut Command execution started on the instance, but the execution was not complete before the execution timeout expired. Execution timeouts count against the MaxErrors limit of the parent command. This is a terminal state. | ||
| CommandExecutionTimedOut Status = "Execution Timed Out" | ||
|
|
||
| // CommandCanceled The command was terminated before it was completed. This is a terminal state. | ||
| CommandCanceled Status = "Canceled" | ||
|
|
||
| // CommandUndeliverable The command can't be delivered to the instance. The instance might not exist or might not be responding. Undeliverable invocations don't count against the parent command's MaxErrors limit and don't contribute to whether the parent command status is Success or Incomplete. This is a terminal state. | ||
| CommandUndeliverable Status = "Undeliverable" | ||
|
|
||
| // CommandTerminated The parent command exceeded its MaxErrors limit and subsequent command invocations were canceled by the system. This is a terminal state. | ||
| CommandTerminated Status = "Terminated" | ||
|
|
||
| // ClientError indicates error occured prior to or when invoking an ssm api method | ||
| ClientError Status = "ClientError" | ||
| ) | ||
|
|
||
| // Result is used to store information about an invocation run on a particular instance | ||
| type Result struct { | ||
| InvocationResult *ssm.GetCommandInvocationOutput | ||
| ProfileName string | ||
| Region string | ||
| Status string | ||
| Status Status | ||
| Error error | ||
| } | ||
|
|
||
| // ResultSafe allows for concurrent-safe access to a slice of InvocationResult info | ||
| type ResultSafe struct { | ||
| sync.Mutex | ||
| InvocationResults []*Result | ||
| } | ||
|
|
||
| // Add allows appending results safely | ||
| func (results *ResultSafe) Add(result *Result) { | ||
| results.Lock() | ||
| results.InvocationResults = append(results.InvocationResults, result) | ||
| results.Unlock() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unimportant potentially bikesheddy question so take worth a grain of salt, do we prefer
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I generally prefer using defer but considering the proximity and how simple this function is I am impartial to its use here. When there is more code between the lock and unlock I think defer is always the best option |
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a particular reason to move away from the switch/case statements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jordan and I paired on this. Not sure why I made the change either