Skip to content

Commit

Permalink
Merge pull request #18365 from swordqiu/hotfix/qj-auto-convert-missin…
Browse files Browse the repository at this point in the history
…g-subformats

fix: auto convert missing subformat images
  • Loading branch information
zexi authored Oct 20, 2023
2 parents 7e6c6e6 + 4e67db0 commit 88dd684
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/image/models/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 88dd684

Please sign in to comment.