-
Notifications
You must be signed in to change notification settings - Fork 3
Remove Buffer Size in go-sh Shell Command #253
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
base: master
Are you sure you want to change the base?
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 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -50,7 +50,6 @@ func NewRetryConfig() *RetryConfig { | |||||||||||
| return false | ||||||||||||
| } | ||||||||||||
| combined := strings.ToLower(err.Error() + " " + output) | ||||||||||||
| klog.Infoln("Combined output: " + combined) | ||||||||||||
| for _, pattern := range retryablePatterns { | ||||||||||||
| if strings.Contains(combined, strings.ToLower(pattern)) { | ||||||||||||
| return true | ||||||||||||
|
|
@@ -64,32 +63,31 @@ func NewRetryConfig() *RetryConfig { | |||||||||||
| func (rc *RetryConfig) RunWithRetry(ctx context.Context, execFunc func() ([]byte, error)) ([]byte, error) { | ||||||||||||
| var output []byte | ||||||||||||
| var lastErr error | ||||||||||||
| attempts := 0 | ||||||||||||
| attempts := 1 | ||||||||||||
|
|
||||||||||||
| err := wait.PollUntilContextCancel( | ||||||||||||
| ctx, | ||||||||||||
| rc.Delay, | ||||||||||||
| true, // Run immediately on first call | ||||||||||||
| func(ctx context.Context) (bool, error) { | ||||||||||||
| // Stop if max retries reached | ||||||||||||
| if attempts >= rc.MaxRetries { | ||||||||||||
| if attempts > rc.MaxRetries { | ||||||||||||
| return false, fmt.Errorf("max retries reached") | ||||||||||||
| } | ||||||||||||
| output, lastErr = execFunc() | ||||||||||||
| klog.Infof("Attempt #%d: retrying in %v", attempts, rc.Delay) | ||||||||||||
| klog.Infof("Attempt #%d error: %v", attempts, lastErr) | ||||||||||||
| klog.Infof("Attempt #%d output: %s", attempts, string(output)) | ||||||||||||
|
|
||||||||||||
| if !rc.ShouldRetry(lastErr, string(output)) { | ||||||||||||
| return true, nil | ||||||||||||
|
Comment on lines
+78
to
83
|
||||||||||||
| } | ||||||||||||
| klog.Infoln("Retrying command after error", | ||||||||||||
| "attempt", attempts, | ||||||||||||
| "maxRetries", rc.MaxRetries, | ||||||||||||
| "error", fmt.Sprintf("%s %s", lastErr, string(output))) | ||||||||||||
| attempts++ | ||||||||||||
| return false, nil | ||||||||||||
|
Comment on lines
+66
to
86
|
||||||||||||
| }, | ||||||||||||
| ) | ||||||||||||
| if err != nil { | ||||||||||||
| return nil, fmt.Errorf("failed after %d attempts: %w", attempts, lastErr) | ||||||||||||
| return output, fmt.Errorf("failed after %d attempts: %w", attempts, lastErr) | ||||||||||||
|
||||||||||||
| return output, fmt.Errorf("failed after %d attempts: %w", attempts, lastErr) | |
| if lastErr != nil { | |
| return output, fmt.Errorf("failed after %d attempts: %w (last error: %v)", attempts, err, lastErr) | |
| } | |
| return output, fmt.Errorf("failed after %d attempts: %w", attempts, err) |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.