Merge pull request #18366 from swordqiu/automated-cherry-pick-of-#18365-upstream-release-3.11

Automated cherry pick of #18365: fix: auto convert missing subformat images
This commit is contained in:
Zexi Li
2023-10-20 12:28:28 +08:00
committed by GitHub
+5
View File
@@ -1905,6 +1905,7 @@ func (img *SImage) doConvert(ctx context.Context, userCred mcclient.TokenCredent
if len(subimgs) == 0 {
needConvert = true
} else {
supportedFormats := make([]string, 0)
for i := 0; i < len(subimgs); i += 1 {
if !utils.IsInStringArray(subimgs[i].Format, options.Options.TargetImageFormats) && subimgs[i].Format != img.DiskFormat {
// no need to have this subformat
@@ -1918,6 +1919,10 @@ func (img *SImage) doConvert(ctx context.Context, userCred mcclient.TokenCredent
if subimgs[i].Status != api.IMAGE_STATUS_ACTIVE {
needConvert = true
}
supportedFormats = append(supportedFormats, subimgs[i].Format)
}
if len(supportedFormats) < len(options.Options.TargetImageFormats) {
needConvert = true
}
}
log.Debugf("doConvert imageStatus %s %v", img.Status, needConvert)