in src/terraform/providers/terraform-provider-avere/averevfxt.go [208:254]
func (a *AvereVfxt) AvereCommandWithCorrection(cmd string, correctiveAction func() error) (string, error) {
var result string
for retries := 0; ; retries++ {
stdoutBuf, stderrBuf, err := a.RunCommand(cmd)
// look for the error if this is a multi-call
if err == nil && IsMultiCall(cmd) {
if isMultiCallSuccess, faultStr, err2 := IsMultiCallResultSuccessful(stdoutBuf.String()); !isMultiCallSuccess {
if err2 != nil {
err = fmt.Errorf("BUG: multcall result parse error: %v", err2)
} else if len(faultStr) > 0 {
err = fmt.Errorf("multi call error: '%s'", faultStr)
}
}
}
if err == nil {
// success
result = stdoutBuf.String()
break
}
log.Printf("[WARN] [%d/%d] command to %s failed with '%v' ", retries, AverecmdRetryCount, a.ControllerAddress, err)
if isAverecmdNotRetryable(stdoutBuf, stderrBuf) {
// failure not retryable
return "", fmt.Errorf("Non retryable error applying command: '%s' '%s'", stdoutBuf.String(), stderrBuf.String())
}
if correctiveAction != nil {
// the corrective action is best effort, just log an error if one occurs
if err = correctiveAction(); err != nil {
log.Printf("[ERROR] error performing correctiveAction: %v", err)
} else {
// try the command again after a successful correction
stdoutBuf, stderrBuf, err = a.RunCommand(cmd)
if err == nil {
// success
result = stdoutBuf.String()
break
}
}
}
if retries > AverecmdRetryCount {
// failure after exhausted retries
return "", fmt.Errorf("Failure after %d retries applying command: '%s' '%s'", AverecmdRetryCount, stdoutBuf.String(), stderrBuf.String())
}
time.Sleep(AverecmdRetrySleepSeconds * time.Second)
}
return result, nil
}