diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/ArtifactCleanupJob.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/ArtifactCleanupJob.kt index 968b460a8d..5360ccf89b 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/ArtifactCleanupJob.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/ArtifactCleanupJob.kt @@ -36,6 +36,7 @@ import com.tencent.bkrepo.common.artifact.pojo.configuration.RepositoryConfigura import com.tencent.bkrepo.common.security.constant.MS_AUTH_HEADER_SECURITY_TOKEN import com.tencent.bkrepo.common.security.service.ServiceAuthManager import com.tencent.bkrepo.common.service.log.LoggerHolder +import com.tencent.bkrepo.job.IGNORE_PROJECT_PREFIX_LIST import com.tencent.bkrepo.job.PROJECT import com.tencent.bkrepo.job.REPO import com.tencent.bkrepo.job.batch.base.DefaultContextMongoDbJob @@ -92,11 +93,12 @@ class ArtifactCleanupJob( return Query() } - override fun getLockAtMostFor(): Duration = Duration.ofDays(14) + override fun getLockAtMostFor(): Duration = Duration.ofDays(1) override fun run(row: RepoData, collectionName: String, context: JobContext) { try { + if (ignoreProjectOrRepoCheck(row.projectId)) return val config = row.configuration.readJsonString() val cleanupStrategyMap = config.getSetting>(CLEAN_UP_STRATEGY) ?: return val cleanupStrategy = toCleanupStrategy(cleanupStrategyMap) ?: return @@ -129,6 +131,13 @@ class ArtifactCleanupJob( } } + /** + * 判断项目或者仓库是否不需要进行目录统计 + */ + private fun ignoreProjectOrRepoCheck(projectId: String): Boolean { + return IGNORE_PROJECT_PREFIX_LIST.firstOrNull { projectId.startsWith(it) } != null + } + private fun toCleanupStrategy(map: Map): CleanupStrategy? { val cleanupStrategy = CleanupStrategy( enable = map[CleanupStrategy::enable.name] as? Boolean ?: false, diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/base/ActiveProjectService.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/base/ActiveProjectService.kt index 9a1598a021..e3eb125211 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/base/ActiveProjectService.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/batch/base/ActiveProjectService.kt @@ -101,9 +101,6 @@ class ActiveProjectService( return ArrayList(criteriaList).apply { add(TOperateLog::type.inValues(types)) } } - // all - activeProjects = findDistinct(TOperateLog::projectId.name, Criteria().andOperator(criteriaList)) - // download event downloadActiveProjects = findDistinct( TOperateLog::projectId.name, @@ -115,6 +112,7 @@ class ActiveProjectService( TOperateLog::projectId.name, Criteria().andOperator(buildTypesCriteriaList(UPLOAD_EVENTS)) ) + activeProjects = downloadActiveProjects.union(uploadActiveProjects).toMutableSet() // active users activeUsers = findDistinct(TOperateLog::userId.name, TOperateLog::userId.ne("")) diff --git a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/config/properties/ArtifactCleanupJobProperties.kt b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/config/properties/ArtifactCleanupJobProperties.kt index 6009e4c387..42470969ba 100644 --- a/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/config/properties/ArtifactCleanupJobProperties.kt +++ b/src/backend/job/biz-job/src/main/kotlin/com/tencent/bkrepo/job/config/properties/ArtifactCleanupJobProperties.kt @@ -36,5 +36,5 @@ data class ArtifactCleanupJobProperties( var projectList: List = listOf(), // 如配置仓库,则只清理该仓库下的仓库 var repoList: List = listOf(), - override var cron: String = "0 0 5 * * ?" + override var cron: String = "0 0 0 * * ?" ): MongodbJobProperties() \ No newline at end of file