Merge pull request #12384 from zexi/glance-s3-image-removed

fix(glance): s3 uploaded image removed
This commit is contained in:
yunion-ci-robot
2021-10-11 14:08:43 +08:00
committed by GitHub
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -115,7 +115,7 @@ type SImage struct {
// 镜像大小, 单位Byte
Size int64 `nullable:"true" list:"user" create:"optional"`
// 存储地址
Location string `nullable:"true"`
Location string `nullable:"true" list:"user"`
// 镜像格式
DiskFormat string `width:"20" charset:"ascii" nullable:"true" list:"user" create:"optional" default:"raw"`
+5 -2
View File
@@ -28,6 +28,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/image/models"
"yunion.io/x/onecloud/pkg/image/options"
"yunion.io/x/onecloud/pkg/mcclient/modules/notify"
"yunion.io/x/onecloud/pkg/util/procutils"
)
@@ -89,8 +90,10 @@ func (self *PutImageTask) OnInit(ctx context.Context, obj db.IStandaloneModel, d
if err != nil {
log.Errorf("failed update image location %s", err)
} else {
if err = procutils.NewCommand("rm", "-f", imagePath).Run(); err != nil {
log.Errorf("failed remove file %s: %s", imagePath, err)
if !strings.Contains(imagePath, options.Options.S3MountPoint) {
if err = procutils.NewCommand("rm", "-f", imagePath).Run(); err != nil {
log.Errorf("failed remove file %s: %s", imagePath, err)
}
}
}
}