-
Notifications
You must be signed in to change notification settings - Fork 2.3k
refactor(golint): update code style and improve error handling across multiple files #6105
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: main
Are you sure you want to change the base?
Conversation
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6105 +/- ##
==========================================
+ Coverage 61.86% 64.12% +2.25%
==========================================
Files 8 8
Lines 653 722 +69
==========================================
+ Hits 404 463 +59
- Misses 202 212 +10
Partials 47 47 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@codex review |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| func (c *ScaleProcessor) RunGuest(cluster *v2.Cluster) error { | ||
| logger.Info("Executing pipeline RunGuest in ScaleProcessor.") | ||
| hosts := append(c.MastersToJoin, c.NodesToJoin...) | ||
| hosts := append(append([]string{}, c.MastersToJoin...), c.NodesToJoin...) |
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.
Can we use slices.Clone followed by append?
| func (c ScaleProcessor) UnMountRootfs(cluster *v2.Cluster) error { | ||
| logger.Info("Executing pipeline UnMountRootfs in ScaleProcessor.") | ||
| hosts := append(c.MastersToDelete, c.NodesToDelete...) | ||
| hosts := append(append([]string{}, c.MastersToDelete...), c.NodesToDelete...) |
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.
Same issue, and there are other places as well.
|
@codex review |
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| time.Sleep(trySleepTime * time.Duration(2*i+1)) | ||
| } | ||
| return fmt.Errorf("retry action timeout: %v", err) | ||
| return fmt.Errorf("retry action timeout: %w", err) | ||
| } | ||
|
|
||
| // RetryWithBackoff provides exponential backoff retry with jitter | ||
| func RetryWithBackoff(maxAttempts int, baseDelay time.Duration, action func() error) error { | ||
| var lastErr error | ||
| for attempt := range maxAttempts { | ||
| if err := action(); err == nil { | ||
| return nil |
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.
Replace invalid range loops with counted for
The new loops call for i := range tryTimes (and similarly range maxAttempts) where tryTimes and maxAttempts are integers. In Go an int is not iterable, so this code does not compile at all; the range keyword only works with arrays, slices, maps, strings or channels. The original counted for loop compiled correctly. Please switch back to a standard for i := 0; i < tryTimes; i++ style loop (and likewise for the other two retry helpers) so that the package builds.
Useful? React with 👍 / 👎.
…e files Signed-off-by: cuisongliu <[email protected]>
…tions Signed-off-by: cuisongliu <[email protected]>
Signed-off-by: cuisongliu <[email protected]>
…cross multiple files Signed-off-by: cuisongliu <[email protected]>
…multiple files Signed-off-by: cuisongliu <[email protected]>
Signed-off-by: cuisongliu <[email protected]>
Signed-off-by: cuisongliu <[email protected]>
…etry and runner modules Signed-off-by: cuisongliu <[email protected]>
Signed-off-by: cuisongliu <[email protected]>
…s across multiple files Signed-off-by: cuisongliu <[email protected]>
…s across multiple files Signed-off-by: cuisongliu <[email protected]>
…e files