Skip to content

Fix leak in parallel resource creation workflows#2109

Merged
cb-github-robot merged 1 commit intocloud-barista:mainfrom
seokho-son:main
Aug 21, 2025
Merged

Fix leak in parallel resource creation workflows#2109
cb-github-robot merged 1 commit intocloud-barista:mainfrom
seokho-son:main

Conversation

@seokho-son
Copy link
Copy Markdown
Member

fix #2105

Signed-off-by: Seokho Son <shsongist@gmail.com>
Copilot AI review requested due to automatic review settings August 21, 2025 10:33
@seokho-son seokho-son requested a review from yunkon-kim as a code owner August 21, 2025 10:33
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 a resource leak issue in parallel resource creation workflows by implementing VNet readiness checks and reducing unnecessary logging overhead.

  • Added VNet readiness validation with retry mechanisms
  • Reduced random sleep duration in resource deletion from 100ms to 1ms
  • Commented out debug logging for empty label data
  • Updated Docker image version from 0.11.7 to 0.11.8

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/core/infra/provisioning.go Adds waitForVNetReady function and VNet status checks to prevent resource leaks
src/core/resource/common.go Reduces random sleep duration to minimize deletion delays
src/core/common/label/label.go Comments out debug logging for empty label data
docker-compose.yaml Updates Docker image version to 0.11.8

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// waitForVNetReady waits for VNet to be in a ready state with timeout and retry mechanism
func waitForVNetReady(nsId string, vNetId string, reqID string) error {
const (
maxRetries = 200
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The maxRetries value of 200 is a magic number. Consider making this configurable or define it as a named constant with documentation explaining the rationale for this specific value.

Suggested change
maxRetries = 200

Copilot uses AI. Check for mistakes.
const (
maxRetries = 200
retryInterval = 5 * time.Second
progressUpdateInterval = 10 // Update progress every 10 attempts (50 seconds)
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The progressUpdateInterval value of 10 is a magic number. Consider making this configurable or defining it as a named constant to improve maintainability.

Copilot uses AI. Check for mistakes.
time.Sleep(retryInterval)
}

return fmt.Errorf("timeout waiting for VNet '%s' to be ready after %d minutes", vNetId, (maxRetries*int(retryInterval.Seconds()))/60)
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

The timeout calculation (maxRetries*int(retryInterval.Seconds()))/60 is complex and hard to read. Consider extracting this calculation into a variable or constant for better readability.

Suggested change
return fmt.Errorf("timeout waiting for VNet '%s' to be ready after %d minutes", vNetId, (maxRetries*int(retryInterval.Seconds()))/60)
timeoutMinutes := (maxRetries * int(retryInterval.Seconds())) / 60
return fmt.Errorf("timeout waiting for VNet '%s' to be ready after %d minutes", vNetId, timeoutMinutes)

Copilot uses AI. Check for mistakes.
}
if len(labelData) == 0 {
log.Debug().Msg("labelData is empty")
//log.Debug().Msg("labelData is empty")
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

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

Commented-out code should be removed rather than left in place. If this debug logging needs to be conditionally enabled, consider using a feature flag or configuration setting instead.

Suggested change
//log.Debug().Msg("labelData is empty")

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 21, 2025
@cb-github-robot cb-github-robot merged commit 16b705e into cloud-barista:main Aug 21, 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.

Occasionally, Requests the creation of a SecurityGroup before the vNet creation is complete

3 participants