Merge pull request #5123 from rainzm/automated-cherry-pick-of-#5121-upstream-release-3.1

Automated cherry pick of #5121: fix(esxiagent): Delete image backup file after saving to glance instead of before
This commit is contained in:
yunion-ci-robot
2020-02-14 17:42:05 +08:00
committed by GitHub
+2 -1
View File
@@ -409,7 +409,6 @@ func (as *SAgentStorage) PrepareSaveToGlance(ctx context.Context, taskId string,
destDir := as.GetImgsaveBackupPath()
as.checkDirC(destDir)
backupPath := filepath.Join(destDir, fmt.Sprintf("%s.%s", spec.Vm.PrivateId, taskId))
defer as.checkFileR(backupPath)
client, err := esxi.NewESXiClientFromAccessInfo(ctx, &spec.Vm)
if err != nil {
@@ -458,6 +457,8 @@ func (as *SAgentStorage) SaveToGlance(ctx context.Context, params interface{}) (
as.onSaveToGlanceFailed(ctx, imageId)
return nil, err
}
// delete the backup image
as.checkFileR(imagePath)
imagecacheManager := as.Manager.LocalStorageImagecacheManager
if len(imagecacheManager.GetId()) > 0 {