-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Fix issue with runtime environment restart failure #8008
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 |
|---|---|---|
|
|
@@ -150,7 +150,7 @@ func runComposeCmdWithLog(operate string, composePath string, logPath string) er | |
|
|
||
| err = cmd.Run() | ||
| if err != nil { | ||
| return errors.New(buserr.New("ErrRuntimeStart").Error() + ":" + err.Error()) | ||
| return errors.New(buserr.New("ErrRuntimeStart").Error() + ":" + stderrBuf.String()) | ||
| } | ||
| return nil | ||
| } | ||
|
|
@@ -263,7 +263,7 @@ func buildRuntime(runtime *model.Runtime, oldImageID string, oldEnv string, rebu | |
| ctx, cancel := context.WithTimeout(context.Background(), 1*time.Hour) | ||
| defer cancel() | ||
|
|
||
| cmd := exec.CommandContext(ctx, "docker-compose", "-f", composePath, "build") | ||
| cmd := exec.CommandContext(ctx, "docker", "compose", "-f", composePath, "build") | ||
| cmd.Stdout = logFile | ||
| var stderrBuf bytes.Buffer | ||
| multiWriterStderr := io.MultiWriter(&stderrBuf, logFile) | ||
|
Member
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. The provided code is written in Go, which is a high-level typed programming language. However, there aren't noticeable syntax issues. But you can apply the best practices like using constant keys instead of variables. Here's some suggestions on how to improve readability and maintainability: And another suggestion could be about refactoring function names since they have a slightly different meaning from what expected. def main():
# Code block here...Remember that these points depend entirely upon understanding the intended use-case for this implementation (e.g., docker compose build command). For detailed analysis, it would help if you give more contextual information. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -306,6 +306,7 @@ const message = { | |
| installerr: 'Installation failed', | ||
| applyerror: 'Apply failed', | ||
| systemrestart: 'Interrupted', | ||
| starterr: 'Startup failed', | ||
| }, | ||
| units: { | ||
| second: 'Second', | ||
|
Member
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. The main difference between the two code bases (the ones before my current knowledge cutoff of September 1, 2021) was that there were different values assigned to some keys inside an object named "message". Specifically: In code snippet from September 1, 2021:
This would be incorrect since it should have been So this is currently corrected with proper names. However, I do not see any other significant differences or issues that need immediate attention. As these codes are still relatively old, if you encounter anything further unexpected, feel free to ask! |
||
|
|
||
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.
There appear to be no syntax errors or logic anomalies. However, regarding optimization suggestions:
cmd.Execute()), consider refactoring this to reduce function calls.ExecuteCommandmethod instead of appending logs after calling it.For future reference, these adjustments apply more generally rather than specifically to this snippet within an existing project, so don't feel restricted by them if they're not relevant. Let me know how can I assist further!