fix(esxiagent): Delete image backup file after saving to glance instead of before

This commit is contained in:
Rain
2020-02-14 17:17:06 +08:00
parent f73ac4844f
commit 91c39cf8cd
+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 {