fix(region,host): migrate converted servers (#20698)

This commit is contained in:
wanyaoqi
2024-07-02 00:15:45 +08:00
committed by GitHub
parent 0bf8d46a7b
commit d10428aaf3
2 changed files with 12 additions and 5 deletions
+11 -4
View File
@@ -149,12 +149,19 @@ func (task *GuestMigrateTask) SaveScheduleResult(ctx context.Context, obj ISched
// prepare disk for migration
if len(disk.TemplateId) > 0 && isLocalStorage {
templates := []string{}
guestdisks, _ := guest.GetDisks()
for i := range guestdisks {
if guestdisks[i].TemplateId != "" {
templates = append(templates, guestdisks[i].TemplateId)
if sourceGuestId := guest.GetMetadata(ctx, api.SERVER_META_CONVERT_FROM_ESXI, task.UserCred); len(sourceGuestId) > 0 {
// skip cache images
} else if sourceGuestId := guest.GetMetadata(ctx, api.SERVER_META_CONVERT_FROM_CLOUDPODS, task.UserCred); len(sourceGuestId) > 0 {
// skip cache images
} else {
guestdisks, _ := guest.GetDisks()
for i := range guestdisks {
if guestdisks[i].TemplateId != "" {
templates = append(templates, guestdisks[i].TemplateId)
}
}
}
if len(templates) > 0 {
body.Set("cache_templates", jsonutils.NewStringArray(templates))
}
+1 -1
View File
@@ -835,7 +835,7 @@ func (s *SLocalStorage) DestinationPrepareMigrate(
return errors.Wrap(err, "CreateFromUrl")
}
}
if rebaseDisks && len(templateId) > 0 && len(baseImagePath) == 0 {
if rebaseDisks && len(templateId) > 0 && len(baseImagePath) == 0 && sysDiskHasTemplate {
templatePath := path.Join(storageManager.LocalStorageImagecacheManager.GetPath(), templateId)
// check if template is encrypted
img, err := qemuimg.NewQemuImage(templatePath)