improve VM image mapping logic and subnet naming#2282
Merged
cb-github-robot merged 4 commits intocloud-barista:mainfrom Jan 21, 2026
Merged
improve VM image mapping logic and subnet naming#2282cb-github-robot merged 4 commits intocloud-barista:mainfrom
cb-github-robot merged 4 commits intocloud-barista:mainfrom
Conversation
seokho-son
reviewed
Jan 21, 2026
src/core/infra/provisioning.go
Outdated
Comment on lines
+3434
to
+3475
| // Try to lookup and register the image from CSP | ||
| log.Info().Msgf("Image not found in TB, attempting to lookup from CSP: %s", targetImageName) | ||
|
|
||
| handleImageRegistration := func(img model.ImageInfo, err error, imageType string, isCustom bool) { | ||
| if err != nil { | ||
| log.Error().Err(err).Msgf("Failed to register %s: %s", imageType, targetImageName) | ||
| errMsg := fmt.Sprintf("Dependency Missing: Cannot find or register Image (CSP ID: %s) in TB.", targetImageName) | ||
| log.Error().Msg(errMsg) | ||
| } else { | ||
| if isCustom { | ||
| customImageFlag = true | ||
| } | ||
| vmInfoData.ImageId = img.Id | ||
| log.Info().Msgf("Successfully registered %s: %s as %s", imageType, targetImageName, img.Id) | ||
| } | ||
| } | ||
|
|
||
| // First, try to lookup as public image | ||
| _, lookupErr := resource.LookupImage(requestBody.ConnectionName, targetImageName) | ||
| if lookupErr == nil { | ||
| log.Info().Msgf("Public image found in CSP: %s, registering to TB", targetImageName) | ||
|
|
||
| imageReq := &model.ImageReq{ | ||
| Name: targetImageName, | ||
| ConnectionName: requestBody.ConnectionName, | ||
| CspImageName: targetImageName, | ||
| Description: "Auto-registered from existing VM", | ||
| } | ||
| registeredImage, regErr := resource.RegisterImageWithId(model.SystemCommonNs, imageReq, false, false) | ||
| handleImageRegistration(registeredImage, regErr, model.StrImage, false) | ||
| } else { | ||
| // Public image lookup failed, try to register as custom image | ||
| log.Info().Msgf("Public image not found, attempting to register as custom image: %s", targetImageName) | ||
|
|
||
| customImageReq := &model.CustomImageReq{ | ||
| Name: targetImageName, | ||
| ConnectionName: requestBody.ConnectionName, | ||
| CspResourceId: targetImageName, | ||
| } | ||
| registeredImage, regErr := resource.RegisterCustomImageWithId(nsId, customImageReq) | ||
| handleImageRegistration(registeredImage, regErr, model.StrCustomImage, true) | ||
| } |
Member
There was a problem hiding this comment.
Hi @leehyeoklee
Thanks for the contribution. Could you check func EnsureImageAvailable(nsId, connectionName, imageId string) (model.ImageInfo, bool, error) { can be reusable here?
I think both logics are very similar.
Contributor
Author
There was a problem hiding this comment.
Thanks for the suggestion!
I checked EnsureImageAvailable and it covers exactly what I needed. Since the necessary logic was already implemented there, I was able to significantly reduce the code size
seokho-son
reviewed
Jan 21, 2026
src/core/resource/vnet.go
Outdated
Comment on lines
+1487
to
+1488
| Id: fmt.Sprintf("reg-%s", spSubnetInfo.IId.SystemId), | ||
| Name: fmt.Sprintf("reg-%s", spSubnetInfo.IId.NameId), |
Member
There was a problem hiding this comment.
Suggested change
| Id: fmt.Sprintf("reg-%s", spSubnetInfo.IId.SystemId), | |
| Name: fmt.Sprintf("reg-%s", spSubnetInfo.IId.NameId), | |
| Id: fmt.Sprintf("%s", spSubnetInfo.IId.SystemId), | |
| Name: fmt.Sprintf("%s", spSubnetInfo.IId.NameId), |
minor suggestion. :)
Member
|
/approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR improves the resource registration logic for VM images and Subnets.
1. Enhanced Image Registration Logic
unknown.unknownstatus.2. Corrected Subnet Naming
reg-01).spSubnetInfo.IId.SystemIdandspSubnetInfo.IId.NameId) for accurate identification.