diff --git a/pkg/manager/service.go b/pkg/manager/service.go index 6f51c87f..13fb7225 100644 --- a/pkg/manager/service.go +++ b/pkg/manager/service.go @@ -152,10 +152,15 @@ func (m *Manager) Delete(ctx context.Context, req *rpc.DeleteRequest) (resp *emp log.Info("Backing Image Manager: prepare to delete backing image") defer func() { if err != nil { - log.WithError(err).Error("Backing Image Manager: failed to delete backing image, will continue to do directory cleanup anyway") + log.WithError(err).Warn("Backing Image Manager: failed to delete backing image, will continue to do directory cleanup anyway") } if rmDirErr := os.RemoveAll(types.GetBackingImageDirectory(m.diskPath, req.Name, req.Uuid)); rmDirErr != nil { - log.WithError(rmDirErr).Errorf("Backing Image Manager: failed to remove the backing image work directory at the end of the deletion") + log.WithError(rmDirErr).Warn("Backing Image Manager: failed to remove the backing image work directory at the end of the deletion") + } + // Delete cmd is used to remove the tmp file left on the host as well when preparing backing image file failed. + tmpFilePath := fmt.Sprintf("%s%s", types.GetDataSourceFilePath(m.diskPath, req.Name, req.Uuid), types.TmpFileSuffix) + if rmTmpFileErr := os.RemoveAll(tmpFilePath); rmTmpFileErr != nil { + log.WithError(rmTmpFileErr).Warn("Backing Image Manager: failed to remove the data source tmp file at the end of the deletion") } }() diff --git a/pkg/types/types.go b/pkg/types/types.go index 65e87f9f..0b636a6b 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -38,6 +38,7 @@ const ( StateStarting = State("starting") StateInProgress = State("in-progress") StateFailed = State("failed") + StateFailedAndCleanUp = State("failed-and-cleanup") StateUnknown = State("unknown") StateReady = State("ready") StateReadyForTransfer = State("ready-for-transfer")