Reduce racing condition for mci dynamic#2126
Reduce racing condition for mci dynamic#2126cb-github-robot merged 2 commits intocloud-barista:mainfrom
Conversation
Signed-off-by: seokho-son <shsongist@gmail.com>
Signed-off-by: seokho-son <shsongist@gmail.com>
There was a problem hiding this comment.
Pull Request Overview
This PR addresses racing conditions in MCI (Multi-Cloud Infrastructure) dynamic provisioning by implementing sequential processing for VMs within the same cloud connection and improving error handling with enhanced system messaging.
- Sequential VM provisioning per connection to reduce API rate limiting and race conditions
- Changed SystemMessage field from string to array for better error tracking
- Enhanced error reporting throughout the MCI creation process
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/core/model/mci.go | Changed SystemMessage field from string to string array |
| src/interface/rest/docs/swagger.yaml | Updated API documentation to reflect SystemMessage as array |
| src/interface/rest/docs/swagger.json | Updated JSON schema for SystemMessage array type |
| src/interface/rest/docs/docs.go | Updated generated documentation for SystemMessage array |
| src/core/infra/provisioning.go | Implemented sequential processing and enhanced error handling with SystemMessage array |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| mciTmp.SystemMessage = append(mciTmp.SystemMessage, errorSummary) | ||
|
|
||
| // Add each VM object creation error | ||
| for _, vmError := range vmObjectErrors { |
There was a problem hiding this comment.
The variable vmObjectErrors is referenced but not defined. This should likely be createErrors based on the context of VM object creation failures.
| mciTmp.SystemMessage = append(mciTmp.SystemMessage, errorSummary) | ||
|
|
||
| // Add each VM creation error | ||
| for _, vmError := range vmCreateErrors { |
There was a problem hiding this comment.
The variable vmCreateErrors is referenced but not defined. This should likely be createErrors based on the context of VM creation failures.
| // errorMsg += "Detailed errors:\n" | ||
| // for _, detail := range errorDetails { | ||
| // errorMsg += fmt.Sprintf(" • %s\n", detail) | ||
| // } | ||
|
|
||
| // if rollbackErr != nil { | ||
| // errorMsg += fmt.Sprintf("CRITICAL: Rollback operation failed: %s\n", rollbackErr.Error()) | ||
| // errorMsg += "Manual cleanup may be required for created resources." | ||
| // return emptyMci, fmt.Errorf("%s", errorMsg) | ||
| // } else { | ||
| // errorMsg += "All created resources have been successfully rolled back." | ||
| // return emptyMci, fmt.Errorf("%s", errorMsg) | ||
| // } | ||
|
|
||
| // cancel is also one of the options | ||
| // // Return error but keep MCI object so user can see the error messages | ||
| // errorMsg := fmt.Sprintf("MCI '%s' resource preparation failed. Check MCI SystemMessage for detailed error information.", req.Name) | ||
| // return emptyMci, fmt.Errorf("%s", errorMsg) |
There was a problem hiding this comment.
Large block of commented-out code should be removed rather than left in the codebase. If this rollback functionality might be needed later, consider implementing it as a configurable option or removing it entirely to improve code readability.
| // errorMsg += "Detailed errors:\n" | |
| // for _, detail := range errorDetails { | |
| // errorMsg += fmt.Sprintf(" • %s\n", detail) | |
| // } | |
| // if rollbackErr != nil { | |
| // errorMsg += fmt.Sprintf("CRITICAL: Rollback operation failed: %s\n", rollbackErr.Error()) | |
| // errorMsg += "Manual cleanup may be required for created resources." | |
| // return emptyMci, fmt.Errorf("%s", errorMsg) | |
| // } else { | |
| // errorMsg += "All created resources have been successfully rolled back." | |
| // return emptyMci, fmt.Errorf("%s", errorMsg) | |
| // } | |
| // cancel is also one of the options | |
| // // Return error but keep MCI object so user can see the error messages | |
| // errorMsg := fmt.Sprintf("MCI '%s' resource preparation failed. Check MCI SystemMessage for detailed error information.", req.Name) | |
| // return emptyMci, fmt.Errorf("%s", errorMsg) | |
|
/approve |
fix #2123
Reduced racing condition for mci dynamic.
Extreamly tested in parallel.
japan-tokyo-cost-optimized-mci VM tested in parallel