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")