From 1f0f16875a4306d489bd64a86140fd99a06156a7 Mon Sep 17 00:00:00 2001 From: zacYL <100330102+zacYL@users.noreply.github.com> Date: Sun, 18 Feb 2024 17:21:47 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E8=B0=83=E6=95=B4=20#1748?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 删除多以的依赖 #1748 * feat: 历史数据刷新调整 #1748 * feat: 打印调整 #1748 --- .../helm/service/impl/AbstractChartService.kt | 4 ++++ .../helm/service/impl/FixToolServiceImpl.kt | 24 +++++++++++-------- src/backend/settings.gradle.kts | 2 -- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt index a16f0a4a89..7c30823eba 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/AbstractChartService.kt @@ -95,6 +95,7 @@ import com.tencent.bkrepo.helm.utils.TimeFormatUtil import com.tencent.bkrepo.repository.api.MetadataClient import com.tencent.bkrepo.repository.api.NodeClient import com.tencent.bkrepo.repository.api.PackageClient +import com.tencent.bkrepo.repository.api.PackageMetadataClient import com.tencent.bkrepo.repository.api.ProxyChannelClient import com.tencent.bkrepo.repository.api.RepositoryClient import com.tencent.bkrepo.repository.pojo.node.NodeDetail @@ -123,6 +124,9 @@ open class AbstractChartService : ArtifactService() { @Autowired lateinit var metadataClient: MetadataClient + @Autowired + lateinit var packageMetadataClient: PackageMetadataClient + @Autowired lateinit var repositoryClient: RepositoryClient diff --git a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt index f5b599458b..c98e6e2311 100644 --- a/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt +++ b/src/backend/helm/biz-helm/src/main/kotlin/com/tencent/bkrepo/helm/service/impl/FixToolServiceImpl.kt @@ -41,6 +41,7 @@ import com.tencent.bkrepo.common.artifact.constant.ARTIFACT_INFO_KEY import com.tencent.bkrepo.common.artifact.pojo.RepositoryCategory import com.tencent.bkrepo.common.artifact.repository.context.ArtifactQueryContext import com.tencent.bkrepo.common.artifact.stream.Range +import com.tencent.bkrepo.common.artifact.util.PackageKeys import com.tencent.bkrepo.common.query.enums.OperationType import com.tencent.bkrepo.common.query.model.PageLimit import com.tencent.bkrepo.common.query.model.QueryModel @@ -54,8 +55,7 @@ import com.tencent.bkrepo.helm.constants.CHART_PACKAGE_FILE_EXTENSION import com.tencent.bkrepo.helm.constants.FULL_PATH import com.tencent.bkrepo.helm.constants.HelmMessageCode import com.tencent.bkrepo.helm.constants.NODE_FULL_PATH -import com.tencent.bkrepo.helm.constants.SIZE -import com.tencent.bkrepo.helm.constants.SLEEP_MILLIS +import com.tencent.bkrepo.helm.constants.NODE_METADATA import com.tencent.bkrepo.helm.exception.HelmBadRequestException import com.tencent.bkrepo.helm.exception.HelmFileNotFoundException import com.tencent.bkrepo.helm.pojo.artifact.HelmArtifactInfo @@ -70,6 +70,7 @@ import com.tencent.bkrepo.helm.utils.HelmMetadataUtils import com.tencent.bkrepo.helm.utils.HelmUtils import com.tencent.bkrepo.helm.utils.TimeFormatUtil import com.tencent.bkrepo.repository.pojo.metadata.MetadataSaveRequest +import com.tencent.bkrepo.repository.pojo.metadata.packages.PackageMetadataSaveRequest import com.tencent.bkrepo.repository.pojo.node.NodeInfo import com.tencent.bkrepo.repository.pojo.packages.request.PopulatedPackageVersion import com.tencent.bkrepo.repository.pojo.repo.RepositoryDetail @@ -414,21 +415,24 @@ class FixToolServiceImpl( ", size [${nodeList.size}] " ) val context = ArtifactQueryContext() - nodeList.forEach { - Thread.sleep(SLEEP_MILLIS) + for (it in nodeList) { try { val path = it[NODE_FULL_PATH] as String + val nodeMetadata = it[NODE_METADATA] as Map + if (nodeMetadata.size > 3) { + continue + } val chartMetadata = queryHelmChartMetadata(context, path) val metadata = HelmMetadataUtils.convertToMetadata(chartMetadata) context.putAttribute(FULL_PATH, path) - createVersion( - userId = context.userId, + val packageMetadataRequest = PackageMetadataSaveRequest( projectId = artifactInfo.projectId, repoName = artifactInfo.repoName, - chartInfo = chartMetadata, - size = context.getLongAttribute(SIZE)!!, - isOverwrite = true + packageKey = PackageKeys.ofHelm(chartMetadata.name), + version = chartMetadata.version, + versionMetadata = metadata ) + packageMetadataClient.saveMetadata(packageMetadataRequest) val metadataSaveRequest = MetadataSaveRequest( projectId = artifactInfo.projectId, repoName = artifactInfo.repoName, @@ -438,7 +442,7 @@ class FixToolServiceImpl( ) metadataClient.saveMetadata(metadataSaveRequest) } catch (e: Exception) { - logger.error("error occurred while updating meta data, error: ${e.message}") + logger.warn("error occurred while updating metadata of $it, error: ${e.message}") } } } diff --git a/src/backend/settings.gradle.kts b/src/backend/settings.gradle.kts index 0abe98e6e4..54b7575312 100644 --- a/src/backend/settings.gradle.kts +++ b/src/backend/settings.gradle.kts @@ -67,9 +67,7 @@ includeAll(":composer") includeAll(":generic") includeAll(":helm") includeAll(":maven") -includeAll(":monitor") includeAll(":npm") -includeAll(":npm-registry") includeAll(":nuget") includeAll(":opdata") includeAll(":pypi")