diff --git a/libs/server/domain/src/main/kotlin/org/nxcloudce/server/domain/run/interactor/CleanupRunImpl.kt b/libs/server/domain/src/main/kotlin/org/nxcloudce/server/domain/run/interactor/CleanupRunImpl.kt index 09eaedf1..9807377e 100644 --- a/libs/server/domain/src/main/kotlin/org/nxcloudce/server/domain/run/interactor/CleanupRunImpl.kt +++ b/libs/server/domain/src/main/kotlin/org/nxcloudce/server/domain/run/interactor/CleanupRunImpl.kt @@ -4,6 +4,7 @@ import kotlinx.coroutines.async import kotlinx.coroutines.awaitAll import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch +import org.jboss.logging.Logger import org.nxcloudce.server.domain.run.gateway.ArtifactRepository import org.nxcloudce.server.domain.run.gateway.RunRepository import org.nxcloudce.server.domain.run.gateway.StorageService @@ -18,11 +19,16 @@ class CleanupRunImpl( private val artifactRepository: ArtifactRepository, private val storageService: StorageService, ) : CleanupRun { + companion object { + private val logger = Logger.getLogger(CleanupRunImpl::class.java) + } + override suspend fun invoke( request: CleanupRunRequest, presenter: (CleanupRunResponse) -> T, ): T { val runs = runRepository.findAllByCreationDateOlderThan(request.creationDateThreshold) + logger.info("Found run(s) to delete: ${runs.size}") runs.forEach { run -> val tasks = taskRepository.findAllByRunId(run.id) @@ -31,6 +37,7 @@ class CleanupRunImpl( tasks.filter { it.artifactId != null }.map { it.hash }, run.workspaceId, ) + logger.info("Run contains ${tasks.size} task(s) and ${artifacts.size} artifact(s)") coroutineScope { artifacts.map { artifact -> @@ -43,10 +50,12 @@ class CleanupRunImpl( } } .awaitAll() + logger.info("Artifacts and their files have deleted") coroutineScope { launch { taskRepository.deleteAllByRunId(run.id) } launch { runRepository.delete(run) } } + logger.info("Tasks and run have been deleted") } return presenter(CleanupRunResponse(deletedCount = runs.size))