mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): aws rebuild instance os_arch mismatch fix
This commit is contained in:
@@ -1749,6 +1749,8 @@ func fillDiskConfigByImage(ctx context.Context, userCred mcclient.TokenCredentia
|
||||
}
|
||||
if strings.Contains(image.Properties["os_arch"], "aarch") {
|
||||
diskConfig.OsArch = api.OS_ARCH_AARCH64
|
||||
} else {
|
||||
diskConfig.OsArch = image.Properties["os_arch"]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1476,6 +1476,16 @@ func (self *SGuest) PerformRebuildRoot(ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// compare os arch
|
||||
if len(self.InstanceType) > 0 {
|
||||
provider := GetDriver(self.Hypervisor).GetProvider()
|
||||
sku, _ := ServerSkuManager.FetchSkuByNameAndProvider(self.InstanceType, provider, true)
|
||||
if sku != nil && len(sku.CpuArch) > 0 && len(img.Properties["os_arch"]) > 0 && !strings.Contains(img.Properties["os_arch"], sku.CpuArch) {
|
||||
return nil, httperrors.NewConflictError("root disk image(%s) and sku(%s) architecture mismatch", img.Properties["os_arch"], sku.CpuArch)
|
||||
}
|
||||
}
|
||||
|
||||
diskCat := self.CategorizeDisks()
|
||||
if img.MinDiskMB == 0 || img.Status != imageapi.IMAGE_STATUS_ACTIVE {
|
||||
return nil, httperrors.NewInputParameterError("invlid image")
|
||||
|
||||
@@ -1323,7 +1323,7 @@ func (manager *SGuestManager) validateCreateData(
|
||||
input.Disks[0] = rootDiskConfig
|
||||
if sku != nil {
|
||||
if len(rootDiskConfig.OsArch) > 0 && len(sku.CpuArch) > 0 {
|
||||
if strings.Contains(rootDiskConfig.OsArch, sku.CpuArch) {
|
||||
if !strings.Contains(rootDiskConfig.OsArch, sku.CpuArch) {
|
||||
return nil, httperrors.NewConflictError("root disk image(%s) and sku(%s) architecture mismatch", rootDiskConfig.OsArch, sku.CpuArch)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user