-
Notifications
You must be signed in to change notification settings - Fork 15
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
skipped failed hosts #2
Comments
What is a failed host?. One that you couldn't connect to? I can add a timeout to: if err := session.Run(r.Command); err != nil {
result.SetErr(errors.Wrap(err, "failed to execute command"))
jobResult <- result
return
} |
A failed host is basically whatever the host determines that was a failure. Some things are obvious like a connection failed to establish or something like that but you could do your own thing, for instance: var AssertionFailed error = errors.New("assertion failed")
type VerifyPreconditionsTask struct {
}
func (t *VerifyPreconditionsTask) Run(...) {
// here we could do some asserts against a device or something
if preConditionFailed {
result.SetErr(AssertionFailed) // SetErr will also store the error in the host
jobResult <- result
}
} Now, as a user in your main code you could do: gr.RunS(
"let's test our devices meet preconditions",
&VerifyPreconditionsTask{},
)
// Now we could filter out the devices
func okHosts(host *Host, gr *Gornir) bool {
return host.Err() == nil
}
gr.RunS.Filter(okHosts).RunS(
"do more stuff",
...
)
// Or maybe we want to do something on the hosts that failed the precondition
func hostsThatPassedPrecondition(host *Host, gr *Gornir) bool {
return host.Err() == AssertionFailed
}
gr.RunS.Filter(hostsThatPassedPrecondition).RunS(
"we need to do something on the hosts that failed the assertions",
...
) Actually, I think this is a good enough interface without any attached magic so maybe there is nothing to do here. Maybe just write a working example. Does this make sense? |
It does. I can envision running a pre-check to check the operating system version of a host, or a given capability, before sending the task. Thanks. |
Awesome, I am going to keep it open to remind us to add an example. Eventually I'd like to also use a "golden file pattern" for testing the examples. |
runners should skip failed hosts unless stated otherwise
The text was updated successfully, but these errors were encountered: