From 91c39cf8cdbe02d745cbcc82f8c2ea317a35b896 Mon Sep 17 00:00:00 2001 From: Rain Date: Fri, 14 Feb 2020 17:10:31 +0800 Subject: [PATCH] fix(esxiagent): Delete image backup file after saving to glance instead of before --- pkg/hostman/storageman/storage_agent.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/hostman/storageman/storage_agent.go b/pkg/hostman/storageman/storage_agent.go index ece6f22783..63c8be1754 100644 --- a/pkg/hostman/storageman/storage_agent.go +++ b/pkg/hostman/storageman/storage_agent.go @@ -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 {