Skip to content

Reduce racing condition for mci dynamic#2126

Merged
cb-github-robot merged 2 commits intocloud-barista:mainfrom
seokho-son:main
Aug 28, 2025
Merged

Reduce racing condition for mci dynamic#2126
cb-github-robot merged 2 commits intocloud-barista:mainfrom
seokho-son:main

Conversation

@seokho-son
Copy link
Copy Markdown
Member

fix #2123

Reduced racing condition for mci dynamic.
Extreamly tested in parallel.

japan-tokyo-cost-optimized-mci VM tested in parallel

순위 VM 이름 스펙 시간당 비용 vCPU 메모리
1 vm-t3a-nano-1 t3a.nano $0.0061 2 0.5GB
2 vm-t3-nano-1 t3.nano $0.0068 2 0.5GB
3 vm-t2-nano-1 t2.nano $0.0076 1 0.5GB
4 vm-t3a-micro-1 t3a.micro $0.0122 2 1GB
5 vm-t3-micro-1 t3.micro $0.0136 2 1GB
6 vm-t2-micro-1 t2.micro $0.0152 1 1GB
7 vm-t3a-small-1 t3a.small $0.0245 2 2GB
8 vm-t3-small-1 t3.small $0.0272 2 2GB
9 vm-t2-small-1 t2.small $0.0304 1 2GB
10 vm-t3a-medium-1 t3a.medium $0.0490 2 4GB
11 vm-t3-medium-1 t3.medium $0.0544 2 4GB
12 vm-t2-medium-1 t2.medium $0.0608 2 4GB
13 vm-c7a-medium-1 c7a.medium $0.0646 2 4GB
14 vm-m7a-medium-1 m7a.medium $0.0749 2 8GB
15 vm-r7a-medium-1 r7a.medium $0.0918 2 16GB
16 vm-c5a-large-1 c5a.large $0.0960 2 4GB
17 vm-c6a-large-1 c6a.large $0.0963 2 8GB
18 vm-t3a-large-1 t3a.large $0.0979 2 8GB
19 vm-c7i-flex-large-1 c7i-flex.large $0.1067 2 8GB
20 vm-c5-large-1 c5.large $0.1070 2 4GB
21 vm-c6i-large-1 c6i.large $0.1070 2 8GB
22 vm-t3-large-1 t3.large $0.1088 2 8GB
23 vm-m6a-large-1 m6a.large $0.1116 2 8GB
24 vm-m5a-large-1 m5a.large $0.1120 2 8GB
25 vm-c7i-large-1 c7i.large $0.1124 2 8GB
26 vm-t2-large-1 t2.large $0.1216 2 8GB
27 vm-c5d-large-1 c5d.large $0.1220 2 8GB
28 vm-m7i-flex-large-1 m7i-flex.large $0.1237 2 8GB
29 vm-m5-large-1 m5.large $0.1240 2 8GB
30 vm-m6i-large-1 m6i.large $0.1240 2 8GB
31 vm-c4-large-1 c4.large $0.1260 2 3.75GB
32 vm-c6id-large-1 c6id.large $0.1281 2 8GB
33 vm-m4-large-1 m4.large $0.1290 2 8GB
34 vm-c7a-large-1 c7a.large $0.1292 2 8GB
35 vm-m7i-large-1 m7i.large $0.1302 2 8GB
36 vm-m5ad-large-1 m5ad.large $0.1340 2 8GB
37 vm-c5n-large-1 c5n.large $0.1360 2 5.25GB
38 vm-r6a-large-1 r6a.large $0.1368 2 16GB
39 vm-r5a-large-1 r5a.large $0.1370 2 16GB
40 vm-c6in-large-1 c6in.large $0.1428 2 8GB
41 vm-m5d-large-1 m5d.large $0.1460 2 8GB
42 vm-m7a-large-1 m7a.large $0.1497 2 8GB
43 vm-r5-large-1 r5.large $0.1520 2 16GB
44 vm-r6i-large-1 r6i.large $0.1520 2 16GB
45 vm-m5n-large-1 m5n.large $0.1530 2 8GB
46 vm-m6id-large-1 m6id.large $0.1533 2 8GB
47 vm-r5ad-large-1 r5ad.large $0.1590 2 16GB
48 vm-r7i-large-1 r7i.large $0.1596 2 16GB
49 vm-r4-large-1 r4.large $0.1600 2 15.25GB
50 vm-r5d-large-1 r5d.large $0.1740 2 16GB
image

Signed-off-by: seokho-son <shsongist@gmail.com>
Signed-off-by: seokho-son <shsongist@gmail.com>
Copilot AI review requested due to automatic review settings August 28, 2025 17:59
@seokho-son seokho-son requested a review from yunkon-kim as a code owner August 28, 2025 17:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable vmObjectErrors is referenced but not defined. This should likely be createErrors based on the context of VM object creation failures.

Copilot uses AI. Check for mistakes.
mciTmp.SystemMessage = append(mciTmp.SystemMessage, errorSummary)

// Add each VM creation error
for _, vmError := range vmCreateErrors {
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable vmCreateErrors is referenced but not defined. This should likely be createErrors based on the context of VM creation failures.

Copilot uses AI. Check for mistakes.
Comment on lines +1587 to +1604
// 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)
Copy link

Copilot AI Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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)

Copilot uses AI. Check for mistakes.
@seokho-son
Copy link
Copy Markdown
Member Author

/approve

@github-actions github-actions bot added the approved This PR is approved and will be merged soon. label Aug 28, 2025
@cb-github-robot cb-github-robot merged commit 51b3d74 into cloud-barista:main Aug 28, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved This PR is approved and will be merged soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

“default VNet ~ already exists” error frequently occurs during MCI creation testing

3 participants