From bbfaff005a613f4144a96b434917c7da1cc542b5 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Tue, 6 Jun 2023 17:29:42 +0800 Subject: [PATCH 01/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-docker-build.gradle.kts | 14 ++++-- .../plugins/task-multi-boot-jar.gradle.kts | 46 +++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index f023d7da697..687f89b46e9 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -31,10 +31,13 @@ plugins { val toImageRepo = System.getProperty("to.image.repo") val toImageTag = System.getProperty("to.image.tag") var toImage = System.getProperty("jib.to.image") +val serviceName = System.getProperty("serviceName") // 加这个判断 , 主要是为了编译kts时不报错 if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNullOrBlank())) { - val service = name.replace("boot-", "").replace("-tencent", "") + val service = serviceName.takeUnless { it.isNullOrBlank() } + ?: name.replace("boot-", "") + .replace("-tencent", "") if (toImage.isNullOrBlank() && !toImageRepo.isNullOrBlank()) { toImage = toImageRepo.let { @@ -45,7 +48,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull val configNamespace = System.getProperty("config.namespace") val jvmFlagList = System.getProperty("jvmFlags.file")?.let { File(it).readLines() } ?: emptyList() - + val multiModelDataSource = System.getProperty("devops.multi.datasource") val finalJvmFlags = mutableListOf( "-server", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8080", @@ -80,9 +83,12 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-Dspring.cloud.kubernetes.config.includeProfileSpecificSources=false", "-Dio.undertow.legacy.cookie.ALLOW_HTTP_SEPARATORS_IN_V0=true", "-Dserver.port=80" - ) + ).also{ + if (multiModelDataSource != null) { + it.add("-Ddevops.multi.datasource=$multiModelDataSource") + } + } finalJvmFlags.addAll(jvmFlagList) - jib { // 环境变量 container { diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts new file mode 100644 index 00000000000..ba7ee11eeca --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -0,0 +1,46 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +tasks.register("multiBootJar") { + System.getProperty("devops.multi.from")?.let { multiModuleStr -> + val multiModuleList = multiModuleStr.split(",").toMutableList() + allprojects.filter { + isSpecifiedModulePath(it.path, multiModuleList) + }.forEach { subProject -> addDependencies(subProject.path) } + dependsOn("copyToRelease") + dependsOn("jib") + } +} +fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { + return path.contains("ext") && path.contains("biz") + && multiModuleList.any { module -> path.contains(module) } +} + +fun addDependencies(path: String) { + dependencies { + add("implementation", project(path)) + } +} From 2622ec60b1790fc48b884544ddb0635786f39cce Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 7 Jun 2023 10:03:39 +0800 Subject: [PATCH 02/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-docker-build.gradle.kts | 9 ++++----- .../com/tencent/devops/common/db/DBAutoConfiguration.kt | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index 687f89b46e9..4466fcfe3f1 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -36,19 +36,16 @@ val serviceName = System.getProperty("serviceName") // 加这个判断 , 主要是为了编译kts时不报错 if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNullOrBlank())) { val service = serviceName.takeUnless { it.isNullOrBlank() } - ?: name.replace("boot-", "") - .replace("-tencent", "") - + ?: name.replace("boot-", "").replace("-tencent", "") if (toImage.isNullOrBlank() && !toImageRepo.isNullOrBlank()) { toImage = toImageRepo.let { if (toImageRepo.endsWith("/")) it else it + "/" } + "bkci-" + service + ":" + toImageTag } - val configNamespace = System.getProperty("config.namespace") - val jvmFlagList = System.getProperty("jvmFlags.file")?.let { File(it).readLines() } ?: emptyList() val multiModelDataSource = System.getProperty("devops.multi.datasource") + val finalJvmFlags = mutableListOf( "-server", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8080", @@ -88,7 +85,9 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull it.add("-Ddevops.multi.datasource=$multiModelDataSource") } } + finalJvmFlags.addAll(jvmFlagList) + jib { // 环境变量 container { diff --git a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt index a18cd456a84..10917745ae9 100644 --- a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt @@ -51,6 +51,7 @@ import javax.sql.DataSource @Configuration @PropertySource("classpath:/common-db.properties") @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@ConditionalOnMissingClass("com.tencent.devops.AccessoriesJooqConfiguration") @AutoConfigureBefore(DataSourceAutoConfiguration::class, JooqAutoConfiguration::class) @Import(DBBaseConfiguration::class) @EnableTransactionManagement From 262aeecadff5bccb320103e12ecdd512ffd6c3a4 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Thu, 8 Jun 2023 10:31:20 +0800 Subject: [PATCH 03/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-jar.gradle.kts | 2 +- .../tencent/devops/common/client/Client.kt | 38 +++++++++++++++++++ .../devops/common/db/DBAutoConfiguration.kt | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index ba7ee11eeca..36d177f112c 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -27,7 +27,7 @@ tasks.register("multiBootJar") { System.getProperty("devops.multi.from")?.let { multiModuleStr -> val multiModuleList = multiModuleStr.split(",").toMutableList() - allprojects.filter { + rootProject.subprojects.filter { isSpecifiedModulePath(it.path, multiModuleList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt index cb18ae1a929..4693770b8c2 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt @@ -85,6 +85,8 @@ class Client @Autowired constructor( private const val connectTimeoutSeconds = 5L private const val CACHE_SIZE = 1000L private val longTimeOptions = Request.Options(10L, TimeUnit.SECONDS, 30L, TimeUnit.MINUTES, true) + private val accessoriesServiceList = listOf("experience") + private const val accessoriesName = "accessories" } private val beanCaches: LoadingCache, *> = Caffeine.newBuilder() @@ -279,6 +281,42 @@ class Client @Autowired constructor( ).url() } + private fun findServiceName(clz: KClass<*>): String { + // 单体结构,不分微服务的方式 + if (!assemblyServiceName.isNullOrBlank()) { + return assemblyServiceName + } + var serviceName = interfaces.getOrPut(clz) { + val serviceInterface = AnnotationUtils.findAnnotation(clz.java, ServiceInterface::class.java) + if (serviceInterface != null && serviceInterface.value.isNotBlank()) { + serviceInterface.value + } else { + val packageName = clz.qualifiedName.toString() + val regex = Regex("""com.tencent.devops.([a-z]+).api.([a-zA-Z]+)""") + val matches = regex.find(packageName) + ?: throw ErrorCodeException( + errorCode = SERVICE_COULD_NOT_BE_ANALYZED, + params = arrayOf(packageName) + ) + matches.groupValues[1] + } + } + // 得加一个标识,如果为集成的,才这么操作 + if (isAccessoriesService(serviceName)) { + logger.info("findServiceName:serviceName({})", serviceName) + serviceName = accessoriesName + } + return if (serviceSuffix.isNullOrBlank() || KubernetesUtils.inContainer()) { + serviceName + } else { + "$serviceName$serviceSuffix" + } + } + + private fun isAccessoriesService(serviceName: String): Boolean { + return accessoriesServiceList.contains(serviceName) + } + private fun buildGatewayUrl(path: String, gatewayType: GatewayType = GatewayType.IDC): String { return if (path.startsWith("http://") || path.startsWith("https://")) { diff --git a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt index 10917745ae9..43343e8adbe 100644 --- a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt @@ -33,6 +33,7 @@ import com.zaxxer.hikari.HikariDataSource import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.AutoConfigureBefore import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration import org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration import org.springframework.context.annotation.Bean From c1d128927c1c4e5440472abe3efd90f3943dfdca Mon Sep 17 00:00:00 2001 From: greysonfang Date: Thu, 8 Jun 2023 10:38:06 +0800 Subject: [PATCH 04/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/plugins/task-multi-boot-jar.gradle.kts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 36d177f112c..ede02c326ab 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -35,8 +35,13 @@ tasks.register("multiBootJar") { } } fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { - return path.contains("ext") && path.contains("biz") - && multiModuleList.any { module -> path.contains(module) } + // 由于store微服务下的有些项目名称包含image,在打包image时会把store给误打包,故在打包image时,把store服务剔除 + return if (path.contains("image") && path.contains("store")) { + false + } else { + path.contains("ext") && path.contains("biz") + && multiModuleList.any { module -> path.contains(module) } + } } fun addDependencies(path: String) { From 1652de2c2a639f4829dc72acf90fa6cdc1db7f16 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 12 Jun 2023 10:14:01 +0800 Subject: [PATCH 05/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/com/tencent/devops/common/client/Client.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt index 4693770b8c2..4b240c897f6 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt @@ -85,7 +85,7 @@ class Client @Autowired constructor( private const val connectTimeoutSeconds = 5L private const val CACHE_SIZE = 1000L private val longTimeOptions = Request.Options(10L, TimeUnit.SECONDS, 30L, TimeUnit.MINUTES, true) - private val accessoriesServiceList = listOf("experience") + private val accessoriesServiceList = listOf("experience,support,image,lambda,monitoring") private const val accessoriesName = "accessories" } From 529702128f7fe777314a877fb4699729efbb228a Mon Sep 17 00:00:00 2001 From: greysonfang Date: Tue, 13 Jun 2023 15:52:46 +0800 Subject: [PATCH 06/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/plugins/task-docker-build.gradle.kts | 10 +++++----- .../tencent/devops/common/db/DBAutoConfiguration.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index 4466fcfe3f1..9a6f6e040c1 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -44,7 +44,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull } val configNamespace = System.getProperty("config.namespace") val jvmFlagList = System.getProperty("jvmFlags.file")?.let { File(it).readLines() } ?: emptyList() - val multiModelDataSource = System.getProperty("devops.multi.datasource") + val multiModelService = System.getProperty("devops.multi.from") val finalJvmFlags = mutableListOf( "-server", @@ -53,7 +53,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-XX:+PrintTenuringDistribution", "-XX:+PrintGCDetails", "-XX:+PrintGCDateStamps", - "-XX:MaxGCPauseMillis=200", + "-XX:MaxGCPauseMillis=100", "-XX:+UseG1GC", "-XX:NativeMemoryTracking=summary", "-XX:+HeapDumpOnOutOfMemoryError", @@ -80,9 +80,9 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-Dspring.cloud.kubernetes.config.includeProfileSpecificSources=false", "-Dio.undertow.legacy.cookie.ALLOW_HTTP_SEPARATORS_IN_V0=true", "-Dserver.port=80" - ).also{ - if (multiModelDataSource != null) { - it.add("-Ddevops.multi.datasource=$multiModelDataSource") + ).also { + if (multiModelService != null) { + it.add("-Ddevops.multi.from=$multiModelService") } } diff --git a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt index 43343e8adbe..a6fec8b8bc1 100644 --- a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt @@ -52,7 +52,7 @@ import javax.sql.DataSource @Configuration @PropertySource("classpath:/common-db.properties") @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) -@ConditionalOnMissingClass("com.tencent.devops.AccessoriesJooqConfiguration") +@ConditionalOnMissingClass("com.tencent.devops.accessories.AccessoriesJooqConfiguration") @AutoConfigureBefore(DataSourceAutoConfiguration::class, JooqAutoConfiguration::class) @Import(DBBaseConfiguration::class) @EnableTransactionManagement From 1304a2fa447b6012c69ee743efa4c0cdd03d74d0 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 14 Jun 2023 15:40:09 +0800 Subject: [PATCH 07/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/common/client/Client.kt | 38 +++++++++---------- .../client/MutilJarServiceMapConfiguration.kt | 10 +++++ .../main/resources/META-INF/spring.factories | 3 +- 3 files changed, 30 insertions(+), 21 deletions(-) create mode 100644 src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt index 4b240c897f6..aad3716faf6 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt @@ -49,6 +49,13 @@ import feign.jackson.JacksonEncoder import feign.jaxrs.JAXRSContract import feign.okhttp.OkHttpClient import feign.spring.SpringContract +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient +import org.springframework.context.annotation.DependsOn +import org.springframework.core.annotation.AnnotationUtils +import org.springframework.stereotype.Component import java.lang.reflect.Method import java.security.cert.CertificateException import java.util.concurrent.TimeUnit @@ -56,12 +63,6 @@ import javax.net.ssl.SSLContext import javax.net.ssl.SSLSocketFactory import javax.net.ssl.TrustManager import javax.net.ssl.X509TrustManager -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient -import org.springframework.context.annotation.DependsOn -import org.springframework.stereotype.Component import kotlin.reflect.KClass /** @@ -76,6 +77,7 @@ class Client @Autowired constructor( private val clientErrorDecoder: ClientErrorDecoder, private val commonConfig: CommonConfig, private val bkTag: BkTag, + private val mutilJarServiceMapConfiguration: MutilJarServiceMapConfiguration, objectMapper: ObjectMapper ) { @@ -85,8 +87,6 @@ class Client @Autowired constructor( private const val connectTimeoutSeconds = 5L private const val CACHE_SIZE = 1000L private val longTimeOptions = Request.Options(10L, TimeUnit.SECONDS, 30L, TimeUnit.MINUTES, true) - private val accessoriesServiceList = listOf("experience,support,image,lambda,monitoring") - private const val accessoriesName = "accessories" } private val beanCaches: LoadingCache, *> = Caffeine.newBuilder() @@ -286,7 +286,7 @@ class Client @Autowired constructor( if (!assemblyServiceName.isNullOrBlank()) { return assemblyServiceName } - var serviceName = interfaces.getOrPut(clz) { + val serviceName = interfaces.getOrPut(clz) { val serviceInterface = AnnotationUtils.findAnnotation(clz.java, ServiceInterface::class.java) if (serviceInterface != null && serviceInterface.value.isNotBlank()) { serviceInterface.value @@ -301,22 +301,20 @@ class Client @Autowired constructor( matches.groupValues[1] } } - // 得加一个标识,如果为集成的,才这么操作 - if (isAccessoriesService(serviceName)) { - logger.info("findServiceName:serviceName({})", serviceName) - serviceName = accessoriesName - } + return generateServiceName(serviceName) + } + + private fun generateServiceName(serviceName: String): String { + val mutilJarServiceMap = mutilJarServiceMapConfiguration.propertiesMap + val finalServiceName = mutilJarServiceMap[serviceName] ?: serviceName + logger.info("findServiceName:serviceName({})", finalServiceName) return if (serviceSuffix.isNullOrBlank() || KubernetesUtils.inContainer()) { - serviceName + finalServiceName } else { - "$serviceName$serviceSuffix" + "$finalServiceName$serviceSuffix" } } - private fun isAccessoriesService(serviceName: String): Boolean { - return accessoriesServiceList.contains(serviceName) - } - private fun buildGatewayUrl(path: String, gatewayType: GatewayType = GatewayType.IDC): String { return if (path.startsWith("http://") || path.startsWith("https://")) { diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt new file mode 100644 index 00000000000..5f59507cf18 --- /dev/null +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt @@ -0,0 +1,10 @@ +package com.tencent.devops.common.client + +import org.springframework.boot.context.properties.ConfigurationProperties +import org.springframework.context.annotation.Configuration + +@Configuration +@ConfigurationProperties(prefix = "mutiljar.service.map") +class MutilJarServiceMapConfiguration { + val propertiesMap: Map = mutableMapOf() +} diff --git a/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories b/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories index 9239c595c45..aa57898d083 100644 --- a/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories +++ b/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories @@ -1,2 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.tencent.devops.common.client.ClientAutoConfiguration \ No newline at end of file +com.tencent.devops.common.client.ClientAutoConfiguration,\ +com.tencent.devops.common.client.MutilJarServiceMapConfiguration From 4a886012ef3cf9e52952f10197f9b94131c4ce03 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 14 Jun 2023 15:52:27 +0800 Subject: [PATCH 08/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/common/client/ClientAutoConfiguration.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt index b16de4a0bb0..f261cfda6e3 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt @@ -77,9 +77,10 @@ class ClientAutoConfiguration { clientErrorDecoder: ClientErrorDecoder, commonConfig: CommonConfig, bkTag: BkTag, + mutilJarServiceMapConfiguration: MutilJarServiceMapConfiguration, objectMapper: ObjectMapper, @Autowired(required = false) compositeDiscoveryClient: CompositeDiscoveryClient? - ) = Client(compositeDiscoveryClient, clientErrorDecoder, commonConfig, bkTag, objectMapper) + ) = Client(compositeDiscoveryClient, clientErrorDecoder, commonConfig, bkTag, mutilJarServiceMapConfiguration, objectMapper) @Bean fun consulFilter(bkTag: BkTag) = ConsulFilter(bkTag) From e9cbce8e20d4e165631922100758dc1eff3faf14 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Thu, 15 Jun 2023 11:03:14 +0800 Subject: [PATCH 09/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tencent/devops/common/client/ClientAutoConfiguration.kt | 2 ++ .../devops/common/client/MutilJarServiceMapConfiguration.kt | 4 ++-- .../src/main/resources/META-INF/spring.factories | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt index f261cfda6e3..daab8a27bc0 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt @@ -38,6 +38,7 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.AutoConfigureAfter import org.springframework.boot.autoconfigure.AutoConfigureOrder import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean +import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration import org.springframework.context.annotation.Bean @@ -53,6 +54,7 @@ import org.springframework.core.Ordered @PropertySource("classpath:/common-client.properties") @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @AutoConfigureAfter(ServiceAutoConfiguration::class, LoadBalancerAutoConfiguration::class) +@EnableConfigurationProperties(MutilJarServiceMapConfiguration::class) class ClientAutoConfiguration { @Value("\${spring.cloud.consul.discovery.tags:prod}") diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt index 5f59507cf18..0c1cad185d1 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt @@ -1,9 +1,9 @@ package com.tencent.devops.common.client import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.context.annotation.Configuration +import org.springframework.boot.context.properties.ConstructorBinding -@Configuration +@ConstructorBinding @ConfigurationProperties(prefix = "mutiljar.service.map") class MutilJarServiceMapConfiguration { val propertiesMap: Map = mutableMapOf() diff --git a/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories b/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories index aa57898d083..9e824dc890d 100644 --- a/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories +++ b/src/backend/ci/core/common/common-client/src/main/resources/META-INF/spring.factories @@ -1,3 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.tencent.devops.common.client.ClientAutoConfiguration,\ -com.tencent.devops.common.client.MutilJarServiceMapConfiguration +com.tencent.devops.common.client.ClientAutoConfiguration From afa30d395767a64b8c386061d6afb5c8f53d97e0 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Thu, 15 Jun 2023 11:42:27 +0800 Subject: [PATCH 10/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/com/tencent/devops/common/client/Client.kt | 1 - .../devops/common/client/MutilJarServiceMapConfiguration.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt index aad3716faf6..fb0b06aa1e2 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt @@ -80,7 +80,6 @@ class Client @Autowired constructor( private val mutilJarServiceMapConfiguration: MutilJarServiceMapConfiguration, objectMapper: ObjectMapper ) { - companion object { private val logger = LoggerFactory.getLogger(Client::class.java) private const val readWriteTimeoutSeconds = 15L diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt index 0c1cad185d1..1f613c6a4d8 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt @@ -4,7 +4,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConstructorBinding @ConstructorBinding -@ConfigurationProperties(prefix = "mutiljar.service.map") +@ConfigurationProperties(prefix = "mutiljar.service") class MutilJarServiceMapConfiguration { val propertiesMap: Map = mutableMapOf() } From 79a49dc4a4ec1cb5fccfb0308bd5d5b68d604eb7 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 13 Jun 2023 11:09:08 +0800 Subject: [PATCH 11/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gateway/core/lua/router_srv.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gateway/core/lua/router_srv.lua b/src/gateway/core/lua/router_srv.lua index 934318cbd8a..89e81ea8fe8 100644 --- a/src/gateway/core/lua/router_srv.lua +++ b/src/gateway/core/lua/router_srv.lua @@ -38,6 +38,11 @@ if service_name == "bkrepo" then return end +-- 服务合并 +if config.accessories and config.accessories[service_name] then + service_name = config.accessories[service_name] +end + -- 获取灰度设置 local cache_tail = "" local ns_config = nil From 8933399a546f65ba7def4647198b0855b5c4f305 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 31 Jul 2023 19:52:01 +0800 Subject: [PATCH 12/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt index a6fec8b8bc1..cd70a82c09e 100644 --- a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt @@ -52,7 +52,7 @@ import javax.sql.DataSource @Configuration @PropertySource("classpath:/common-db.properties") @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) -@ConditionalOnMissingClass("com.tencent.devops.accessories.AccessoriesJooqConfiguration") +@ConditionalOnMissingClass("com.tencent.devops.accessories.DataSourceDefinitionRegistrar") @AutoConfigureBefore(DataSourceAutoConfiguration::class, JooqAutoConfiguration::class) @Import(DBBaseConfiguration::class) @EnableTransactionManagement From 85762ced28409b252ad576b016aeee2371900c3f Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 31 Jul 2023 20:15:21 +0800 Subject: [PATCH 13/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-docker-build.gradle.kts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index 9a6f6e040c1..d3e19d05af6 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -33,6 +33,7 @@ val toImageTag = System.getProperty("to.image.tag") var toImage = System.getProperty("jib.to.image") val serviceName = System.getProperty("serviceName") + // 加这个判断 , 主要是为了编译kts时不报错 if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNullOrBlank())) { val service = serviceName.takeUnless { it.isNullOrBlank() } @@ -45,6 +46,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull val configNamespace = System.getProperty("config.namespace") val jvmFlagList = System.getProperty("jvmFlags.file")?.let { File(it).readLines() } ?: emptyList() val multiModelService = System.getProperty("devops.multi.from") + val multiDataSource = System.getProperty("devops.multi.datasource") val finalJvmFlags = mutableListOf( "-server", @@ -84,6 +86,9 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull if (multiModelService != null) { it.add("-Ddevops.multi.from=$multiModelService") } + if (multiDataSource != null) { + it.add("-Ddevops.multi.datasource=$multiDataSource") + } } finalJvmFlags.addAll(jvmFlagList) From 73d0f8ea99ec0fca04b03cefd273d88dad5998f8 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 23 Aug 2023 17:05:30 +0800 Subject: [PATCH 14/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-jar.gradle.kts | 4 +- .../ci/core/auth/boot-auth/build.gradle.kts | 4 + .../mutijar/boot-mutijar/build.gradle.kts | 48 +++++++++++ .../mutijar/DataSourceDefinitionRegistrar.kt | 64 ++++++++++++++ .../devops/mutijar/JooqDefinitionRegistrar.kt | 45 ++++++++++ .../devops/mutijar/MutijarApplication.kt | 49 +++++++++++ .../mutijar/MutijarDslContextConfiguration.kt | 86 +++++++++++++++++++ .../src/main/resources/application.yml | 21 +++++ src/backend/ci/core/mutijar/build.gradle.kts | 30 +++++++ src/backend/ci/settings.gradle.kts | 7 ++ 10 files changed, 356 insertions(+), 2 deletions(-) create mode 100644 src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts create mode 100644 src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt create mode 100644 src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt create mode 100644 src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt create mode 100644 src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt create mode 100644 src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml create mode 100644 src/backend/ci/core/mutijar/build.gradle.kts diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index ede02c326ab..86770d54a0a 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -31,7 +31,7 @@ tasks.register("multiBootJar") { isSpecifiedModulePath(it.path, multiModuleList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") - dependsOn("jib") + // dependsOn("jib") } } fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { @@ -39,7 +39,7 @@ fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean return if (path.contains("image") && path.contains("store")) { false } else { - path.contains("ext") && path.contains("biz") + path.contains("biz") && multiModuleList.any { module -> path.contains(module) } } } diff --git a/src/backend/ci/core/auth/boot-auth/build.gradle.kts b/src/backend/ci/core/auth/boot-auth/build.gradle.kts index b7dd3810af9..eafedf3eab8 100644 --- a/src/backend/ci/core/auth/boot-auth/build.gradle.kts +++ b/src/backend/ci/core/auth/boot-auth/build.gradle.kts @@ -30,3 +30,7 @@ dependencies { api(project(":core:auth:biz-auth-blueking")) api(project(":core:auth:biz-auth-rbac")) } +tasks.named("bootRun") { + //classpath = files("${project.rootDir}\\release\\boot-finalModule.jar") + println("greysonfang-test classpath = ${classpath.asPath}") +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts new file mode 100644 index 00000000000..d1eca936005 --- /dev/null +++ b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts @@ -0,0 +1,48 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import org.springframework.boot.gradle.tasks.bundling.BootJar +import org.springframework.boot.gradle.tasks.run.BootRun + +dependencies { + api(project(":core:common:common-web")) + api(project(":core:common:common-db-base")) + api("mysql:mysql-connector-java") + implementation(kotlin("stdlib")) +} +plugins { + `task-multi-boot-jar` +} + +tasks.named("bootJar") { + val finalModuleName = System.getProperty("devops.multi.to") + archiveBaseName.set("boot-$finalModuleName") +} + +tasks.named("bootRun") { + println("bootRun classpath is :" + classpath.asPath.toString()) + //classpath = files("C:\\Users\\bk-ci-2\\src\\backend\\ci\\core\\mutijar\\boot-mutijar\\build\\classes\\kotlin\\main") +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt new file mode 100644 index 00000000000..b5b7124961d --- /dev/null +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt @@ -0,0 +1,64 @@ +package com.tencent.devops.mutijar + +import com.mysql.jdbc.Driver +import com.tencent.devops.common.web.jasypt.DefaultEncryptor +import com.zaxxer.hikari.HikariDataSource +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.config.YamlPropertiesFactoryBean +import org.springframework.beans.factory.support.BeanDefinitionBuilder +import org.springframework.beans.factory.support.BeanDefinitionRegistry +import org.springframework.beans.factory.support.BeanNameGenerator +import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.ImportBeanDefinitionRegistrar +import org.springframework.core.Ordered +import org.springframework.core.env.Environment +import org.springframework.core.io.ClassPathResource +import org.springframework.core.type.AnnotationMetadata +import org.springframework.transaction.annotation.EnableTransactionManagement +import java.util.Properties + + +@Configuration +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +@EnableTransactionManagement +class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { + override fun registerBeanDefinitions( + importingClassMetadata: AnnotationMetadata, + registry: BeanDefinitionRegistry, + importBeanNameGenerator: BeanNameGenerator + ) { + multiDataSource.forEach { dataSource -> + logger.info("DataSourceDefinitionRegistrar:$dataSource") + val resource = ClassPathResource("application-$dataSource.yml") + val yamlFactory = YamlPropertiesFactoryBean() + yamlFactory.setResources(resource) + val properties = yamlFactory.getObject()!! + val dataSourceUrl = properties.getProperty("spring.datasource.url") + val datasourceUsername = properties.getProperty("spring.datasource.username") + val datasourcePassword = properties.getProperty("spring.datasource.password") + val datasourceInitSql = properties.getProperty("spring.datasource.initSql") + val leakDetectionThreshold = properties.getProperty("spring.datasource.leakDetectionThreshold") ?: 0 + val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HikariDataSource::class.java) + .addPropertyValue("poolName", "DBPool-$dataSource") + .addPropertyValue("jdbcUrl", dataSourceUrl) + .addPropertyValue("username", datasourceUsername!!) + .addPropertyValue("password", datasourcePassword!!) + .addPropertyValue("driverClassName", Driver::class.java.name) + .addPropertyValue("minimumIdle", 10) + .addPropertyValue("maximumPoolSize", 50) + .addPropertyValue("idleTimeout", 60000) + .addPropertyValue("connectionInitSql", datasourceInitSql) + .addPropertyValue("leakDetectionThreshold", leakDetectionThreshold) + .setPrimary(false) + registry.registerBeanDefinition("${dataSource}DataSource", beanDefinitionBuilder.beanDefinition) + } + } + + + companion object { + private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) + private val multiDataSource = listOf("auth","image").filterNot { it == "process" } + private val regex = Regex("""ENC\((.*?)\)""") + } +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt new file mode 100644 index 00000000000..5f85c4de0b5 --- /dev/null +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt @@ -0,0 +1,45 @@ +package com.tencent.devops.mutijar + +import com.tencent.devops.common.db.listener.BkJooqExecuteListener +import org.jooq.SQLDialect +import org.jooq.impl.DataSourceConnectionProvider +import org.jooq.impl.DefaultConfiguration +import org.jooq.impl.DefaultExecuteListenerProvider +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.support.BeanDefinitionBuilder +import org.springframework.beans.factory.support.BeanDefinitionRegistry +import org.springframework.beans.factory.support.BeanNameGenerator +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.ImportBeanDefinitionRegistrar +import org.springframework.core.type.AnnotationMetadata + +@Configuration +class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { + override fun registerBeanDefinitions( + importingClassMetadata: AnnotationMetadata, + registry: BeanDefinitionRegistry, + importBeanNameGenerator: BeanNameGenerator + ) { + multiDataSource.forEach { dataSource -> + val finalDataSource = if (dataSource == "process") "shardingDataSource" else "${dataSource}DataSource" + val connectionProvider = BeanDefinitionBuilder.genericBeanDefinition( + DataSourceConnectionProvider::class.java + ).addConstructorArgReference(finalDataSource) + registry.registerBeanDefinition("${dataSource}ConnectionProvider", connectionProvider.beanDefinition) + val beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultConfiguration::class.java) { + val configuration = DefaultConfiguration() + configuration.set(SQLDialect.MYSQL) + configuration.settings().isRenderSchema = false + configuration.set(DefaultExecuteListenerProvider(BkJooqExecuteListener())) + configuration + } + beanDefinitionBuilder.addPropertyReference("connectionProvider", "${dataSource}ConnectionProvider") + registry.registerBeanDefinition("${dataSource}JooqConfiguration", beanDefinitionBuilder.beanDefinition) + } + } + + companion object { + private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) + private val multiDataSource = listOf("auth","image").filterNot { it == "process" } + } +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt new file mode 100644 index 00000000000..fd3dbeced32 --- /dev/null +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt @@ -0,0 +1,49 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package com.tencent.devops.mutijar + +import com.tencent.devops.common.service.MicroService +import com.tencent.devops.common.service.MicroServiceApplication +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.FilterType + +@MicroService +@ComponentScan( + "com.tencent.devops", + excludeFilters = [ + ComponentScan.Filter( + type = FilterType.REGEX, + pattern = ["com\\.tencent\\.devops\\.common\\..*"] + ) + ] +) +class MutijarApplication + +fun main(args: Array) { + MicroServiceApplication.run(MutijarApplication::class, args) +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt new file mode 100644 index 00000000000..0bea288654b --- /dev/null +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -0,0 +1,86 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.tencent.devops.mutijar + +import com.tencent.devops.common.db.config.DBBaseConfiguration +import org.jooq.DSLContext +import org.jooq.impl.DSL +import org.jooq.impl.DefaultConfiguration +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.InjectionPoint +import org.springframework.beans.factory.NoSuchBeanDefinitionException +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Import +import org.springframework.context.annotation.Primary +import org.springframework.context.annotation.Scope +import java.lang.reflect.AnnotatedElement +import java.lang.reflect.Constructor + +/** + * + * Powered By Tencent + */ +@Configuration +@Import(DBBaseConfiguration::class, DataSourceDefinitionRegistrar::class, JooqDefinitionRegistrar::class) +class MutijarDslContextConfiguration { + @Bean + @Primary + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + fun dslContext( + configurationMap: Map, + injectionPoint: InjectionPoint + ): DSLContext { + val annotatedElement: AnnotatedElement = injectionPoint.annotatedElement + if (Constructor::class.java.isAssignableFrom(annotatedElement::class.java)) { + val declaringClass: Class<*> = (annotatedElement as Constructor<*>).declaringClass + val packageName = declaringClass.getPackage().name + logger.info("packageName:$packageName") + // lambda服务有多个数据源,需要进行处理 + val configurationName = if (packageName.contains(".lambda")) { + val matchResult = lambdaServiceRegex.find(packageName) + "${matchResult?.groupValues?.get(1) ?: "lambda"}JooqConfiguration" + } else { + val serviceName = multiModelService.find { packageName.contains(it) } + ?: throw NoSuchBeanDefinitionException("no jooq configuration") + serviceName.removePrefix(".").plus("JooqConfiguration") + } + logger.info("AccessoriesJooqConfiguration:$configurationName") + val configuration: org.jooq.Configuration = configurationMap[configurationName] + ?: throw NoSuchBeanDefinitionException("no $configurationName") + return DSL.using(configuration) + } + throw NoSuchBeanDefinitionException("no jooq configuration") + } + + companion object { + private val logger = LoggerFactory.getLogger(MutijarDslContextConfiguration::class.java) + private val multiModelService = listOf("auth","image").filterNot { it == "process" } + private val lambdaServiceRegex = "\\.(tsource|ttarget|process|project|store)".toRegex() + } +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml b/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml new file mode 100644 index 00000000000..ac834873dd3 --- /dev/null +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml @@ -0,0 +1,21 @@ +spring: + profiles: + active: + - common + - auth + - image + main: + allow-bean-definition-overriding: true + application: + name: mutijar + desc: DevOps MUTIJAR Service + version: 4.0.0 + packageName: com.tencent.devops.mutijar + cloud: + config: + fail-fast: true +server: + port: 21930 +logging: + level: + root=DEBUG: DEBUG diff --git a/src/backend/ci/core/mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/build.gradle.kts new file mode 100644 index 00000000000..1216a155ec6 --- /dev/null +++ b/src/backend/ci/core/mutijar/build.gradle.kts @@ -0,0 +1,30 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +subprojects { + group = "com.tencent.bk.devops.ci.mutijar" +} diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index bbcf02fd0e9..6573d628329 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -267,3 +267,10 @@ include(":core:metrics:biz-metrics") include(":core:metrics:biz-metrics-sample") include(":core:metrics:boot-metrics") include(":core:metrics:model-metrics") + +include("core:mutijar") +include("core:mutijar:boot-mutijar") +include("core:mutijar:boot-mutijar") +findProject(":core:mutijar:boot-mutijar")?.name = "boot-mutijar" +include("core:mutijar:boot-mutijar") +findProject(":core:mutijar:boot-mutijar")?.name = "boot-mutijar" From 4ae4fc4ccc8a371c9ae43f05fbcda0145eea7c53 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 9 Aug 2023 10:37:09 +0800 Subject: [PATCH 15/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-jar.gradle.kts | 1 + .../devops/auth/service/MyStartupTask.kt | 18 ++++++++++++++++++ .../mutijar/DataSourceDefinitionRegistrar.kt | 2 +- .../devops/mutijar/JooqDefinitionRegistrar.kt | 5 +++-- .../mutijar/MutijarDslContextConfiguration.kt | 2 +- .../service/measure/MeasureServiceImpl.kt | 2 -- .../rule/processor/BkVarProcessorService.kt | 6 +++--- .../api/ServiceScmWebhookResourceImpl.kt | 3 ++- .../config/PipelinePermConfiguration.kt | 14 ++++++++------ .../webhook/PipelineBuildWebhookService.kt | 8 ++++---- .../SamplePipelineBuildWebhookService.kt | 4 ++-- 11 files changed, 43 insertions(+), 22 deletions(-) create mode 100644 src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 86770d54a0a..a10d609ab12 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -31,6 +31,7 @@ tasks.register("multiBootJar") { isSpecifiedModulePath(it.path, multiModuleList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") + dependsOn("bootRun") // dependsOn("jib") } } diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt new file mode 100644 index 00000000000..eddf3550b37 --- /dev/null +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt @@ -0,0 +1,18 @@ +package com.tencent.devops.auth.service + +import org.slf4j.LoggerFactory +import org.springframework.stereotype.Component +import javax.annotation.PostConstruct + + +@Component +class MyStartupTask { + @PostConstruct + fun init() { + logger.info("MyStartupTask init") + } + + companion object { + private val logger = LoggerFactory.getLogger(MyStartupTask::class.java) + } +} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt index b5b7124961d..fa03120d647 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt @@ -58,7 +58,7 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) - private val multiDataSource = listOf("auth","image").filterNot { it == "process" } + private val multiDataSource = listOf("auth", "image", "process") private val regex = Regex("""ENC\((.*?)\)""") } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt index 5f85c4de0b5..56bff066f16 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt @@ -21,7 +21,8 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { importBeanNameGenerator: BeanNameGenerator ) { multiDataSource.forEach { dataSource -> - val finalDataSource = if (dataSource == "process") "shardingDataSource" else "${dataSource}DataSource" + //if (dataSource == "process") "shardingDataSource" else + val finalDataSource = "${dataSource}DataSource" val connectionProvider = BeanDefinitionBuilder.genericBeanDefinition( DataSourceConnectionProvider::class.java ).addConstructorArgReference(finalDataSource) @@ -40,6 +41,6 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) - private val multiDataSource = listOf("auth","image").filterNot { it == "process" } + private val multiDataSource = listOf("auth", "image", "process") } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt index 0bea288654b..2931860c49e 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -80,7 +80,7 @@ class MutijarDslContextConfiguration { companion object { private val logger = LoggerFactory.getLogger(MutijarDslContextConfiguration::class.java) - private val multiModelService = listOf("auth","image").filterNot { it == "process" } + private val multiModelService = listOf("auth", "image", "process") private val lambdaServiceRegex = "\\.(tsource|ttarget|process|project|store)".toRegex() } } diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt index ffdf3cfe166..9288ded4468 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt @@ -67,8 +67,6 @@ class MeasureServiceImpl : MeasureService { @Autowired lateinit var buildVariableService: BuildVariableService @Autowired - lateinit var dslContext: DSLContext - @Autowired lateinit var templateService: TemplateService @Autowired lateinit var pipelineInfoService: PipelineInfoService diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt index 423e0e3ec9d..385fad2e3a7 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt @@ -33,10 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service("BkVarProcessor") -class BkVarProcessorService : ProcessorService { +class BkVarProcessorService constructor( + private val dslContext: DSLContext +) : ProcessorService { - @Autowired - private lateinit var dslContext: DSLContext @Autowired private lateinit var pipelineBuildVarDao: PipelineBuildVarDao diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt index 5e126a76aea..ad488b32c76 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt @@ -42,8 +42,9 @@ import com.tencent.devops.process.webhook.CodeWebhookEventDispatcher import com.tencent.devops.process.webhook.pojo.event.commit.GithubWebhookEvent import org.springframework.amqp.rabbit.core.RabbitTemplate import org.springframework.beans.factory.annotation.Autowired +import org.springframework.context.annotation.Lazy -@RestResource +//@RestResource class ServiceScmWebhookResourceImpl @Autowired constructor( private val pipelineBuildWebhookService: PipelineBuildWebhookService, private val rabbitTemplate: RabbitTemplate, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt index 32dc02fe414..d385f9afc37 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt @@ -54,7 +54,9 @@ import org.springframework.core.Ordered @Configuration @ConditionalOnWebApplication @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) -class PipelinePermConfiguration { +class PipelinePermConfiguration constructor( + val dslContext: DSLContext +){ @Bean @ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "bk_login") @@ -73,7 +75,7 @@ class PipelinePermConfiguration { @Bean @ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "sample") fun mockPipelinePermissionService( - dslContext: DSLContext, + pipelineInfoDao: PipelineInfoDao, authProjectApi: AuthProjectApi, authResourceApi: AuthResourceApi, @@ -91,7 +93,7 @@ class PipelinePermConfiguration { @Bean @ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "bk_login_v3") fun v3pipelinePermissionService( - dslContext: DSLContext, + client: Client, redisOperation: RedisOperation, pipelineInfoDao: PipelineInfoDao, @@ -115,7 +117,7 @@ class PipelinePermConfiguration { fun githubStreamPipelinePermissionService( client: Client, pipelineInfoDao: PipelineInfoDao, - dslContext: DSLContext, + checkTokenService: ClientTokenService ): PipelinePermissionService = StreamPipelinePermissionServiceImpl( client = client, @@ -129,7 +131,7 @@ class PipelinePermConfiguration { fun gitlabStreamPipelinePermissionService( client: Client, pipelineInfoDao: PipelineInfoDao, - dslContext: DSLContext, + checkTokenService: ClientTokenService ): PipelinePermissionService = StreamPipelinePermissionServiceImpl( client = client, @@ -144,7 +146,7 @@ class PipelinePermConfiguration { authPermissionApi: AuthPermissionApi, authProjectApi: AuthProjectApi, pipelineAuthServiceCode: PipelineAuthServiceCode, - dslContext: DSLContext, + pipelineInfoDao: PipelineInfoDao, pipelineViewGroupService: PipelineViewGroupService, authResourceApi: AuthResourceApi diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt index 3ed4f069ed7..5d7d25f2777 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt @@ -81,8 +81,10 @@ import com.tencent.devops.repository.utils.RepositoryUtils import org.slf4j.LoggerFactory import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware +import org.springframework.stereotype.Service @Suppress("ALL") +@Service abstract class PipelineBuildWebhookService : ApplicationContextAware { override fun setApplicationContext(applicationContext: ApplicationContext) { @@ -95,7 +97,6 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { gitWebhookUnlockDispatcher = applicationContext.getBean(GitWebhookUnlockDispatcher::class.java) pipelineWebHookQueueService = applicationContext.getBean(PipelineWebHookQueueService::class.java) buildLogPrinter = applicationContext.getBean(BuildLogPrinter::class.java) - pipelinebuildWebhookService = applicationContext.getBean(PipelineBuildWebhookService::class.java) pipelineBuildCommitService = applicationContext.getBean(PipelineBuildCommitService::class.java) webhookBuildParameterService = applicationContext.getBean(WebhookBuildParameterService::class.java) } @@ -110,7 +111,6 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { lateinit var gitWebhookUnlockDispatcher: GitWebhookUnlockDispatcher lateinit var pipelineWebHookQueueService: PipelineWebHookQueueService lateinit var buildLogPrinter: BuildLogPrinter - lateinit var pipelinebuildWebhookService: PipelineBuildWebhookService // 给AOP调用 lateinit var pipelineBuildCommitService: PipelineBuildCommitService lateinit var webhookBuildParameterService: WebhookBuildParameterService private val logger = LoggerFactory.getLogger(PipelineBuildWebhookService::class.java) @@ -265,13 +265,13 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { return@outside } - if (pipelinebuildWebhookService.webhookTriggerPipelineBuild( + /*if (pipelinebuildWebhookService.webhookTriggerPipelineBuild( projectId = projectId, pipelineId = pipelineId, codeRepositoryType = codeRepositoryType, matcher = matcher ) - ) return@outside + ) return@outside*/ } catch (e: Throwable) { logger.warn("[$pipelineId]|webhookTriggerPipelineBuild fail: $e", e) } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt index 6d854932e19..bad968e018d 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt @@ -56,7 +56,7 @@ class SamplePipelineBuildWebhookService : PipelineBuildWebhookService() { ) } - @BkTimed // 要aop生效必须在子类上拦截 +/* @BkTimed // 要aop生效必须在子类上拦截 override fun webhookTriggerPipelineBuild( projectId: String, pipelineId: String, @@ -64,5 +64,5 @@ class SamplePipelineBuildWebhookService : PipelineBuildWebhookService() { matcher: ScmWebhookMatcher ): Boolean { return super.webhookTriggerPipelineBuild(projectId, pipelineId, codeRepositoryType, matcher) - } + }*/ } From f268e0739a33b51ac73a422c7ae0c13bc5749c8e Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 23 Aug 2023 17:09:44 +0800 Subject: [PATCH 16/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts | 2 +- src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts | 6 ++++-- .../tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt | 2 +- .../com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt | 2 +- .../devops/mutijar/MutijarDslContextConfiguration.kt | 2 +- .../process/service/webhook/PipelineBuildWebhookService.kt | 6 ++---- .../webhook/service/SamplePipelineBuildWebhookService.kt | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index a10d609ab12..165bec29346 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -31,7 +31,7 @@ tasks.register("multiBootJar") { isSpecifiedModulePath(it.path, multiModuleList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") - dependsOn("bootRun") + //dependsOn("bootRun") // dependsOn("jib") } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts index d1eca936005..15545ba228f 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts +++ b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts @@ -43,6 +43,8 @@ tasks.named("bootJar") { } tasks.named("bootRun") { - println("bootRun classpath is :" + classpath.asPath.toString()) - //classpath = files("C:\\Users\\bk-ci-2\\src\\backend\\ci\\core\\mutijar\\boot-mutijar\\build\\classes\\kotlin\\main") + dependsOn("multiBootJar") + doFirst { + systemProperty("devops.multi.from", System.getProperty("devops.multi.from")) + } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt index fa03120d647..7fb83424aa5 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt @@ -58,7 +58,7 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) - private val multiDataSource = listOf("auth", "image", "process") + private val multiDataSource = System.getProperty("devops.multi.from").split(",") private val regex = Regex("""ENC\((.*?)\)""") } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt index 56bff066f16..4852ec380fb 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt @@ -41,6 +41,6 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) - private val multiDataSource = listOf("auth", "image", "process") + private val multiDataSource = System.getProperty("devops.multi.from").split(",") } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt index 2931860c49e..27258c8037d 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -80,7 +80,7 @@ class MutijarDslContextConfiguration { companion object { private val logger = LoggerFactory.getLogger(MutijarDslContextConfiguration::class.java) - private val multiModelService = listOf("auth", "image", "process") + private val multiModelService = System.getProperty("devops.multi.from").split(",") private val lambdaServiceRegex = "\\.(tsource|ttarget|process|project|store)".toRegex() } } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt index 5d7d25f2777..2d5f7b0332a 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt @@ -81,10 +81,8 @@ import com.tencent.devops.repository.utils.RepositoryUtils import org.slf4j.LoggerFactory import org.springframework.context.ApplicationContext import org.springframework.context.ApplicationContextAware -import org.springframework.stereotype.Service @Suppress("ALL") -@Service abstract class PipelineBuildWebhookService : ApplicationContextAware { override fun setApplicationContext(applicationContext: ApplicationContext) { @@ -265,13 +263,13 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { return@outside } - /*if (pipelinebuildWebhookService.webhookTriggerPipelineBuild( + if (webhookTriggerPipelineBuild( projectId = projectId, pipelineId = pipelineId, codeRepositoryType = codeRepositoryType, matcher = matcher ) - ) return@outside*/ + ) return@outside } catch (e: Throwable) { logger.warn("[$pipelineId]|webhookTriggerPipelineBuild fail: $e", e) } diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt index bad968e018d..6d854932e19 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/webhook/service/SamplePipelineBuildWebhookService.kt @@ -56,7 +56,7 @@ class SamplePipelineBuildWebhookService : PipelineBuildWebhookService() { ) } -/* @BkTimed // 要aop生效必须在子类上拦截 + @BkTimed // 要aop生效必须在子类上拦截 override fun webhookTriggerPipelineBuild( projectId: String, pipelineId: String, @@ -64,5 +64,5 @@ class SamplePipelineBuildWebhookService : PipelineBuildWebhookService() { matcher: ScmWebhookMatcher ): Boolean { return super.webhookTriggerPipelineBuild(projectId, pipelineId, codeRepositoryType, matcher) - }*/ + } } From c4d5e07390a488b8559db24ea9a8078bb1ec139e Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 16 Aug 2023 09:56:23 +0800 Subject: [PATCH 17/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-jar.gradle.kts | 3 +- .../plugins/task-multi-boot-run.gradle.kts | 47 +++++++++++++++++++ .../devops/auth/service/MyStartupTask.kt | 2 +- .../mutijar/boot-mutijar/build.gradle.kts | 8 +--- .../mutijar/DataSourceDefinitionRegistrar.kt | 2 +- .../devops/mutijar/JooqDefinitionRegistrar.kt | 4 +- .../mutijar/MutijarDslContextConfiguration.kt | 12 ++++- .../api/ServiceScmWebhookResourceImpl.kt | 2 +- .../config/PipelinePermConfiguration.kt | 14 +++--- .../webhook/PipelineBuildWebhookService.kt | 4 +- .../core/project/biz-project/build.gradle.kts | 2 +- .../tencent/devops/project/config/OpConfig.kt | 9 ++++ 12 files changed, 83 insertions(+), 26 deletions(-) create mode 100644 src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 165bec29346..793f9845bc8 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -31,10 +31,9 @@ tasks.register("multiBootJar") { isSpecifiedModulePath(it.path, multiModuleList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") - //dependsOn("bootRun") - // dependsOn("jib") } } + fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { // 由于store微服务下的有些项目名称包含image,在打包image时会把store给误打包,故在打包image时,把store服务剔除 return if (path.contains("image") && path.contains("store")) { diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts new file mode 100644 index 00000000000..3df86756f0e --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -0,0 +1,47 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import org.springframework.boot.gradle.tasks.bundling.BootJar +import org.springframework.boot.gradle.tasks.run.BootRun + +tasks.register("multiBootRun") { + doFirst { + systemProperty("devops.multi.from", System.getProperty("devops.multi.from")) + systemProperty("spring.main.allow-circular-references", "true") + systemProperty("spring.cloud.config.enabled", "false") + systemProperty("spring.cloud.config.fail-fast", "true") + systemProperty("spring.jmx.enabled", "true") + systemProperty("jasypt.encryptor.bootstrap", "false") + systemProperty("sun.jnu.encoding", "UTF-8") + systemProperty("file.encoding", "UTF-8") + systemProperty("spring.cloud.consul.host", "localhost") + } + dependsOn("multiBootJar") + val bootJarTask = tasks.getByName("bootJar") + println("multi boot run:${bootJarTask.mainClass}|${bootJarTask.classpath}") + mainClass.set(bootJarTask.mainClass) + classpath = bootJarTask.classpath +} diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt index eddf3550b37..99cb5480338 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt @@ -6,7 +6,7 @@ import javax.annotation.PostConstruct @Component -class MyStartupTask { +class MyStartupTask { @PostConstruct fun init() { logger.info("MyStartupTask init") diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts index 15545ba228f..64d377d0be4 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts +++ b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts @@ -35,16 +35,10 @@ dependencies { } plugins { `task-multi-boot-jar` + `task-multi-boot-run` } tasks.named("bootJar") { val finalModuleName = System.getProperty("devops.multi.to") archiveBaseName.set("boot-$finalModuleName") } - -tasks.named("bootRun") { - dependsOn("multiBootJar") - doFirst { - systemProperty("devops.multi.from", System.getProperty("devops.multi.from")) - } -} diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt index 7fb83424aa5..da09b8360bd 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt @@ -58,7 +58,7 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) - private val multiDataSource = System.getProperty("devops.multi.from").split(",") + private val multiDataSource = System.getProperty("devops.multi.from").split(",").filterNot { it == "process" } private val regex = Regex("""ENC\((.*?)\)""") } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt index 4852ec380fb..895379ecd7a 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt @@ -21,8 +21,8 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { importBeanNameGenerator: BeanNameGenerator ) { multiDataSource.forEach { dataSource -> - //if (dataSource == "process") "shardingDataSource" else - val finalDataSource = "${dataSource}DataSource" + val finalDataSource = if (dataSource == "process") "shardingDataSource" else + "${dataSource}DataSource" val connectionProvider = BeanDefinitionBuilder.genericBeanDefinition( DataSourceConnectionProvider::class.java ).addConstructorArgReference(finalDataSource) diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt index 27258c8037d..b00eca0c63c 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -41,6 +41,8 @@ import org.springframework.context.annotation.Primary import org.springframework.context.annotation.Scope import java.lang.reflect.AnnotatedElement import java.lang.reflect.Constructor +import java.lang.reflect.Method +import java.lang.reflect.Parameter /** * @@ -57,8 +59,14 @@ class MutijarDslContextConfiguration { injectionPoint: InjectionPoint ): DSLContext { val annotatedElement: AnnotatedElement = injectionPoint.annotatedElement - if (Constructor::class.java.isAssignableFrom(annotatedElement::class.java)) { - val declaringClass: Class<*> = (annotatedElement as Constructor<*>).declaringClass + if (Constructor::class.java.isAssignableFrom(annotatedElement::class.java) || + Method::class.java.isAssignableFrom(annotatedElement::class.java) + ) { + val declaringClass: Class<*> = when (annotatedElement) { + is Constructor<*> -> annotatedElement.declaringClass + is Method -> annotatedElement.declaringClass + else -> throw IllegalArgumentException("Invalid annotatedElement type") + } val packageName = declaringClass.getPackage().name logger.info("packageName:$packageName") // lambda服务有多个数据源,需要进行处理 diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt index ad488b32c76..937ac28e279 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt @@ -44,7 +44,7 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.Lazy -//@RestResource +@RestResource class ServiceScmWebhookResourceImpl @Autowired constructor( private val pipelineBuildWebhookService: PipelineBuildWebhookService, private val rabbitTemplate: RabbitTemplate, diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt index d385f9afc37..32dc02fe414 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/permission/config/PipelinePermConfiguration.kt @@ -54,9 +54,7 @@ import org.springframework.core.Ordered @Configuration @ConditionalOnWebApplication @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) -class PipelinePermConfiguration constructor( - val dslContext: DSLContext -){ +class PipelinePermConfiguration { @Bean @ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "bk_login") @@ -75,7 +73,7 @@ class PipelinePermConfiguration constructor( @Bean @ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "sample") fun mockPipelinePermissionService( - + dslContext: DSLContext, pipelineInfoDao: PipelineInfoDao, authProjectApi: AuthProjectApi, authResourceApi: AuthResourceApi, @@ -93,7 +91,7 @@ class PipelinePermConfiguration constructor( @Bean @ConditionalOnProperty(prefix = "auth", name = ["idProvider"], havingValue = "bk_login_v3") fun v3pipelinePermissionService( - + dslContext: DSLContext, client: Client, redisOperation: RedisOperation, pipelineInfoDao: PipelineInfoDao, @@ -117,7 +115,7 @@ class PipelinePermConfiguration constructor( fun githubStreamPipelinePermissionService( client: Client, pipelineInfoDao: PipelineInfoDao, - + dslContext: DSLContext, checkTokenService: ClientTokenService ): PipelinePermissionService = StreamPipelinePermissionServiceImpl( client = client, @@ -131,7 +129,7 @@ class PipelinePermConfiguration constructor( fun gitlabStreamPipelinePermissionService( client: Client, pipelineInfoDao: PipelineInfoDao, - + dslContext: DSLContext, checkTokenService: ClientTokenService ): PipelinePermissionService = StreamPipelinePermissionServiceImpl( client = client, @@ -146,7 +144,7 @@ class PipelinePermConfiguration constructor( authPermissionApi: AuthPermissionApi, authProjectApi: AuthProjectApi, pipelineAuthServiceCode: PipelineAuthServiceCode, - + dslContext: DSLContext, pipelineInfoDao: PipelineInfoDao, pipelineViewGroupService: PipelineViewGroupService, authResourceApi: AuthResourceApi diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt index 2d5f7b0332a..3ed4f069ed7 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/service/webhook/PipelineBuildWebhookService.kt @@ -95,6 +95,7 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { gitWebhookUnlockDispatcher = applicationContext.getBean(GitWebhookUnlockDispatcher::class.java) pipelineWebHookQueueService = applicationContext.getBean(PipelineWebHookQueueService::class.java) buildLogPrinter = applicationContext.getBean(BuildLogPrinter::class.java) + pipelinebuildWebhookService = applicationContext.getBean(PipelineBuildWebhookService::class.java) pipelineBuildCommitService = applicationContext.getBean(PipelineBuildCommitService::class.java) webhookBuildParameterService = applicationContext.getBean(WebhookBuildParameterService::class.java) } @@ -109,6 +110,7 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { lateinit var gitWebhookUnlockDispatcher: GitWebhookUnlockDispatcher lateinit var pipelineWebHookQueueService: PipelineWebHookQueueService lateinit var buildLogPrinter: BuildLogPrinter + lateinit var pipelinebuildWebhookService: PipelineBuildWebhookService // 给AOP调用 lateinit var pipelineBuildCommitService: PipelineBuildCommitService lateinit var webhookBuildParameterService: WebhookBuildParameterService private val logger = LoggerFactory.getLogger(PipelineBuildWebhookService::class.java) @@ -263,7 +265,7 @@ abstract class PipelineBuildWebhookService : ApplicationContextAware { return@outside } - if (webhookTriggerPipelineBuild( + if (pipelinebuildWebhookService.webhookTriggerPipelineBuild( projectId = projectId, pipelineId = pipelineId, codeRepositoryType = codeRepositoryType, diff --git a/src/backend/ci/core/project/biz-project/build.gradle.kts b/src/backend/ci/core/project/biz-project/build.gradle.kts index 847f9abeedd..bcc901c6fb0 100644 --- a/src/backend/ci/core/project/biz-project/build.gradle.kts +++ b/src/backend/ci/core/project/biz-project/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * Tencent is p:leased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * * Copyright (C)) 2019 THL A29 Limited, a Tencent company. All rights reserved. * diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt index a6ead3480e7..438537291da 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt @@ -28,6 +28,7 @@ package com.tencent.devops.project.config import com.tencent.devops.common.redis.RedisOperation +import com.tencent.devops.leaf.plugin.LeafSpringBootProperties import com.tencent.devops.project.dao.ProjectDao import com.tencent.devops.project.dao.ProjectLabelRelDao import com.tencent.devops.project.dispatch.ProjectDispatcher @@ -38,6 +39,8 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Primary + @Configuration class OpConfig { @@ -57,4 +60,10 @@ class OpConfig { projectDispatcher = projectDispatcher, redisOperation = redisOperation ) + + @Bean + @Primary + fun leafSpringBootProperties(): LeafSpringBootProperties { + return LeafSpringBootProperties() + } } From 1ba53c1a5b5d53f7b7f0d0b778f13d6c8a745865 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Thu, 17 Aug 2023 19:21:13 +0800 Subject: [PATCH 18/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mutijar/boot-mutijar/build.gradle.kts | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts index 64d377d0be4..6bcd9fdd83d 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts +++ b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts @@ -24,8 +24,8 @@ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +import org.jetbrains.kotlin.konan.properties.Properties import org.springframework.boot.gradle.tasks.bundling.BootJar -import org.springframework.boot.gradle.tasks.run.BootRun dependencies { api(project(":core:common:common-web")) @@ -42,3 +42,32 @@ tasks.named("bootJar") { val finalModuleName = System.getProperty("devops.multi.to") archiveBaseName.set("boot-$finalModuleName") } +tasks.register("replacePlaceholders") { + doLast { + val rootDirPath = rootDir.absolutePath.replace("${File.separator}src${File.separator}backend${File.separator}ci", "") + val bkEnvPath = joinPath(rootDirPath, "scripts", "bkenv.properties") + val authPath = joinPath(rootDirPath, "support-files", "templates", "#etc#ci#application-auth.yml") + + val properties = Properties() + val propertiesFile = file(bkEnvPath) + properties.load(propertiesFile.inputStream()) + + // 渲染 bkenv.properties 文件 + var content1 = propertiesFile.readText() + properties.forEach { key, value -> + content1 = content1.replace("$${key}", value.toString()) + } + properties.load(content1.byteInputStream()) + // 使用渲染后的值渲染 application-auth.yml 文件 + val authFile = file(authPath) + var content2 = authFile.readText() + properties.forEach { key, value -> + content2 = content2.replace("__${key}__", value.toString()) + } + authFile.writeText(content2) + } +} +/** + * 返回路径 + */ +fun joinPath(vararg folders: String) = folders.joinToString(File.separator) From fedfddb9cbe3831f4217c187bef51f8204d295f2 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Sun, 20 Aug 2023 14:05:53 +0800 Subject: [PATCH 19/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-run.gradle.kts | 7 +- .../plugins/task-render-template.gradle.kts | 94 +++++++++++++++++++ .../dispatch.sdk/config/SDKConfiguration.kt | 7 ++ .../main/resources/META-INF/spring.factories | 2 + .../service/DispatchBaseDebugService.kt | 8 +- .../utils/{RedisUtils.kt => k8sRedisUtils.kt} | 2 +- .../service/ThirdPartyAgentService.kt | 8 +- ...DispatchService.kt => DispatchService1.kt} | 4 +- .../agent/ThirdPartyAgentDispatcher.kt | 4 +- .../mutijar/boot-mutijar/build.gradle.kts | 31 +----- .../mutijar/MutijarDslContextConfiguration.kt | 3 - 11 files changed, 123 insertions(+), 47 deletions(-) create mode 100644 src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts create mode 100644 src/backend/ci/core/common/common-dispatch-sdk/src/main/resources/META-INF/spring.factories rename src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/{RedisUtils.kt => k8sRedisUtils.kt} (98%) rename src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/{DispatchService.kt => DispatchService1.kt} (98%) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index 3df86756f0e..0cadfd098b5 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -38,10 +38,15 @@ tasks.register("multiBootRun") { systemProperty("sun.jnu.encoding", "UTF-8") systemProperty("file.encoding", "UTF-8") systemProperty("spring.cloud.consul.host", "localhost") + systemProperty("service.log.dir", joinPath(projectDir.absolutePath, "log")) } + dependsOn("replacePlaceholders") dependsOn("multiBootJar") val bootJarTask = tasks.getByName("bootJar") - println("multi boot run:${bootJarTask.mainClass}|${bootJarTask.classpath}") mainClass.set(bootJarTask.mainClass) classpath = bootJarTask.classpath } +/** + * 返回路径 + */ +fun joinPath(vararg folders: String) = folders.joinToString(File.separator) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts new file mode 100644 index 00000000000..64571b98034 --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts @@ -0,0 +1,94 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +import java.util.Properties +import java.io.File + +tasks.register("replacePlaceholders") { + doLast { + val destDir = joinPath(projectDir.absolutePath, "src", "main", "resources") + deleteFiles(destDir) + + val rootDirPath = rootDir.absolutePath.replace( + "${File.separator}src${File.separator}backend${File.separator}ci", + "" + ) + val bkEnvPath = joinPath(rootDirPath, "scripts", "bkenv.properties") + val templatesDir = joinPath(rootDirPath, "support-files", "templates") + val bkEnvProperties = loadProperties(bkEnvPath) + val bkEnvFileContent = renderTemplate(bkEnvPath, bkEnvProperties) + bkEnvProperties.load(bkEnvFileContent.byteInputStream()) + generateFiles(templatesDir, destDir, bkEnvProperties) + } +} + +fun deleteFiles(dir: String) { + val destDirFile = File(dir) + destDirFile.listFiles()?.forEach { file -> + if (file.isFile && file.name != "application.yml") { + file.delete() + } + } +} + +fun loadProperties(path: String): Properties { + val properties = Properties() + properties.load(file(path).inputStream()) + return properties +} + +fun renderTemplate(templatePath: String, properties: Properties): String { + var templateContent = file(templatePath).readText() + properties.forEach { key, value -> + templateContent = templateContent.replace("$${key}", value.toString()) + } + return templateContent +} + +fun generateFiles(templatesDir: String, destDir: String, properties: Properties) { + val templatesDirFile = file(templatesDir) + templatesDirFile.walkTopDown().forEach { templateFile -> + if (templateFile.isFile && templateFile.name.endsWith(".yml")) { + var content = templateFile.readText() + properties.forEach { key, value -> + content = content.replace("__${key}__", value.toString()) + } + val destFileName = if (templateFile.name == "#etc#ci#common.yml") { + "application-common.yml" + } else { + templateFile.name.replace("#etc#ci#", "") + } + val destFile = File(joinPath(destDir, destFileName)) + destFile.parentFile.mkdirs() + destFile.writeText(content) + } + } +} + +/** + * 返回路径 + */ +fun joinPath(vararg folders: String) = folders.joinToString(File.separator) diff --git a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt index 85c338a39b7..48d27aa69d2 100644 --- a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt +++ b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt @@ -42,6 +42,7 @@ import com.tencent.devops.common.dispatch.sdk.service.DockerRoutingSdkService import com.tencent.devops.common.log.utils.BuildLogPrinter import com.tencent.devops.common.dispatch.sdk.service.JobQuotaService import com.tencent.devops.common.dispatch.sdk.utils.ChannelUtils +import com.tencent.devops.common.service.BkTag import com.tencent.devops.common.service.config.CommonConfig @Configuration @@ -87,4 +88,10 @@ class SDKConfiguration { fun pipelineEventDispatcher(@Autowired rabbitTemplate: RabbitTemplate): PipelineEventDispatcher { return MQEventDispatcher(rabbitTemplate) } + + @Bean + fun channelUtils( + @Autowired bkTag: BkTag + ) = ChannelUtils(bkTag) + } diff --git a/src/backend/ci/core/common/common-dispatch-sdk/src/main/resources/META-INF/spring.factories b/src/backend/ci/core/common/common-dispatch-sdk/src/main/resources/META-INF/spring.factories new file mode 100644 index 00000000000..c4c5bf13399 --- /dev/null +++ b/src/backend/ci/core/common/common-dispatch-sdk/src/main/resources/META-INF/spring.factories @@ -0,0 +1,2 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ +com.tencent.devops.common.dispatch.sdk.config.SDKConfiguration diff --git a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt index 0a3f9c5c722..4a5067d5be2 100644 --- a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt +++ b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt @@ -53,7 +53,7 @@ import com.tencent.devops.dispatch.kubernetes.pojo.builds.DispatchBuildTaskStatu import com.tencent.devops.dispatch.kubernetes.pojo.debug.DispatchBuilderDebugStatus import com.tencent.devops.dispatch.kubernetes.service.factory.ContainerServiceFactory import com.tencent.devops.dispatch.kubernetes.service.factory.JobServiceFactory -import com.tencent.devops.dispatch.kubernetes.utils.RedisUtils +import com.tencent.devops.dispatch.kubernetes.utils.k8sRedisUtils import org.jooq.DSLContext import org.jooq.impl.DSL import org.slf4j.LoggerFactory @@ -69,7 +69,7 @@ class DispatchBaseDebugService @Autowired constructor( private val dispatchKubernetesBuildHisDao: DispatchKubernetesBuildHisDao, private val bkAuthPermissionApi: AuthPermissionApi, private val pipelineAuthServiceCode: PipelineAuthServiceCode, - private val redisUtils: RedisUtils, + private val k8sRedisUtils: k8sRedisUtils, private val dockerRoutingSdkService: DockerRoutingSdkService ) { @@ -186,7 +186,7 @@ class DispatchBaseDebugService @Autowired constructor( } // 设置containerName缓存 - redisUtils.setDebugBuilderName(userId, pipelineId, vmSeqId, builderName) + k8sRedisUtils.setDebugBuilderName(userId, pipelineId, vmSeqId, builderName) return DebugResponse( websocketUrl = containerServiceFactory.load(projectId).getDebugWebsocketUrl( @@ -210,7 +210,7 @@ class DispatchBaseDebugService @Autowired constructor( val dockerRoutingType = dockerRoutingSdkService.getDockerRoutingType(projectId) val debugBuilderName = builderName.ifBlank { - redisUtils.getDebugBuilderName(userId, pipelineId, vmSeqId) ?: "" + k8sRedisUtils.getDebugBuilderName(userId, pipelineId, vmSeqId) ?: "" } logger.info( diff --git a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/RedisUtils.kt b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/k8sRedisUtils.kt similarity index 98% rename from src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/RedisUtils.kt rename to src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/k8sRedisUtils.kt index 5e2dfa4aac0..00104989b2a 100644 --- a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/RedisUtils.kt +++ b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/k8sRedisUtils.kt @@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @Component -class RedisUtils @Autowired constructor( +class k8sRedisUtils @Autowired constructor( private val redisOperation: RedisOperation ) { fun setDebugBuilderName( diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt index a68f798474d..8e0809f69d5 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt @@ -49,7 +49,7 @@ import com.tencent.devops.dispatch.pojo.thirdPartyAgent.BuildJobType import com.tencent.devops.dispatch.pojo.thirdPartyAgent.ThirdPartyBuildDockerInfo import com.tencent.devops.dispatch.pojo.thirdPartyAgent.ThirdPartyBuildInfo import com.tencent.devops.dispatch.pojo.thirdPartyAgent.ThirdPartyBuildWithStatus -import com.tencent.devops.dispatch.service.dispatcher.agent.DispatchService +import com.tencent.devops.dispatch.service.dispatcher.agent.DispatchService1 import com.tencent.devops.dispatch.utils.ThirdPartyAgentLock import com.tencent.devops.dispatch.utils.ThirdPartyAgentUtils import com.tencent.devops.dispatch.utils.redis.ThirdPartyAgentBuildRedisUtils @@ -75,7 +75,7 @@ class ThirdPartyAgentService @Autowired constructor( private val client: Client, private val redisOperation: RedisOperation, private val thirdPartyAgentBuildDao: ThirdPartyAgentBuildDao, - private val dispatchService: DispatchService + private val dispatchService1: DispatchService1 ) { fun queueBuild( @@ -367,7 +367,7 @@ class ThirdPartyAgentService @Autowired constructor( finishBuild(it, success) if (it.dockerInfo != null) { // 第三方构建机可能是docker构建机时需要在这里删除docker类型的redisKey - dispatchService.shutdown(event) + dispatchService1.shutdown(event) } } } else { @@ -375,7 +375,7 @@ class ThirdPartyAgentService @Autowired constructor( finishBuild(record, success) if (record.dockerInfo != null) { // 第三方构建机可能是docker构建机时需要在这里删除docker类型的redisKey - dispatchService.shutdown(event) + dispatchService1.shutdown(event) } } } diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService1.kt similarity index 98% rename from src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService.kt rename to src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService1.kt index 7a0dcc2d644..44ed318c68c 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService1.kt @@ -18,7 +18,7 @@ import org.springframework.stereotype.Service **/ @Suppress("ALL") @Service -class DispatchService @Autowired constructor( +class DispatchService1 @Autowired constructor( private val redisOperation: RedisOperation, private val objectMapper: ObjectMapper ) { @@ -96,6 +96,6 @@ class DispatchService @Autowired constructor( } companion object { - private val logger = LoggerFactory.getLogger(DispatchService::class.java) + private val logger = LoggerFactory.getLogger(DispatchService1::class.java) } } diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt index e5b46b5e39c..f1f83485bf8 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt @@ -79,7 +79,7 @@ class ThirdPartyAgentDispatcher @Autowired constructor( private val thirdPartyAgentBuildRedisUtils: ThirdPartyAgentBuildRedisUtils, private val pipelineEventDispatcher: PipelineEventDispatcher, private val thirdPartyAgentBuildService: ThirdPartyAgentService, - private val dispatchService: DispatchService + private val dispatchService1: DispatchService1 ) : Dispatcher { override fun canDispatch(event: PipelineAgentStartupEvent) = event.dispatchType is ThirdPartyAgentIDDispatchType || @@ -251,7 +251,7 @@ class ThirdPartyAgentDispatcher @Autowired constructor( val message = if (dockerInfo == null) { null } else { - dispatchService.setRedisAuth(event) + dispatchService1.setRedisAuth(event) } // #5806 入库失败就不再写Redis diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts index 6bcd9fdd83d..41996ad17b5 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts +++ b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts @@ -24,7 +24,6 @@ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import org.jetbrains.kotlin.konan.properties.Properties import org.springframework.boot.gradle.tasks.bundling.BootJar dependencies { @@ -34,6 +33,7 @@ dependencies { implementation(kotlin("stdlib")) } plugins { + `task-render-template` `task-multi-boot-jar` `task-multi-boot-run` } @@ -42,32 +42,3 @@ tasks.named("bootJar") { val finalModuleName = System.getProperty("devops.multi.to") archiveBaseName.set("boot-$finalModuleName") } -tasks.register("replacePlaceholders") { - doLast { - val rootDirPath = rootDir.absolutePath.replace("${File.separator}src${File.separator}backend${File.separator}ci", "") - val bkEnvPath = joinPath(rootDirPath, "scripts", "bkenv.properties") - val authPath = joinPath(rootDirPath, "support-files", "templates", "#etc#ci#application-auth.yml") - - val properties = Properties() - val propertiesFile = file(bkEnvPath) - properties.load(propertiesFile.inputStream()) - - // 渲染 bkenv.properties 文件 - var content1 = propertiesFile.readText() - properties.forEach { key, value -> - content1 = content1.replace("$${key}", value.toString()) - } - properties.load(content1.byteInputStream()) - // 使用渲染后的值渲染 application-auth.yml 文件 - val authFile = file(authPath) - var content2 = authFile.readText() - properties.forEach { key, value -> - content2 = content2.replace("__${key}__", value.toString()) - } - authFile.writeText(content2) - } -} -/** - * 返回路径 - */ -fun joinPath(vararg folders: String) = folders.joinToString(File.separator) diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt index b00eca0c63c..2481e410f04 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -68,7 +68,6 @@ class MutijarDslContextConfiguration { else -> throw IllegalArgumentException("Invalid annotatedElement type") } val packageName = declaringClass.getPackage().name - logger.info("packageName:$packageName") // lambda服务有多个数据源,需要进行处理 val configurationName = if (packageName.contains(".lambda")) { val matchResult = lambdaServiceRegex.find(packageName) @@ -78,7 +77,6 @@ class MutijarDslContextConfiguration { ?: throw NoSuchBeanDefinitionException("no jooq configuration") serviceName.removePrefix(".").plus("JooqConfiguration") } - logger.info("AccessoriesJooqConfiguration:$configurationName") val configuration: org.jooq.Configuration = configurationMap[configurationName] ?: throw NoSuchBeanDefinitionException("no $configurationName") return DSL.using(configuration) @@ -87,7 +85,6 @@ class MutijarDslContextConfiguration { } companion object { - private val logger = LoggerFactory.getLogger(MutijarDslContextConfiguration::class.java) private val multiModelService = System.getProperty("devops.multi.from").split(",") private val lambdaServiceRegex = "\\.(tsource|ttarget|process|project|store)".toRegex() } From 288b96d5cb286f7fbe170183d81c516c18574922 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 21 Aug 2023 14:39:15 +0800 Subject: [PATCH 20/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/buildless/ContainerPoolExecutor.kt | 14 +++---- ...leConfig.kt => BuildlessScheduleConfig.kt} | 2 +- .../devops/buildless/rejected/JumpPolicy.kt | 6 +-- ...Runner.kt => BuildlessSystemInfoRunner.kt} | 2 +- .../schedule/ContainerPoolSchedule.kt | 10 ++--- .../service/BuildLessContainerService.kt | 18 ++++---- .../buildless/service/BuildLessTaskService.kt | 14 +++---- .../{RedisUtils.kt => BuildlessRedisUtils.kt} | 4 +- ....kt => DispatchBuildDockerHostResource.kt} | 2 +- ...t => ServiceDispatchDockerHostResource.kt} | 2 +- .../client/BuildLessEndPrepareHandler.kt | 6 +-- .../client/BuildLessStartDispatchHandler.kt | 6 +-- .../docker/client/DockerHostClient.kt | 6 +-- ...fig.kt => DispatchDockerScheduleConfig.kt} | 2 +- ...=> DispatchBuildDockerHostResourceImpl.kt} | 18 ++++---- .../controller/OpDockerBuildResourceImpl.kt | 6 +-- ... ServiceDispatchDockerHostResourceImpl.kt} | 14 +++---- .../controller/UserDockerHostResourceImpl.kt | 8 ++-- .../docker/listener/DockerVMListener.kt | 6 +-- ...e.kt => DispatchDockerHostBuildService.kt} | 4 +- .../service/DockerHostZoneTaskService.kt | 8 ++-- .../debug/impl/DockerHostDebugServiceImpl.kt | 8 ++-- ...isUtils.kt => DispatchDockerRedisUtils.kt} | 2 +- .../service/DispatchBaseDebugService.kt | 8 ++-- ...ils.kt => DispatchKubernetesRedisUtils.kt} | 2 +- ...unner.kt => DockerhostSystemInfoRunner.kt} | 2 +- ...cheduleConfig.kt => MiscScheduleConfig.kt} | 2 +- ...bClient.kt => MonitoringInfluxdbClient.kt} | 4 +- .../consumer/AtomMonitorReportListener.kt | 8 ++-- .../monitor/AbstractMonitorProcessor.kt | 6 +-- .../monitoring/service/AtomMonitorService.kt | 0 .../mutijar/DataSourceDefinitionRegistrar.kt | 9 +++- .../devops/mutijar/JooqDefinitionRegistrar.kt | 5 ++- .../mutijar/MutijarDslContextConfiguration.kt | 41 +++++++++---------- .../apigw/v4/ApigwDispatchResourceV4Impl.kt | 4 +- .../rule/processor/BkVarProcessorService.kt | 6 +-- .../ServiceRepositoryGitCheckResourceImpl.kt | 10 ++--- ...CheckService.kt => RepoGitCheckService.kt} | 2 +- ...rce.kt => StreamExternalGithubResource.kt} | 2 +- ...source.kt => StreamExternalScmResource.kt} | 2 +- ...t => StreamExternalStreamLoginResource.kt} | 2 +- ...rce.kt => StreamExternalStreamResource.kt} | 2 +- ...kt => StreamExternalGithubResourceImpl.kt} | 8 ++-- ...pl.kt => StreamExternalScmResourceImpl.kt} | 8 ++-- ... StreamExternalStreamLoginResourceImpl.kt} | 6 +-- ...kt => StreamExternalStreamResourceImpl.kt} | 6 +-- .../#etc#ci#application-buildless.yml | 4 +- 47 files changed, 160 insertions(+), 157 deletions(-) rename src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/{ScheduleConfig.kt => BuildlessScheduleConfig.kt} (93%) rename src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/{SystemInfoRunner.kt => BuildlessSystemInfoRunner.kt} (98%) rename src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/{RedisUtils.kt => BuildlessRedisUtils.kt} (97%) rename src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/{BuildDockerHostResource.kt => DispatchBuildDockerHostResource.kt} (99%) rename src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/{ServiceDockerHostResource.kt => ServiceDispatchDockerHostResource.kt} (98%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/{ScheduleConfig.kt => DispatchDockerScheduleConfig.kt} (92%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/{BuildDockerHostResourceImpl.kt => DispatchBuildDockerHostResourceImpl.kt} (82%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/{ServiceDockerHostResourceImpl.kt => ServiceDispatchDockerHostResourceImpl.kt} (87%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/{DockerHostBuildService.kt => DispatchDockerHostBuildService.kt} (98%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/{RedisUtils.kt => DispatchDockerRedisUtils.kt} (98%) rename src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/{k8sRedisUtils.kt => DispatchKubernetesRedisUtils.kt} (97%) rename src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/{SystemInfoRunner.kt => DockerhostSystemInfoRunner.kt} (98%) rename src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/{ScheduleConfig.kt => MiscScheduleConfig.kt} (97%) rename src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/{InfluxdbClient.kt => MonitoringInfluxdbClient.kt} (98%) create mode 100644 src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/service/AtomMonitorService.kt rename src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/{GitCheckService.kt => RepoGitCheckService.kt} (96%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{ExternalGithubResource.kt => StreamExternalGithubResource.kt} (98%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{ExternalScmResource.kt => StreamExternalScmResource.kt} (98%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{ExternalStreamLoginResource.kt => StreamExternalStreamLoginResource.kt} (97%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{ExternalStreamResource.kt => StreamExternalStreamResource.kt} (98%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{ExternalGithubResourceImpl.kt => StreamExternalGithubResourceImpl.kt} (93%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{ExternalScmResourceImpl.kt => StreamExternalScmResourceImpl.kt} (92%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{ExternalStreamLoginResourceImpl.kt => StreamExternalStreamLoginResourceImpl.kt} (91%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{ExternalStreamResourceImpl.kt => StreamExternalStreamResourceImpl.kt} (93%) diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt index 61cabcca441..dee6392e560 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt @@ -10,7 +10,7 @@ import com.tencent.devops.buildless.pojo.RejectedExecutionType import com.tencent.devops.buildless.rejected.RejectedExecutionFactory import com.tencent.devops.buildless.service.BuildLessContainerService import com.tencent.devops.buildless.utils.CommonUtils -import com.tencent.devops.buildless.utils.RedisUtils +import com.tencent.devops.buildless.utils.BuildlessRedisUtils import com.tencent.devops.buildless.utils.ThreadPoolName import com.tencent.devops.buildless.utils.ThreadPoolUtils import org.slf4j.LoggerFactory @@ -22,7 +22,7 @@ import java.util.concurrent.locks.ReentrantLock @Component class ContainerPoolExecutor @Autowired constructor( - private val redisUtils: RedisUtils, + private val buildlessRedisUtils: BuildlessRedisUtils, private val buildLessConfig: BuildLessConfig, private val rejectedExecutionFactory: RejectedExecutionFactory, private val buildLessContainerService: BuildLessContainerService @@ -35,7 +35,7 @@ class ContainerPoolExecutor @Autowired constructor( } logger.info("$buildId|$vmSeqId|$executionCount left push buildLessReadyTask") - redisUtils.leftPushBuildLessReadyTask( + buildlessRedisUtils.leftPushBuildLessReadyTask( BuildLessTask( projectId = projectId, pipelineId = pipelineId, @@ -85,7 +85,7 @@ class ContainerPoolExecutor @Autowired constructor( fun getContainerStatus(containerId: String): BuildLessPoolInfo? { synchronized(containerId.intern()) { - return redisUtils.getBuildLessPoolContainer(containerId) + return buildlessRedisUtils.getBuildLessPoolContainer(containerId) } } @@ -124,7 +124,7 @@ class ContainerPoolExecutor @Autowired constructor( } retry@ while (true) { - val idlePoolSize = redisUtils.getIdlePoolSize() + val idlePoolSize = buildlessRedisUtils.getIdlePoolSize() // 无空闲容器时执行拒绝策略 logger.info("${buildLessStartInfo.buildId}|${buildLessStartInfo.vmSeqId} idlePoolSize: $idlePoolSize") @@ -135,10 +135,10 @@ class ContainerPoolExecutor @Autowired constructor( } // 再次check idlePoolSize,有变更则retry - if (idlePoolSize != redisUtils.getIdlePoolSize()) continue@retry + if (idlePoolSize != buildlessRedisUtils.getIdlePoolSize()) continue@retry // 已经进入需求池,资源池减1 - redisUtils.increIdlePool(-1) + buildlessRedisUtils.increIdlePool(-1) return false } } finally { diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/ScheduleConfig.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/BuildlessScheduleConfig.kt similarity index 93% rename from src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/ScheduleConfig.kt rename to src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/BuildlessScheduleConfig.kt index e5693b73a46..479c3c4900e 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/ScheduleConfig.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/BuildlessScheduleConfig.kt @@ -8,7 +8,7 @@ import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit @Configuration -class ScheduleConfig : SchedulingConfigurer { +class BuildlessScheduleConfig : SchedulingConfigurer { override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar) { val scheduler = ScheduledThreadPoolExecutor(5) scheduler.maximumPoolSize = 5 diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt index cab0aeda40e..ba8dc803c43 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt @@ -29,19 +29,19 @@ package com.tencent.devops.buildless.rejected import com.tencent.devops.buildless.pojo.BuildLessStartInfo import com.tencent.devops.buildless.pojo.BuildLessTask -import com.tencent.devops.buildless.utils.RedisUtils +import com.tencent.devops.buildless.utils.BuildlessRedisUtils import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service class JumpPolicy @Autowired constructor( - private val redisUtils: RedisUtils + private val buildlessRedisUtils: BuildlessRedisUtils ) : RejectedExecutionHandler { override fun rejectedExecution(buildLessStartInfo: BuildLessStartInfo): Boolean { with(buildLessStartInfo) { logger.info("$buildId|$vmSeqId|$executionCount jump allocate container.") - redisUtils.rightPushBuildLessReadyTask( + buildlessRedisUtils.rightPushBuildLessReadyTask( BuildLessTask( projectId = projectId, pipelineId = pipelineId, diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/SystemInfoRunner.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/BuildlessSystemInfoRunner.kt similarity index 98% rename from src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/SystemInfoRunner.kt rename to src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/BuildlessSystemInfoRunner.kt index ada662c20ac..a2602d236f2 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/SystemInfoRunner.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/BuildlessSystemInfoRunner.kt @@ -32,7 +32,7 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component -class SystemInfoRunner { +class BuildlessSystemInfoRunner { @Scheduled(cron = "0/5 * * * * ?") fun startCollect() { diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt index d95223c1b36..640e4002ae2 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt @@ -28,14 +28,14 @@ package com.tencent.devops.buildless.schedule import com.tencent.devops.buildless.ContainerPoolExecutor -import com.tencent.devops.buildless.utils.RedisUtils +import com.tencent.devops.buildless.utils.BuildlessRedisUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component class ContainerPoolSchedule @Autowired constructor( - private val redisUtils: RedisUtils, + private val buildlessRedisUtils: BuildlessRedisUtils, private val containerPoolExecutor: ContainerPoolExecutor ) { /** @@ -44,9 +44,9 @@ class ContainerPoolSchedule @Autowired constructor( @Scheduled(cron = "0 0/1 * * * ?") fun execute() { // 校准空闲池大小 - if (redisUtils.getBuildLessReadyTaskSize() == 0L) { - val idleContainerPoolSize = redisUtils.getBuildLessPoolContainerIdle() - redisUtils.setIdlePool(idleContainerPoolSize) + if (buildlessRedisUtils.getBuildLessReadyTaskSize() == 0L) { + val idleContainerPoolSize = buildlessRedisUtils.getBuildLessPoolContainerIdle() + buildlessRedisUtils.setIdlePool(idleContainerPoolSize) } containerPoolExecutor.addContainer() diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt index 1fc8a5dfb02..4a1f59a889a 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt @@ -56,7 +56,7 @@ import com.tencent.devops.buildless.utils.ENV_JOB_BUILD_TYPE import com.tencent.devops.buildless.utils.ENV_KEY_BK_TAG import com.tencent.devops.buildless.utils.ENV_KEY_GATEWAY import com.tencent.devops.buildless.utils.RandomUtil -import com.tencent.devops.buildless.utils.RedisUtils +import com.tencent.devops.buildless.utils.BuildlessRedisUtils import com.tencent.devops.common.api.util.ShaUtils import com.tencent.devops.common.service.BkTag import com.tencent.devops.common.service.config.CommonConfig @@ -76,7 +76,7 @@ import kotlin.streams.toList @Service class BuildLessContainerService( private val bkTag: BkTag, - private val redisUtils: RedisUtils, + private val buildlessRedisUtils: BuildlessRedisUtils, private val commonConfig: CommonConfig, private val buildLessConfig: BuildLessConfig ) { @@ -139,8 +139,8 @@ class BuildLessContainerService( httpDockerCli.startContainerCmd(container.id).exec() logger.info("===> created container: $container, containerName: $containerName. ") - redisUtils.setBuildLessPoolContainer(container.id, ContainerStatus.IDLE) - redisUtils.increIdlePool(1) + buildlessRedisUtils.setBuildLessPoolContainer(container.id, ContainerStatus.IDLE) + buildlessRedisUtils.increIdlePool(1) logger.info("===> buildLessPoolKey hset ${container.id} ${ContainerStatus.IDLE.name}.") } catch (e: Exception) { logger.error("===> failed to created container.", e) @@ -181,7 +181,7 @@ class BuildLessContainerService( ignored ) } finally { - redisUtils.deleteBuildLessPoolContainer(containerId) + buildlessRedisUtils.deleteBuildLessPoolContainer(containerId) } } @@ -206,10 +206,10 @@ class BuildLessContainerService( }.toList() // 不在containerIds列表内的同步删除缓存 - val buildLessPoolContainerMap = redisUtils.getBuildLessPoolContainerList() + val buildLessPoolContainerMap = buildlessRedisUtils.getBuildLessPoolContainerList() buildLessPoolContainerMap.forEach { (key, _) -> if (!containerIds.contains(key)) { - redisUtils.deleteBuildLessPoolContainer(key) + buildlessRedisUtils.deleteBuildLessPoolContainer(key) } } @@ -217,7 +217,7 @@ class BuildLessContainerService( containerIds.forEach { if (!buildLessPoolContainerMap.keys.contains(it)) { logger.info("Supplemental cache buildLessPoolKey hset $it ${ContainerStatus.IDLE.name}.") - redisUtils.setBuildLessPoolContainer(it, ContainerStatus.IDLE) + buildlessRedisUtils.setBuildLessPoolContainer(it, ContainerStatus.IDLE) } } } @@ -231,7 +231,7 @@ class BuildLessContainerService( for (container in containerInfo) { val startTime = httpDockerCli.inspectContainerCmd(container.id).exec().state.startedAt // 是否已运行超过12小时 - val buildLessPoolInfo = redisUtils.getBuildLessPoolContainer(container.id) + val buildLessPoolInfo = buildlessRedisUtils.getBuildLessPoolContainer(container.id) if (checkStartTime(startTime) && (buildLessPoolInfo == null || buildLessPoolInfo.status == ContainerStatus.IDLE)) { timeoutContainerList.add(container.id) diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt index 71786bde04a..c06db537b4f 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt @@ -31,7 +31,7 @@ import com.tencent.devops.buildless.ContainerPoolExecutor import com.tencent.devops.buildless.client.DispatchClient import com.tencent.devops.buildless.pojo.BuildLessTask import com.tencent.devops.buildless.utils.ContainerStatus -import com.tencent.devops.buildless.utils.RedisUtils +import com.tencent.devops.buildless.utils.BuildlessRedisUtils import org.slf4j.LoggerFactory import org.springframework.scheduling.annotation.Async import org.springframework.scheduling.annotation.AsyncResult @@ -44,7 +44,7 @@ import java.util.concurrent.Future */ @Service class BuildLessTaskService( - private val redisUtils: RedisUtils, + private val buildlessRedisUtils: BuildlessRedisUtils, private val dispatchClient: DispatchClient, private val containerPoolExecutor: ContainerPoolExecutor ) { @@ -60,7 +60,7 @@ class BuildLessTaskService( return AsyncResult(buildLessPoolInfo.buildLessTask) } - val buildLessTask = redisUtils.popBuildLessReadyTask() + val buildLessTask = buildlessRedisUtils.popBuildLessReadyTask() if (buildLessTask != null) { try { logger.info("****> container: $containerId claim buildLessTask: $buildLessTask") @@ -70,14 +70,14 @@ class BuildLessTaskService( ) logger.info("****> claim task buildLessPoolKey hset $containerId ${ContainerStatus.BUSY.name}.") - redisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) + buildlessRedisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) return AsyncResult(buildLessTask) } catch (e: Exception) { // 异常时任务重新回队列 logger.info("****> container: $containerId claim buildLessTask: $buildLessTask get error, " + "retry.", e) - redisUtils.leftPushBuildLessReadyTask(buildLessTask) + buildlessRedisUtils.leftPushBuildLessReadyTask(buildLessTask) continue } @@ -105,7 +105,7 @@ class BuildLessTaskService( return } - val buildLessTask = redisUtils.popBuildLessReadyTask() + val buildLessTask = buildlessRedisUtils.popBuildLessReadyTask() if (buildLessTask != null) { logger.info("****> container: $containerId claim buildLessTask: $buildLessTask") dispatchClient.updateContainerId( @@ -114,7 +114,7 @@ class BuildLessTaskService( ) logger.info("****> claim task buildLessPoolKey hset $containerId ${ContainerStatus.BUSY.name}.") - redisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) + buildlessRedisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) deferredResult.setResult(buildLessTask) return diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/RedisUtils.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/BuildlessRedisUtils.kt similarity index 97% rename from src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/RedisUtils.kt rename to src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/BuildlessRedisUtils.kt index 6ef5c5b68fa..de9d6e6a550 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/RedisUtils.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/BuildlessRedisUtils.kt @@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @Component -class RedisUtils @Autowired constructor( +class BuildlessRedisUtils @Autowired constructor( private val redisOperation: RedisOperation, private val objectMapper: ObjectMapper ) { @@ -139,6 +139,6 @@ class RedisUtils @Autowired constructor( } companion object { - private val logger = LoggerFactory.getLogger(RedisUtils::class.java) + private val logger = LoggerFactory.getLogger(BuildlessRedisUtils::class.java) } } diff --git a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/BuildDockerHostResource.kt b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/DispatchBuildDockerHostResource.kt similarity index 99% rename from src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/BuildDockerHostResource.kt rename to src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/DispatchBuildDockerHostResource.kt index f09a2c00453..b699b02ad2f 100644 --- a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/BuildDockerHostResource.kt +++ b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/DispatchBuildDockerHostResource.kt @@ -47,7 +47,7 @@ import javax.ws.rs.core.MediaType @Path("/dockerhost") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)@Suppress("ALL") -interface BuildDockerHostResource { +interface DispatchBuildDockerHostResource { @GET @Path("/resource-config/pipelines/{pipelineId}/vmSeqs/{vmSeqId}") @ApiOperation("获取蓝盾项目的docker性能配置") diff --git a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDockerHostResource.kt b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDispatchDockerHostResource.kt similarity index 98% rename from src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDockerHostResource.kt rename to src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDispatchDockerHostResource.kt index 877cce5a674..5839a31fd75 100644 --- a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDockerHostResource.kt +++ b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDispatchDockerHostResource.kt @@ -54,7 +54,7 @@ import javax.ws.rs.core.MediaType @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ServiceInterface("dispatch-docker") // 指明接入到哪个微服务 -interface ServiceDockerHostResource { +interface ServiceDispatchDockerHostResource { @ApiOperation("获取dockerhost列表") @GET diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessEndPrepareHandler.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessEndPrepareHandler.kt index f9036a0b024..d6da86866c1 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessEndPrepareHandler.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessEndPrepareHandler.kt @@ -30,7 +30,7 @@ package com.tencent.devops.dispatch.docker.client import com.tencent.devops.common.api.util.SecurityUtil import com.tencent.devops.dispatch.docker.client.context.BuildLessEndHandlerContext import com.tencent.devops.dispatch.docker.dao.PipelineDockerBuildDao -import com.tencent.devops.dispatch.docker.utils.RedisUtils +import com.tencent.devops.dispatch.docker.utils.DispatchDockerRedisUtils import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus import com.tencent.devops.model.dispatch.tables.records.TDispatchPipelineDockerBuildRecord import com.tencent.devops.process.pojo.mq.PipelineBuildLessShutdownDispatchEvent @@ -42,7 +42,7 @@ import org.springframework.stereotype.Service @Service class BuildLessEndPrepareHandler @Autowired constructor( private val dslContext: DSLContext, - private val redisUtils: RedisUtils, + private val dispatchDockerRedisUtils: DispatchDockerRedisUtils, private val pipelineDockerBuildDao: PipelineDockerBuildDao, private val buildLessEndHandler: BuildLessEndHandler ) : Handler() { @@ -99,7 +99,7 @@ class BuildLessEndPrepareHandler @Autowired constructor( // 无编译环境清除redisAuth val decryptSecretKey = SecurityUtil.decrypt(record.secretKey) logger.info("${record.buildId}|${record.vmSeqId} delete dockerBuildKey ${record.id}|$decryptSecretKey") - redisUtils.deleteDockerBuild(record.id, SecurityUtil.decrypt(record.secretKey)) + dispatchDockerRedisUtils.deleteDockerBuild(record.id, SecurityUtil.decrypt(record.secretKey)) } } } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessStartDispatchHandler.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessStartDispatchHandler.kt index 60831266328..dcc1e9f3eac 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessStartDispatchHandler.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/BuildLessStartDispatchHandler.kt @@ -34,7 +34,7 @@ import com.tencent.devops.dispatch.docker.client.context.BuildLessStartHandlerCo import com.tencent.devops.dispatch.docker.dao.PipelineDockerBuildDao import com.tencent.devops.dispatch.docker.pojo.enums.DockerHostClusterType import com.tencent.devops.dispatch.docker.utils.DockerHostUtils -import com.tencent.devops.dispatch.docker.utils.RedisUtils +import com.tencent.devops.dispatch.docker.utils.DispatchDockerRedisUtils import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus import com.tencent.devops.dispatch.pojo.redis.RedisBuild import org.jooq.DSLContext @@ -44,7 +44,7 @@ import org.springframework.stereotype.Service @Service class BuildLessStartDispatchHandler @Autowired constructor( - private val redisUtils: RedisUtils, + private val dispatchDockerRedisUtils: DispatchDockerRedisUtils, private val dslContext: DSLContext, private val dockerHostUtils: DockerHostUtils, private val buildLessStartHandler: BuildLessStartHandler, @@ -95,7 +95,7 @@ class BuildLessStartDispatchHandler @Autowired constructor( ) val agentId = HashUtil.encodeLongId(id) - redisUtils.setDockerBuild( + dispatchDockerRedisUtils.setDockerBuild( id = id, secretKey = secretKey, redisBuild = RedisBuild( vmName = agentId, diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/DockerHostClient.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/DockerHostClient.kt index 6abb4f32d13..fad809fc23d 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/DockerHostClient.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/client/DockerHostClient.kt @@ -51,7 +51,7 @@ import com.tencent.devops.dispatch.docker.pojo.resource.DockerResourceOptionsVO import com.tencent.devops.dispatch.docker.service.DockerHostProxyService import com.tencent.devops.dispatch.docker.service.DockerHostQpcService import com.tencent.devops.dispatch.docker.utils.DockerHostUtils -import com.tencent.devops.dispatch.docker.utils.RedisUtils +import com.tencent.devops.dispatch.docker.utils.DispatchDockerRedisUtils import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus import com.tencent.devops.process.engine.common.VMUtils import com.tencent.devops.store.pojo.image.enums.ImageRDTypeEnum @@ -76,7 +76,7 @@ class DockerHostClient @Autowired constructor( private val defaultImageConfig: DefaultImageConfig, private val dockerHostProxyService: DockerHostProxyService, private val dockerHostQpcService: DockerHostQpcService, - private val redisUtils: RedisUtils, + private val dispatchDockerRedisUtils: DispatchDockerRedisUtils, private val buildLogPrinter: BuildLogPrinter ) { @@ -386,7 +386,7 @@ class DockerHostClient @Autowired constructor( } fun getSpecialProjectList(): String? { - return redisUtils.getSpecialProjectListKey() + return dispatchDockerRedisUtils.getSpecialProjectListKey() } private fun getDockerResource(dockerDispatchType: DockerDispatchType): DockerResourceOptionsVO { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerScheduleConfig.kt similarity index 92% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerScheduleConfig.kt index cd7325c2207..71929165567 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerScheduleConfig.kt @@ -8,7 +8,7 @@ import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit @Configuration -class ScheduleConfig : SchedulingConfigurer { +class DispatchDockerScheduleConfig : SchedulingConfigurer { override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar) { val scheduler = ScheduledThreadPoolExecutor(5) scheduler.maximumPoolSize = 5 diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/BuildDockerHostResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/DispatchBuildDockerHostResourceImpl.kt similarity index 82% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/BuildDockerHostResourceImpl.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/DispatchBuildDockerHostResourceImpl.kt index 17dedbbbdcc..f44ad442cad 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/BuildDockerHostResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/DispatchBuildDockerHostResourceImpl.kt @@ -29,21 +29,21 @@ package com.tencent.devops.dispatch.docker.controller import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource -import com.tencent.devops.dispatch.docker.api.builds.BuildDockerHostResource +import com.tencent.devops.dispatch.docker.api.builds.DispatchBuildDockerHostResource import com.tencent.devops.dispatch.docker.pojo.DockerIpInfoVO import com.tencent.devops.dispatch.docker.pojo.resource.DockerResourceOptionsVO import com.tencent.devops.dispatch.docker.service.DispatchDockerService -import com.tencent.devops.dispatch.docker.service.DockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService import com.tencent.devops.dispatch.docker.service.DockerResourceOptionsService import com.tencent.devops.store.pojo.image.response.ImageRepoInfo import org.springframework.beans.factory.annotation.Autowired @RestResource -class BuildDockerHostResourceImpl @Autowired constructor( - private val dockerHostBuildService: DockerHostBuildService, +class DispatchBuildDockerHostResourceImpl @Autowired constructor( + private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, private val dispatchDockerService: DispatchDockerService, private val dockerResourceOptionsService: DockerResourceOptionsService -) : BuildDockerHostResource { +) : DispatchBuildDockerHostResource { override fun getResourceConfig(pipelineId: String, vmSeqId: String): Result { return Result(dockerResourceOptionsService.getDockerResourceConfig(pipelineId, vmSeqId)) @@ -55,11 +55,11 @@ class BuildDockerHostResourceImpl @Autowired constructor( vmSeqId: String, poolNo: Int ): Result> { - return Result(dockerHostBuildService.getQpcGitProjectList(projectId, buildId, vmSeqId, poolNo)) + return Result(dispatchDockerHostBuildService.getQpcGitProjectList(projectId, buildId, vmSeqId, poolNo)) } override fun log(buildId: String, red: Boolean, message: String, tag: String?, jobId: String?): Result? { - dockerHostBuildService.log(buildId, red, message, tag, jobId) + dispatchDockerHostBuildService.log(buildId, red, message, tag, jobId) return Result(0, "success") } @@ -70,12 +70,12 @@ class BuildDockerHostResourceImpl @Autowired constructor( tag: String?, jobId: String? ): Result? { - dockerHostBuildService.log(buildId, red, message, tag, jobId) + dispatchDockerHostBuildService.log(buildId, red, message, tag, jobId) return Result(0, "success") } override fun getPublicImages(): Result> { - return dockerHostBuildService.getPublicImage() + return dispatchDockerHostBuildService.getPublicImage() } override fun refresh(dockerIp: String, dockerIpInfoVO: DockerIpInfoVO): Result { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt index 8c8153657cd..000be5b4b60 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt @@ -30,19 +30,19 @@ package com.tencent.devops.dispatch.docker.controller import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource import com.tencent.devops.dispatch.docker.api.op.OpDockerBuildResource -import com.tencent.devops.dispatch.docker.service.DockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService import com.tencent.devops.dispatch.docker.service.DockerHostQpcService import org.springframework.beans.factory.annotation.Autowired @RestResource class OpDockerBuildResourceImpl @Autowired constructor( - private val dockerHostBuildService: DockerHostBuildService, + private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, private val dockerHostQpcService: DockerHostQpcService ) : OpDockerBuildResource { override fun enable(pipelineId: String, vmSeqId: Int?, enable: Boolean): Result { - dockerHostBuildService.enable(pipelineId, vmSeqId, enable) + dispatchDockerHostBuildService.enable(pipelineId, vmSeqId, enable) return Result(true) } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDockerHostResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDispatchDockerHostResourceImpl.kt similarity index 87% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDockerHostResourceImpl.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDispatchDockerHostResourceImpl.kt index e447193c9ba..57299a1fc2d 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDockerHostResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDispatchDockerHostResourceImpl.kt @@ -31,22 +31,22 @@ import com.tencent.devops.common.api.exception.ParamBlankException import com.tencent.devops.common.api.pojo.Page import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource -import com.tencent.devops.dispatch.docker.api.service.ServiceDockerHostResource +import com.tencent.devops.dispatch.docker.api.service.ServiceDispatchDockerHostResource import com.tencent.devops.dispatch.docker.pojo.DockerHostZone import com.tencent.devops.dispatch.docker.pojo.DockerIpInfoVO import com.tencent.devops.dispatch.docker.pojo.SpecialDockerHostVO import com.tencent.devops.dispatch.docker.service.DispatchDockerService -import com.tencent.devops.dispatch.docker.service.DockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService import com.tencent.devops.dispatch.docker.service.DockerHostZoneTaskService import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @RestResource@Suppress("ALL") -class ServiceDockerHostResourceImpl @Autowired constructor( - private val dockerHostBuildService: DockerHostBuildService, +class ServiceDispatchDockerHostResourceImpl @Autowired constructor( + private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, private val dispatchDockerService: DispatchDockerService, private val dockerHostZoneTaskService: DockerHostZoneTaskService -) : ServiceDockerHostResource { +) : ServiceDispatchDockerHostResource { override fun list(page: Int?, pageSize: Int?): Page { checkParams(page, pageSize) val realPage = page ?: 1 @@ -62,7 +62,7 @@ class ServiceDockerHostResourceImpl @Autowired constructor( } override fun updateContainerId(buildId: String, vmSeqId: Int, containerId: String): Result { - dockerHostBuildService.updateContainerId(buildId, vmSeqId, containerId) + dispatchDockerHostBuildService.updateContainerId(buildId, vmSeqId, containerId) return Result(true) } @@ -78,7 +78,7 @@ class ServiceDockerHostResourceImpl @Autowired constructor( } companion object { - private val logger = LoggerFactory.getLogger(ServiceDockerHostResourceImpl::class.java) + private val logger = LoggerFactory.getLogger(ServiceDispatchDockerHostResourceImpl::class.java) } fun checkParams(page: Int?, pageSize: Int?) { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt index 8d029821acf..7489d453b36 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt @@ -48,7 +48,7 @@ import com.tencent.devops.dispatch.docker.dao.PipelineDockerTaskSimpleDao import com.tencent.devops.dispatch.docker.pojo.ContainerInfo import com.tencent.devops.dispatch.docker.pojo.DebugStartParam import com.tencent.devops.dispatch.docker.pojo.DockerHostLoad -import com.tencent.devops.dispatch.docker.service.DockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService import com.tencent.devops.dispatch.docker.service.debug.impl.DockerHostDebugServiceImpl import com.tencent.devops.dispatch.docker.utils.DockerHostUtils import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus @@ -60,7 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired @RestResource @Suppress("ALL") class UserDockerHostResourceImpl @Autowired constructor( - private val dockerHostBuildService: DockerHostBuildService, + private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, private val dockerHostDebugService: DockerHostDebugServiceImpl, private val bkAuthPermissionApi: AuthPermissionApi, private val pipelineAuthServiceCode: PipelineAuthServiceCode, @@ -185,7 +185,7 @@ class UserDockerHostResourceImpl @Autowired constructor( ): Result? { checkPermission(userId, projectId, pipelineId, vmSeqId) - return dockerHostBuildService.getContainerInfo(buildId, vmSeqId.toInt()) + return dispatchDockerHostBuildService.getContainerInfo(buildId, vmSeqId.toInt()) } override fun getGreyWebConsoleProject(userId: String): Result> { @@ -198,7 +198,7 @@ class UserDockerHostResourceImpl @Autowired constructor( } override fun getDockerHostLoad(userId: String): Result { - return Result(dockerHostBuildService.getDockerHostLoad(userId)) + return Result(dispatchDockerHostBuildService.getDockerHostLoad(userId)) } fun checkParam(userId: String, projectId: String, pipelineId: String, vmSeqId: String) { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt index 3b77386962a..1981f76ab30 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt @@ -51,7 +51,7 @@ import com.tencent.devops.dispatch.docker.dao.PipelineDockerTaskSimpleDao import com.tencent.devops.dispatch.docker.exception.DockerServiceException import com.tencent.devops.dispatch.docker.pojo.Credential import com.tencent.devops.dispatch.docker.pojo.Pool -import com.tencent.devops.dispatch.docker.service.DockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService import com.tencent.devops.dispatch.docker.utils.CommonUtils import com.tencent.devops.dispatch.docker.utils.DockerHostUtils import com.tencent.devops.dispatch.pojo.enums.JobQuotaVmType @@ -71,7 +71,7 @@ class DockerVMListener @Autowired constructor( private val dslContext: DSLContext, private val buildLogPrinter: BuildLogPrinter, private val defaultImageConfig: DefaultImageConfig, - private val dockerHostBuildService: DockerHostBuildService, + private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, private val dockerHostClient: DockerHostClient, private val dockerHostUtils: DockerHostUtils, private val pipelineDockerTaskSimpleDao: PipelineDockerTaskSimpleDao, @@ -117,7 +117,7 @@ class DockerVMListener @Autowired constructor( val dockerRoutingType = dockerRoutingSdkService.getDockerRoutingType(event.projectId) if (dockerRoutingType == DockerRoutingType.VM) { - dockerHostBuildService.finishDockerBuild(event) + dispatchDockerHostBuildService.finishDockerBuild(event) } else { pipelineEventDispatcher.dispatch(event.copy( routeKeySuffix = DispatchRouteKeySuffix.KUBERNETES.routeKeySuffix, diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostBuildService.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DispatchDockerHostBuildService.kt similarity index 98% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostBuildService.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DispatchDockerHostBuildService.kt index 40a6f577007..c0bba62d933 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostBuildService.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DispatchDockerHostBuildService.kt @@ -55,7 +55,7 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service @Service -class DockerHostBuildService @Autowired constructor( +class DispatchDockerHostBuildService @Autowired constructor( private val dslContext: DSLContext, private val dockerHostClient: DockerHostClient, private val pipelineDockerEnableDao: PipelineDockerEnableDao, @@ -349,6 +349,6 @@ class DockerHostBuildService @Autowired constructor( } companion object { - private val LOG = LoggerFactory.getLogger(DockerHostBuildService::class.java) + private val LOG = LoggerFactory.getLogger(DispatchDockerHostBuildService::class.java) } } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostZoneTaskService.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostZoneTaskService.kt index d15fb18b6f6..cb9b044f32f 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostZoneTaskService.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostZoneTaskService.kt @@ -32,7 +32,7 @@ import com.tencent.devops.dispatch.docker.dao.PipelineDockerHostDao import com.tencent.devops.dispatch.docker.dao.PipelineDockerHostZoneDao import com.tencent.devops.dispatch.docker.pojo.DockerHostZone import com.tencent.devops.dispatch.docker.pojo.SpecialDockerHostVO -import com.tencent.devops.dispatch.docker.utils.RedisUtils +import com.tencent.devops.dispatch.docker.utils.DispatchDockerRedisUtils import com.tencent.devops.model.dispatch.tables.records.TDispatchPipelineDockerHostZoneRecord import org.jooq.DSLContext import org.slf4j.LoggerFactory @@ -44,7 +44,7 @@ class DockerHostZoneTaskService @Autowired constructor( private val dockerHostZoneDao: PipelineDockerHostZoneDao, private val pipelineDockerHostDao: PipelineDockerHostDao, private val dslContext: DSLContext, - private val redisUtils: RedisUtils + private val dispatchDockerRedisUtils: DispatchDockerRedisUtils ) { companion object { @@ -107,10 +107,10 @@ class DockerHostZoneTaskService @Autowired constructor( ) } if (specialDockerHostVO.nfsShare != null && specialDockerHostVO.nfsShare!!) { - redisUtils.getSpecialProjectListKey().let { + dispatchDockerRedisUtils.getSpecialProjectListKey().let { val projectIdList = it?.split(",") ?: emptyList() if (!projectIdList.contains(specialDockerHostVO.projectId)) { - redisUtils.setSpecialProjectList(it + "," + specialDockerHostVO.projectId) + dispatchDockerRedisUtils.setSpecialProjectList(it + "," + specialDockerHostVO.projectId) } } } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/debug/impl/DockerHostDebugServiceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/debug/impl/DockerHostDebugServiceImpl.kt index 758a6b7009c..5325f9809e3 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/debug/impl/DockerHostDebugServiceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/debug/impl/DockerHostDebugServiceImpl.kt @@ -49,7 +49,7 @@ import com.tencent.devops.dispatch.docker.pojo.Pool import com.tencent.devops.dispatch.docker.service.DockerHostProxyService import com.tencent.devops.dispatch.docker.service.debug.DebugInterface import com.tencent.devops.dispatch.docker.utils.DockerHostDebugLock -import com.tencent.devops.dispatch.docker.utils.RedisUtils +import com.tencent.devops.dispatch.docker.utils.DispatchDockerRedisUtils import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus import com.tencent.devops.model.dispatch.tables.records.TDispatchPipelineDockerBuildRecord import com.tencent.devops.store.api.container.ServiceContainerAppResource @@ -69,7 +69,7 @@ class DockerHostDebugServiceImpl @Autowired constructor( private val pipelineDockerDebugDao: PipelineDockerDebugDao, private val pipelineDockerBuildDao: PipelineDockerBuildDao, private val pipelineDockerEnableDao: PipelineDockerEnableDao, - private val redisUtils: RedisUtils, + private val dispatchDockerRedisUtils: DispatchDockerRedisUtils, private val redisOperation: RedisOperation, private val client: Client, private val dockerHostProxyService: DockerHostProxyService, @@ -252,7 +252,7 @@ class DockerHostDebugServiceImpl @Autowired constructor( val debugTask = pipelineDockerDebugDao.getDebug(dslContext, pipelineId, vmSeqId) if (null == debugTask) { LOG.warn("The debug task not exists, pipelineId:$pipelineId, vmSeqId:$vmSeqId") - val msg = redisUtils.getRedisDebugMsg(pipelineId = pipelineId, vmSeqId = vmSeqId) + val msg = dispatchDockerRedisUtils.getRedisDebugMsg(pipelineId = pipelineId, vmSeqId = vmSeqId) return Result( status = 1, message = I18nUtil.getCodeLanMessage( @@ -320,7 +320,7 @@ class DockerHostDebugServiceImpl @Autowired constructor( fun cleanIp(projectId: String, pipelineId: String, vmSeqId: String): Result { LOG.info("clean pipeline docker build ip, projectId:$projectId, pipelineId:$pipelineId, vmSeqId:$vmSeqId") - redisUtils.deleteDockerBuildLastHost(pipelineId, vmSeqId) + dispatchDockerRedisUtils.deleteDockerBuildLastHost(pipelineId, vmSeqId) return Result(0, "success") } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/RedisUtils.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/DispatchDockerRedisUtils.kt similarity index 98% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/RedisUtils.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/DispatchDockerRedisUtils.kt index 424baf8a777..90043d69607 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/RedisUtils.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/utils/DispatchDockerRedisUtils.kt @@ -35,7 +35,7 @@ import org.springframework.stereotype.Component import java.util.concurrent.TimeUnit @Component -class RedisUtils @Autowired constructor( +class DispatchDockerRedisUtils @Autowired constructor( private val redisOperation: RedisOperation, private val objectMapper: ObjectMapper ) { diff --git a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt index 4a5067d5be2..316593d0a58 100644 --- a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt +++ b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt @@ -53,7 +53,7 @@ import com.tencent.devops.dispatch.kubernetes.pojo.builds.DispatchBuildTaskStatu import com.tencent.devops.dispatch.kubernetes.pojo.debug.DispatchBuilderDebugStatus import com.tencent.devops.dispatch.kubernetes.service.factory.ContainerServiceFactory import com.tencent.devops.dispatch.kubernetes.service.factory.JobServiceFactory -import com.tencent.devops.dispatch.kubernetes.utils.k8sRedisUtils +import com.tencent.devops.dispatch.kubernetes.utils.DispatchKubernetesRedisUtils import org.jooq.DSLContext import org.jooq.impl.DSL import org.slf4j.LoggerFactory @@ -69,7 +69,7 @@ class DispatchBaseDebugService @Autowired constructor( private val dispatchKubernetesBuildHisDao: DispatchKubernetesBuildHisDao, private val bkAuthPermissionApi: AuthPermissionApi, private val pipelineAuthServiceCode: PipelineAuthServiceCode, - private val k8sRedisUtils: k8sRedisUtils, + private val DispatchKubernetesRedisUtils: DispatchKubernetesRedisUtils, private val dockerRoutingSdkService: DockerRoutingSdkService ) { @@ -186,7 +186,7 @@ class DispatchBaseDebugService @Autowired constructor( } // 设置containerName缓存 - k8sRedisUtils.setDebugBuilderName(userId, pipelineId, vmSeqId, builderName) + DispatchKubernetesRedisUtils.setDebugBuilderName(userId, pipelineId, vmSeqId, builderName) return DebugResponse( websocketUrl = containerServiceFactory.load(projectId).getDebugWebsocketUrl( @@ -210,7 +210,7 @@ class DispatchBaseDebugService @Autowired constructor( val dockerRoutingType = dockerRoutingSdkService.getDockerRoutingType(projectId) val debugBuilderName = builderName.ifBlank { - k8sRedisUtils.getDebugBuilderName(userId, pipelineId, vmSeqId) ?: "" + DispatchKubernetesRedisUtils.getDebugBuilderName(userId, pipelineId, vmSeqId) ?: "" } logger.info( diff --git a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/k8sRedisUtils.kt b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/DispatchKubernetesRedisUtils.kt similarity index 97% rename from src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/k8sRedisUtils.kt rename to src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/DispatchKubernetesRedisUtils.kt index 00104989b2a..5d187d63bd9 100644 --- a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/k8sRedisUtils.kt +++ b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/utils/DispatchKubernetesRedisUtils.kt @@ -32,7 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @Component -class k8sRedisUtils @Autowired constructor( +class DispatchKubernetesRedisUtils @Autowired constructor( private val redisOperation: RedisOperation ) { fun setDebugBuilderName( diff --git a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/SystemInfoRunner.kt b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/DockerhostSystemInfoRunner.kt similarity index 98% rename from src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/SystemInfoRunner.kt rename to src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/DockerhostSystemInfoRunner.kt index d7f9073052e..b31d7c15748 100644 --- a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/SystemInfoRunner.kt +++ b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/DockerhostSystemInfoRunner.kt @@ -32,7 +32,7 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component -class SystemInfoRunner { +class DockerhostSystemInfoRunner { @Scheduled(cron = "0/5 * * * * ?") fun startCollect() { diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/ScheduleConfig.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/MiscScheduleConfig.kt similarity index 97% rename from src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/ScheduleConfig.kt rename to src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/MiscScheduleConfig.kt index 563d9b2bee6..04c175a9795 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/ScheduleConfig.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/MiscScheduleConfig.kt @@ -35,7 +35,7 @@ import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit @Configuration -class ScheduleConfig : SchedulingConfigurer { +class MiscScheduleConfig : SchedulingConfigurer { override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar) { val scheduler = ScheduledThreadPoolExecutor(20) scheduler.maximumPoolSize = 500 diff --git a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt similarity index 98% rename from src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt rename to src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt index 2c88c1c7b36..c33597fa8c9 100644 --- a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt +++ b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt @@ -44,9 +44,9 @@ import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicInteger @Component -class InfluxdbClient { +class MonitoringInfluxdbClient { companion object { - private val logger = LoggerFactory.getLogger(InfluxdbClient::class.java) + private val logger = LoggerFactory.getLogger(MonitoringInfluxdbClient::class.java) private const val actions = 1000 private const val flushDuration = 100 private const val bufferLimit = 100 diff --git a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt index 78772d6d49f..a282b79d535 100644 --- a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt +++ b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt @@ -31,7 +31,7 @@ import com.tencent.devops.common.api.exception.ErrorCodeException import com.tencent.devops.common.api.pojo.AtomMonitorData import com.tencent.devops.common.event.listener.Listener import com.tencent.devops.common.event.pojo.measure.AtomMonitorReportBroadCastEvent -import com.tencent.devops.monitoring.client.InfluxdbClient +import com.tencent.devops.monitoring.client.MonitoringInfluxdbClient import com.tencent.devops.monitoring.constant.MonitoringMessageCode.ERROR_MONITORING_INSERT_DATA_FAIL import com.tencent.devops.monitoring.consumer.processor.monitor.AbstractMonitorProcessor import io.micrometer.core.instrument.Counter @@ -42,7 +42,7 @@ import org.springframework.stereotype.Component @Component class AtomMonitorReportListener @Autowired constructor( - private val influxdbClient: InfluxdbClient, + private val monitoringInfluxdbClient: MonitoringInfluxdbClient, private val monitorProcessors: List, private val meterRegistry: MeterRegistry ) : Listener { @@ -54,7 +54,7 @@ class AtomMonitorReportListener @Autowired constructor( insertAtomMonitorData(monitorData) monitorProcessors.asSequence().filter { it.atomCode() == monitorData.atomCode } - .forEach { it.process(influxdbClient, monitorData) } + .forEach { it.process(monitoringInfluxdbClient, monitorData) } } catch (ignored: Throwable) { logger.warn("Fail to insert the atom monitor data", ignored) throw ErrorCodeException( @@ -66,7 +66,7 @@ class AtomMonitorReportListener @Autowired constructor( fun insertAtomMonitorData(data: AtomMonitorData) { // 写入influxdb - influxdbClient.insert(data) + monitoringInfluxdbClient.insert(data) // 暴露prometheus Counter.builder("atom_monitor") diff --git a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt index e81ebdd0f4e..e971a6098e8 100644 --- a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt +++ b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt @@ -28,7 +28,7 @@ package com.tencent.devops.monitoring.consumer.processor.monitor import com.tencent.devops.common.api.pojo.AtomMonitorData -import com.tencent.devops.monitoring.client.InfluxdbClient +import com.tencent.devops.monitoring.client.MonitoringInfluxdbClient import org.slf4j.LoggerFactory /** @@ -46,7 +46,7 @@ abstract class AbstractMonitorProcessor { */ protected abstract fun process(extData: Map, monitorDatas: ArrayList) - fun process(influxdbClient: InfluxdbClient, atomMonitorData: AtomMonitorData) { + fun process(monitoringInfluxdbClient: MonitoringInfluxdbClient, atomMonitorData: AtomMonitorData) { val extData = atomMonitorData.extData @@ -71,7 +71,7 @@ abstract class AbstractMonitorProcessor { it.fields["vmSeqId"] = atomMonitorData.vmSeqId it.fields["channel"] = atomMonitorData.channel ?: "" it.fields["starter"] = atomMonitorData.starter - }.forEach { influxdbClient.insert(this.measurement(), it.tags, it.fields) } + }.forEach { monitoringInfluxdbClient.insert(this.measurement(), it.tags, it.fields) } } companion object { diff --git a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/service/AtomMonitorService.kt b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/service/AtomMonitorService.kt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt index da09b8360bd..1c6c848cb3a 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt @@ -58,7 +58,12 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) - private val multiDataSource = System.getProperty("devops.multi.from").split(",").filterNot { it == "process" } - private val regex = Regex("""ENC\((.*?)\)""") + private val notNeedDataSourceService = listOf( + "buildless", "dockerhost", "metrics", "misc", "monitoring", "process","worker","websocket" + ) + + private + val multiDataSource = System.getProperty("devops.multi.from") + .split(",").filterNot { notNeedDataSourceService.contains(it) } } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt index 895379ecd7a..33ceb828a5c 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt @@ -21,7 +21,7 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { importBeanNameGenerator: BeanNameGenerator ) { multiDataSource.forEach { dataSource -> - val finalDataSource = if (dataSource == "process") "shardingDataSource" else + val finalDataSource = if (dataSource == "process" || dataSource == "metrics") "shardingDataSource" else "${dataSource}DataSource" val connectionProvider = BeanDefinitionBuilder.genericBeanDefinition( DataSourceConnectionProvider::class.java @@ -40,7 +40,8 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { } companion object { - private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) + private val notNeedJooqService = listOf("buildless", "dockerhost", "misc", "monitoring", "worker", "websocket") private val multiDataSource = System.getProperty("devops.multi.from").split(",") + .filterNot { notNeedJooqService.contains(it) } } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt index 2481e410f04..8887f23faba 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -41,6 +41,7 @@ import org.springframework.context.annotation.Primary import org.springframework.context.annotation.Scope import java.lang.reflect.AnnotatedElement import java.lang.reflect.Constructor +import java.lang.reflect.Field import java.lang.reflect.Method import java.lang.reflect.Parameter @@ -59,33 +60,29 @@ class MutijarDslContextConfiguration { injectionPoint: InjectionPoint ): DSLContext { val annotatedElement: AnnotatedElement = injectionPoint.annotatedElement - if (Constructor::class.java.isAssignableFrom(annotatedElement::class.java) || - Method::class.java.isAssignableFrom(annotatedElement::class.java) + if (annotatedElement !is Constructor<*> && annotatedElement !is Method && annotatedElement !is Field ) { - val declaringClass: Class<*> = when (annotatedElement) { - is Constructor<*> -> annotatedElement.declaringClass - is Method -> annotatedElement.declaringClass - else -> throw IllegalArgumentException("Invalid annotatedElement type") - } - val packageName = declaringClass.getPackage().name - // lambda服务有多个数据源,需要进行处理 - val configurationName = if (packageName.contains(".lambda")) { - val matchResult = lambdaServiceRegex.find(packageName) - "${matchResult?.groupValues?.get(1) ?: "lambda"}JooqConfiguration" - } else { - val serviceName = multiModelService.find { packageName.contains(it) } - ?: throw NoSuchBeanDefinitionException("no jooq configuration") - serviceName.removePrefix(".").plus("JooqConfiguration") - } - val configuration: org.jooq.Configuration = configurationMap[configurationName] - ?: throw NoSuchBeanDefinitionException("no $configurationName") - return DSL.using(configuration) + throw IllegalArgumentException("Invalid annotatedElement type") } - throw NoSuchBeanDefinitionException("no jooq configuration") + val declaringClass: Class<*> = when (annotatedElement) { + is Constructor<*> -> annotatedElement.declaringClass + is Method -> annotatedElement.declaringClass + is Field -> annotatedElement.declaringClass + else -> throw IllegalArgumentException("Invalid annotatedElement type") + } + + val packageName = declaringClass.`package`.name + val serviceName = multiModelService.find { packageName.contains(it) } + ?: throw NoSuchBeanDefinitionException("no jooq configuration") + val configurationName = serviceName.removePrefix(".").plus("JooqConfiguration") + + val configuration: org.jooq.Configuration = configurationMap[configurationName] + ?: throw NoSuchBeanDefinitionException("no $configurationName") + + return DSL.using(configuration) } companion object { private val multiModelService = System.getProperty("devops.multi.from").split(",") - private val lambdaServiceRegex = "\\.(tsource|ttarget|process|project|store)".toRegex() } } diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt index 87f6e4316c5..aa78521df8c 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt @@ -29,7 +29,7 @@ package com.tencent.devops.openapi.resources.apigw.v4 import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client import com.tencent.devops.common.web.RestResource -import com.tencent.devops.dispatch.docker.api.service.ServiceDockerHostResource +import com.tencent.devops.dispatch.docker.api.service.ServiceDispatchDockerHostResource import com.tencent.devops.dispatch.docker.pojo.SpecialDockerHostVO import com.tencent.devops.openapi.api.apigw.v4.ApigwDispatchResourceV4 import org.slf4j.LoggerFactory @@ -47,7 +47,7 @@ class ApigwDispatchResourceV4Impl @Autowired constructor( specialDockerHostVOs: List ): Result { logger.info("OPENAPI_DISPATCH_V4|$userId|create special docker host|$specialDockerHostVOs") - client.get(ServiceDockerHostResource::class).createSpecialDockerHost( + client.get(ServiceDispatchDockerHostResource::class).createSpecialDockerHost( userId = userId, specialDockerHostVOs = specialDockerHostVOs ) diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt index 385fad2e3a7..423e0e3ec9d 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/rule/processor/BkVarProcessorService.kt @@ -33,10 +33,10 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service("BkVarProcessor") -class BkVarProcessorService constructor( - private val dslContext: DSLContext -) : ProcessorService { +class BkVarProcessorService : ProcessorService { + @Autowired + private lateinit var dslContext: DSLContext @Autowired private lateinit var pipelineBuildVarDao: PipelineBuildVarDao diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt index 82583120b31..9e270c879b3 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt @@ -5,12 +5,12 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource import com.tencent.devops.repository.api.ServiceRepositoryGitCheckResource import com.tencent.devops.repository.pojo.RepositoryGitCheck -import com.tencent.devops.repository.service.GitCheckService +import com.tencent.devops.repository.service.RepoGitCheckService import org.springframework.beans.factory.annotation.Autowired @RestResource class ServiceRepositoryGitCheckResourceImpl @Autowired constructor( - private val gitCheckService: GitCheckService + private val repoGitCheckService: RepoGitCheckService ) : ServiceRepositoryGitCheckResource { override fun getGitCheck( pipelineId: String, @@ -18,14 +18,14 @@ class ServiceRepositoryGitCheckResourceImpl @Autowired constructor( context: String, repositoryConfig: RepositoryConfig ): Result { - return Result(gitCheckService.getGitCheck(pipelineId, repositoryConfig, commitId, context)) + return Result(repoGitCheckService.getGitCheck(pipelineId, repositoryConfig, commitId, context)) } override fun createGitCheck(gitCheck: RepositoryGitCheck) { - gitCheckService.creatGitCheck(gitCheck) + repoGitCheckService.creatGitCheck(gitCheck) } override fun updateGitCheck(gitCheckId: Long, buildNumber: Int) { - gitCheckService.updateGitCheck(gitCheckId = gitCheckId, buildNumber = buildNumber) + repoGitCheckService.updateGitCheck(gitCheckId = gitCheckId, buildNumber = buildNumber) } } diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/GitCheckService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoGitCheckService.kt similarity index 96% rename from src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/GitCheckService.kt rename to src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoGitCheckService.kt index 7ecebc342e4..43bdd7456e5 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/GitCheckService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoGitCheckService.kt @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service -class GitCheckService @Autowired constructor( +class RepoGitCheckService @Autowired constructor( private val dslContext: DSLContext, private val gitCheckDao: GitCheckDao ) { diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalGithubResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalGithubResource.kt similarity index 98% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalGithubResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalGithubResource.kt index b3fb80aa1f9..0b7bf705ec0 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalGithubResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalGithubResource.kt @@ -45,7 +45,7 @@ import javax.ws.rs.core.Response @Path("/external/github/") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface ExternalGithubResource { +interface StreamExternalGithubResource { @ApiOperation("Github仓库提交") @POST diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalScmResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalScmResource.kt similarity index 98% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalScmResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalScmResource.kt index 9a2ac6c311e..91b7f4825a9 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalScmResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalScmResource.kt @@ -42,7 +42,7 @@ import javax.ws.rs.core.MediaType @Path("/service/scm") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface ExternalScmResource { +interface StreamExternalScmResource { @ApiOperation("Code平台Git仓库提交") @POST diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamLoginResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamLoginResource.kt similarity index 97% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamLoginResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamLoginResource.kt index 4fe10d6225b..e7ef106f719 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamLoginResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamLoginResource.kt @@ -43,7 +43,7 @@ import javax.ws.rs.core.MediaType @Path("/external/stream/login") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface ExternalStreamLoginResource { +interface StreamExternalStreamLoginResource { @ApiOperation("获取登录url") @GET diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamResource.kt similarity index 98% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamResource.kt index e493bf539bd..a72a94ee7d5 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamResource.kt @@ -42,7 +42,7 @@ import javax.ws.rs.core.MediaType @Path("/external/stream") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface ExternalStreamResource { +interface StreamExternalStreamResource { @ApiOperation("获取流水线徽章") @Produces("image/svg+xml") diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalGithubResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalGithubResourceImpl.kt similarity index 93% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalGithubResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalGithubResourceImpl.kt index 178ec1d1190..3911966e570 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalGithubResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalGithubResourceImpl.kt @@ -32,7 +32,7 @@ import com.tencent.devops.common.api.enums.ScmType import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.api.util.ShaUtils import com.tencent.devops.common.web.RestResource -import com.tencent.devops.stream.api.external.ExternalGithubResource +import com.tencent.devops.stream.api.external.StreamExternalGithubResource import com.tencent.devops.stream.config.StreamGitConfig import com.tencent.devops.stream.service.StreamLoginService import com.tencent.devops.stream.trigger.mq.streamRequest.StreamRequestDispatcher @@ -44,14 +44,14 @@ import javax.ws.rs.core.Response import javax.ws.rs.core.UriBuilder @RestResource -class ExternalGithubResourceImpl @Autowired constructor( +class StreamExternalGithubResourceImpl @Autowired constructor( private val streamLoginService: StreamLoginService, private val streamGitConfig: StreamGitConfig, private val rabbitTemplate: RabbitTemplate -) : ExternalGithubResource { +) : StreamExternalGithubResource { companion object { - private val logger = LoggerFactory.getLogger(ExternalGithubResourceImpl::class.java) + private val logger = LoggerFactory.getLogger(StreamExternalGithubResourceImpl::class.java) } override fun webhookCommit(event: String, guid: String, signature: String, body: String): Result { diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalScmResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalScmResourceImpl.kt similarity index 92% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalScmResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalScmResourceImpl.kt index 25214ae240d..561632fb0af 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalScmResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalScmResourceImpl.kt @@ -35,7 +35,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.web.RestResource import com.tencent.devops.common.webhook.pojo.code.git.GitReviewEvent -import com.tencent.devops.stream.api.external.ExternalScmResource +import com.tencent.devops.stream.api.external.StreamExternalScmResource import com.tencent.devops.stream.trigger.mq.streamRequest.StreamRequestDispatcher import com.tencent.devops.stream.trigger.mq.streamRequest.StreamRequestEvent import org.slf4j.LoggerFactory @@ -43,13 +43,13 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate import org.springframework.beans.factory.annotation.Autowired @RestResource -class ExternalScmResourceImpl @Autowired constructor( +class StreamExternalScmResourceImpl @Autowired constructor( private val objectMapper: ObjectMapper, private val rabbitTemplate: RabbitTemplate -) : ExternalScmResource { +) : StreamExternalScmResource { companion object { - private val logger = LoggerFactory.getLogger(ExternalScmResourceImpl::class.java) + private val logger = LoggerFactory.getLogger(StreamExternalScmResourceImpl::class.java) } override fun webHookCodeGitCommit(token: String, eventType: String, event: String): Result { diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamLoginResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamLoginResourceImpl.kt similarity index 91% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamLoginResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamLoginResourceImpl.kt index 870ed597d41..9fae126b848 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamLoginResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamLoginResourceImpl.kt @@ -30,14 +30,14 @@ package com.tencent.devops.stream.resources.external import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource -import com.tencent.devops.stream.api.external.ExternalStreamLoginResource +import com.tencent.devops.stream.api.external.StreamExternalStreamLoginResource import com.tencent.devops.stream.service.StreamLoginService import org.springframework.beans.factory.annotation.Autowired @RestResource -class ExternalStreamLoginResourceImpl @Autowired constructor( +class StreamExternalStreamLoginResourceImpl @Autowired constructor( private val streamLoginService: StreamLoginService -) : ExternalStreamLoginResource { +) : StreamExternalStreamLoginResource { override fun loginUrl(type: String): Result { return Result(streamLoginService.loginUrl(type)) diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamResourceImpl.kt similarity index 93% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamResourceImpl.kt index bff09310f0b..62eb3ce91fd 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamResourceImpl.kt @@ -28,13 +28,13 @@ package com.tencent.devops.stream.resources.external import com.tencent.devops.common.web.RestResource -import com.tencent.devops.stream.api.external.ExternalStreamResource +import com.tencent.devops.stream.api.external.StreamExternalStreamResource import com.tencent.devops.stream.service.StreamPipelineBadgeService @RestResource -class ExternalStreamResourceImpl( +class StreamExternalStreamResourceImpl( private val streamPipelineBadgeService: StreamPipelineBadgeService -) : ExternalStreamResource { +) : StreamExternalStreamResource { override fun getPipelineBadge( gitProjectId: Long, filePath: String, diff --git a/support-files/templates/#etc#ci#application-buildless.yml b/support-files/templates/#etc#ci#application-buildless.yml index 4b44f6645e8..21bdbdf41b3 100644 --- a/support-files/templates/#etc#ci#application-buildless.yml +++ b/support-files/templates/#etc#ci#application-buildless.yml @@ -10,8 +10,8 @@ server: port: __BK_CI_BUILDLESS_API_PORT__ containerPool: - coreSize: # 表示容器池默认初始容器数大小,默认:20 - maxSize: # 表示容器池最大可创建容器数大小,默认:30 + coreSize: 20 # 表示容器池默认初始容器数大小,默认:20 + maxSize: 30 # 表示容器池最大可创建容器数大小,默认:30 baseImage: # 表示容器池容器默认镜像,默认:blueking/bk-ci gateway: __BK_CI_PUBLIC_URL__ From 6c3b7e518b0744f4b3dda2c287adca36365adfc9 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 23 Aug 2023 17:20:21 +0800 Subject: [PATCH 21/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application.yml | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml b/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml index ac834873dd3..1b34ed82096 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml @@ -4,6 +4,26 @@ spring: - common - auth - image + - process + - environment + - ticket + - repository + - project + - notify + - openapi + - dispatch + - dispatch-docker + - dispatch-kubernetes + - artifactory + - buildless + - dockerhost + - metrics + - monitoring + - plugin + - stream + - worker + - websocket + - quality main: allow-bean-definition-overriding: true application: @@ -14,8 +34,6 @@ spring: cloud: config: fail-fast: true -server: - port: 21930 logging: level: root=DEBUG: DEBUG From 390b2e24f8c4324bf48ad562c317fb7b6fe102b8 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Fri, 25 Aug 2023 10:11:02 +0800 Subject: [PATCH 22/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/plugins/task-multi-boot-run.gradle.kts | 4 ++-- .../kotlin/plugins/task-render-template.gradle.kts | 5 +++++ .../common/dispatch.sdk/config/SDKConfiguration.kt | 2 ++ .../com/tencent/devops/misc/config/DataSourceConfig.kt | 2 ++ .../tencent/devops/misc/config/JooqConfiguration.kt | 2 ++ .../ci/core/mutijar/boot-mutijar/build.gradle.kts | 1 + .../devops/mutijar/MutijarDslContextConfiguration.kt | 10 +++++++++- .../boot-mutijar/src/main/resources/application.yml | 10 ++-------- 8 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index 0cadfd098b5..beb4f2a5339 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -38,9 +38,8 @@ tasks.register("multiBootRun") { systemProperty("sun.jnu.encoding", "UTF-8") systemProperty("file.encoding", "UTF-8") systemProperty("spring.cloud.consul.host", "localhost") - systemProperty("service.log.dir", joinPath(projectDir.absolutePath, "log")) + systemProperty("service.log.dir", joinPath(projectDir.absolutePath, "log")) } - dependsOn("replacePlaceholders") dependsOn("multiBootJar") val bootJarTask = tasks.getByName("bootJar") mainClass.set(bootJarTask.mainClass) @@ -50,3 +49,4 @@ tasks.register("multiBootRun") { * 返回路径 */ fun joinPath(vararg folders: String) = folders.joinToString(File.separator) +tasks.getByName("compileKotlin").dependsOn("replacePlaceholders") diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts index 64571b98034..5da1a0c7ffc 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts @@ -45,6 +45,11 @@ tasks.register("replacePlaceholders") { } } +tasks.register("deleteApplicationTemplate"){ + val destDir = joinPath(projectDir.absolutePath, "src", "main", "resources") + deleteFiles(destDir) +} + fun deleteFiles(dir: String) { val destDirFile = File(dir) destDirFile.listFiles()?.forEach { file -> diff --git a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt index 48d27aa69d2..bcd3733afec 100644 --- a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt +++ b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt @@ -44,6 +44,7 @@ import com.tencent.devops.common.dispatch.sdk.service.JobQuotaService import com.tencent.devops.common.dispatch.sdk.utils.ChannelUtils import com.tencent.devops.common.service.BkTag import com.tencent.devops.common.service.config.CommonConfig +import org.springframework.context.annotation.Primary @Configuration class SDKConfiguration { @@ -85,6 +86,7 @@ class SDKConfiguration { DockerRoutingSdkService(redisOperation) @Bean + @Primary fun pipelineEventDispatcher(@Autowired rabbitTemplate: RabbitTemplate): PipelineEventDispatcher { return MQEventDispatcher(rabbitTemplate) } diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt index c86aea43e99..4058b0d85fa 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt @@ -31,6 +31,7 @@ import com.mysql.cj.jdbc.Driver import com.zaxxer.hikari.HikariDataSource import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary @@ -46,6 +47,7 @@ import javax.sql.DataSource @Configuration @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement +@ConditionalOnMissingClass("com.tencent.devops.mutijar.MutijarDslContextConfiguration") class DataSourceConfig { @Bean diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt index b7c2274cd69..0ee046bdc7b 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt @@ -40,6 +40,7 @@ import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.annotation.Value import org.springframework.beans.factory.config.ConfigurableBeanFactory import org.springframework.boot.autoconfigure.AutoConfigureAfter +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import @@ -55,6 +56,7 @@ import javax.sql.DataSource */ @Configuration @Import(DataSourceConfig::class, DBBaseConfiguration::class) +@ConditionalOnMissingClass("com.tencent.devops.mutijar.MutijarDslContextConfiguration") @AutoConfigureAfter(DBBaseConfiguration::class) class JooqConfiguration { diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts index 41996ad17b5..bf4473a6806 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts +++ b/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts @@ -42,3 +42,4 @@ tasks.named("bootJar") { val finalModuleName = System.getProperty("devops.multi.to") archiveBaseName.set("boot-$finalModuleName") } +tasks.getByName("multiBootRun").dependsOn("replacePlaceholders") diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt index 8887f23faba..a7816beff06 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt @@ -74,7 +74,14 @@ class MutijarDslContextConfiguration { val packageName = declaringClass.`package`.name val serviceName = multiModelService.find { packageName.contains(it) } ?: throw NoSuchBeanDefinitionException("no jooq configuration") - val configurationName = serviceName.removePrefix(".").plus("JooqConfiguration") + val configurationName = if (packageName.contains(".misc")) { + val matchResult = miscServiceRegex.find(packageName) + "${matchResult?.groupValues?.get(1) ?: "default"}JooqConfiguration" + } else if (packageName.contains(".store")){ + "storeJooqConfiguration" + }else { + serviceName.plus("JooqConfiguration") + } val configuration: org.jooq.Configuration = configurationMap[configurationName] ?: throw NoSuchBeanDefinitionException("no $configurationName") @@ -84,5 +91,6 @@ class MutijarDslContextConfiguration { companion object { private val multiModelService = System.getProperty("devops.multi.from").split(",") + private val miscServiceRegex = "\\.(process|project|repository|dispatch|plugin|quality|artifactory|environment)".toRegex() } } diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml b/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml index 1b34ed82096..784630be524 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml +++ b/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml @@ -23,17 +23,11 @@ spring: - stream - worker - websocket + - misc + - store - quality - main: - allow-bean-definition-overriding: true application: name: mutijar desc: DevOps MUTIJAR Service version: 4.0.0 packageName: com.tencent.devops.mutijar - cloud: - config: - fail-fast: true -logging: - level: - root=DEBUG: DEBUG From 481d6c62aa9171eb3ae859e448bd945e1ecffab3 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 28 Aug 2023 09:56:25 +0800 Subject: [PATCH 23/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-multi-boot-run.gradle.kts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index beb4f2a5339..9e0df29d4c0 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -37,7 +37,9 @@ tasks.register("multiBootRun") { systemProperty("jasypt.encryptor.bootstrap", "false") systemProperty("sun.jnu.encoding", "UTF-8") systemProperty("file.encoding", "UTF-8") - systemProperty("spring.cloud.consul.host", "localhost") + systemProperty("spring.cloud.consul.enabled", "false") + systemProperty("spring.cloud.consul.discovery.enabled", "false") + systemProperty("server.port", "8080") systemProperty("service.log.dir", joinPath(projectDir.absolutePath, "log")) } dependsOn("multiBootJar") From 6979c7cddc095e17de263b1df56ac6916cd79800 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 6 Sep 2023 15:08:12 +0800 Subject: [PATCH 24/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-multi-boot-run.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index 9e0df29d4c0..d94b8a33904 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -39,7 +39,7 @@ tasks.register("multiBootRun") { systemProperty("file.encoding", "UTF-8") systemProperty("spring.cloud.consul.enabled", "false") systemProperty("spring.cloud.consul.discovery.enabled", "false") - systemProperty("server.port", "8080") + systemProperty("server.port", "8081") systemProperty("service.log.dir", joinPath(projectDir.absolutePath, "log")) } dependsOn("multiBootJar") From e71d1063edca98ae106f100da0dc9b8e645bb2c8 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 6 Sep 2023 15:13:29 +0800 Subject: [PATCH 25/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/auth/service/MyStartupTask.kt | 18 ------------------ .../ci/core/auth/boot-auth/build.gradle.kts | 4 ---- .../dispatch/service/ThirdPartyAgentService.kt | 8 ++++---- ...atchService1.kt => DispatchAgentService.kt} | 4 ++-- .../agent/ThirdPartyAgentDispatcher.kt | 4 ++-- .../core/project/biz-project/build.gradle.kts | 2 +- src/backend/ci/settings.gradle.kts | 4 ---- 7 files changed, 9 insertions(+), 35 deletions(-) delete mode 100644 src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt rename src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/{DispatchService1.kt => DispatchAgentService.kt} (96%) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt deleted file mode 100644 index 99cb5480338..00000000000 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/service/MyStartupTask.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.tencent.devops.auth.service - -import org.slf4j.LoggerFactory -import org.springframework.stereotype.Component -import javax.annotation.PostConstruct - - -@Component -class MyStartupTask { - @PostConstruct - fun init() { - logger.info("MyStartupTask init") - } - - companion object { - private val logger = LoggerFactory.getLogger(MyStartupTask::class.java) - } -} diff --git a/src/backend/ci/core/auth/boot-auth/build.gradle.kts b/src/backend/ci/core/auth/boot-auth/build.gradle.kts index eafedf3eab8..b7dd3810af9 100644 --- a/src/backend/ci/core/auth/boot-auth/build.gradle.kts +++ b/src/backend/ci/core/auth/boot-auth/build.gradle.kts @@ -30,7 +30,3 @@ dependencies { api(project(":core:auth:biz-auth-blueking")) api(project(":core:auth:biz-auth-rbac")) } -tasks.named("bootRun") { - //classpath = files("${project.rootDir}\\release\\boot-finalModule.jar") - println("greysonfang-test classpath = ${classpath.asPath}") -} diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt index 8e0809f69d5..74a3470f5b4 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/ThirdPartyAgentService.kt @@ -49,7 +49,7 @@ import com.tencent.devops.dispatch.pojo.thirdPartyAgent.BuildJobType import com.tencent.devops.dispatch.pojo.thirdPartyAgent.ThirdPartyBuildDockerInfo import com.tencent.devops.dispatch.pojo.thirdPartyAgent.ThirdPartyBuildInfo import com.tencent.devops.dispatch.pojo.thirdPartyAgent.ThirdPartyBuildWithStatus -import com.tencent.devops.dispatch.service.dispatcher.agent.DispatchService1 +import com.tencent.devops.dispatch.service.dispatcher.agent.DispatchAgentService import com.tencent.devops.dispatch.utils.ThirdPartyAgentLock import com.tencent.devops.dispatch.utils.ThirdPartyAgentUtils import com.tencent.devops.dispatch.utils.redis.ThirdPartyAgentBuildRedisUtils @@ -75,7 +75,7 @@ class ThirdPartyAgentService @Autowired constructor( private val client: Client, private val redisOperation: RedisOperation, private val thirdPartyAgentBuildDao: ThirdPartyAgentBuildDao, - private val dispatchService1: DispatchService1 + private val dispatchAgentService: DispatchAgentService ) { fun queueBuild( @@ -367,7 +367,7 @@ class ThirdPartyAgentService @Autowired constructor( finishBuild(it, success) if (it.dockerInfo != null) { // 第三方构建机可能是docker构建机时需要在这里删除docker类型的redisKey - dispatchService1.shutdown(event) + dispatchAgentService.shutdown(event) } } } else { @@ -375,7 +375,7 @@ class ThirdPartyAgentService @Autowired constructor( finishBuild(record, success) if (record.dockerInfo != null) { // 第三方构建机可能是docker构建机时需要在这里删除docker类型的redisKey - dispatchService1.shutdown(event) + dispatchAgentService.shutdown(event) } } } diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService1.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchAgentService.kt similarity index 96% rename from src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService1.kt rename to src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchAgentService.kt index 44ed318c68c..8805f963d21 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchService1.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchAgentService.kt @@ -18,7 +18,7 @@ import org.springframework.stereotype.Service **/ @Suppress("ALL") @Service -class DispatchService1 @Autowired constructor( +class DispatchAgentService @Autowired constructor( private val redisOperation: RedisOperation, private val objectMapper: ObjectMapper ) { @@ -96,6 +96,6 @@ class DispatchService1 @Autowired constructor( } companion object { - private val logger = LoggerFactory.getLogger(DispatchService1::class.java) + private val logger = LoggerFactory.getLogger(DispatchAgentService::class.java) } } diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt index f1f83485bf8..fc9694f7f5a 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/ThirdPartyAgentDispatcher.kt @@ -79,7 +79,7 @@ class ThirdPartyAgentDispatcher @Autowired constructor( private val thirdPartyAgentBuildRedisUtils: ThirdPartyAgentBuildRedisUtils, private val pipelineEventDispatcher: PipelineEventDispatcher, private val thirdPartyAgentBuildService: ThirdPartyAgentService, - private val dispatchService1: DispatchService1 + private val dispatchAgentService: DispatchAgentService ) : Dispatcher { override fun canDispatch(event: PipelineAgentStartupEvent) = event.dispatchType is ThirdPartyAgentIDDispatchType || @@ -251,7 +251,7 @@ class ThirdPartyAgentDispatcher @Autowired constructor( val message = if (dockerInfo == null) { null } else { - dispatchService1.setRedisAuth(event) + dispatchAgentService.setRedisAuth(event) } // #5806 入库失败就不再写Redis diff --git a/src/backend/ci/core/project/biz-project/build.gradle.kts b/src/backend/ci/core/project/biz-project/build.gradle.kts index bcc901c6fb0..847f9abeedd 100644 --- a/src/backend/ci/core/project/biz-project/build.gradle.kts +++ b/src/backend/ci/core/project/biz-project/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Tencent is p:leased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. * * Copyright (C)) 2019 THL A29 Limited, a Tencent company. All rights reserved. * diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index 6573d628329..61aa2ef5016 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -270,7 +270,3 @@ include(":core:metrics:model-metrics") include("core:mutijar") include("core:mutijar:boot-mutijar") -include("core:mutijar:boot-mutijar") -findProject(":core:mutijar:boot-mutijar")?.name = "boot-mutijar" -include("core:mutijar:boot-mutijar") -findProject(":core:mutijar:boot-mutijar")?.name = "boot-mutijar" From f5138223b139246d0cffdbcf552ca2b19f2aa1f0 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Wed, 6 Sep 2023 15:52:55 +0800 Subject: [PATCH 26/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend/ci/.gitignore b/src/backend/ci/.gitignore index d858712732c..9537b7ff18d 100644 --- a/src/backend/ci/.gitignore +++ b/src/backend/ci/.gitignore @@ -17,3 +17,4 @@ build.yml .codecc *.log.gz i18n/ +core/mutijar/boot-mutijar/src/main/resources/application-*.yml From 442ce3e91ec6df63578aaf6673515e107bd93a28 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Fri, 8 Sep 2023 16:50:45 +0800 Subject: [PATCH 27/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/common/AuthCoreConfiguration.kt | 20 +++---- .../event/dispatcher/pipeline/mq/Tools.kt | 12 +++-- .../configuration/ListenerConfiguration.kt | 22 ++++---- .../project/config/ProjectMQConfiguration.kt | 52 +++++++++++-------- 4 files changed, 61 insertions(+), 45 deletions(-) diff --git a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt index 3b1dd8d8fd0..f2921e3dc95 100644 --- a/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt +++ b/src/backend/ci/core/auth/biz-auth/src/main/kotlin/com/tencent/devops/auth/common/AuthCoreConfiguration.kt @@ -36,6 +36,7 @@ import com.tencent.devops.auth.service.AuthUserBlackListService import com.tencent.devops.auth.utils.HostUtils import com.tencent.devops.common.client.ClientTokenService import com.tencent.devops.common.event.dispatcher.pipeline.mq.MQ +import com.tencent.devops.common.event.dispatcher.pipeline.mq.Tools import org.springframework.amqp.core.Binding import org.springframework.amqp.core.BindingBuilder import org.springframework.amqp.core.DirectExchange @@ -113,17 +114,18 @@ class AuthCoreConfiguration { @Autowired refreshListener: AuthRefreshEventListener, @Autowired messageConverter: Jackson2JsonMessageConverter ): SimpleMessageListenerContainer { - val container = SimpleMessageListenerContainer(connectionFactory) - container.setQueueNames(authRefreshQueue.name) - container.setConcurrentConsumers(1) - container.setMaxConcurrentConsumers(10) - container.setAmqpAdmin(rabbitAdmin) - container.setStartConsumerMinInterval(5000) - container.setConsecutiveActiveTrigger(5) val adapter = MessageListenerAdapter(refreshListener, refreshListener::execute.name) adapter.setMessageConverter(messageConverter) - container.setMessageListener(adapter) - return container + return Tools.createSimpleMessageListenerContainerByAdapter( + connectionFactory = connectionFactory, + queue = authRefreshQueue, + rabbitAdmin = rabbitAdmin, + adapter = adapter, + startConsumerMinInterval = 5000, + consecutiveActiveTrigger = 5, + concurrency = 1, + maxConcurrency = 5 + ) } @Bean diff --git a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt index da47d338c21..9762a96d82c 100644 --- a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt +++ b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt @@ -59,7 +59,7 @@ object Tools { ): SimpleMessageListenerContainer { logger.info( "createMQListener|queue=${queue.name}|listener=${buildListener::class.java.name}|concurrency=$concurrency" + - "|max=$maxConcurrency|trigger=$consecutiveActiveTrigger|interval=$startConsumerMinInterval" + "|max=$maxConcurrency|trigger=$consecutiveActiveTrigger|interval=$startConsumerMinInterval" ) val adapter = MessageListenerAdapter(buildListener, buildListener::execute.name) adapter.setMessageConverter(messageConverter) @@ -88,9 +88,13 @@ object Tools { prefetchCount: Int = 1 ): SimpleMessageListenerContainer { val container = SimpleMessageListenerContainer(connectionFactory) - container.setQueueNames(queue.name) - container.setConcurrentConsumers(concurrency) - container.setMaxConcurrentConsumers(max(maxConcurrency, concurrency)) + container.setQueues(queue) + if (connectionFactory.virtualHost == "default-vhost") { + container.lazyLoad() + } else { + container.setConcurrentConsumers(concurrency) + container.setMaxConcurrentConsumers(max(maxConcurrency, concurrency)) + } container.setAmqpAdmin(rabbitAdmin) container.setStartConsumerMinInterval(startConsumerMinInterval) container.setConsecutiveActiveTrigger(consecutiveActiveTrigger) diff --git a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt index 381d3c56f13..ac8ce0e9249 100644 --- a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt +++ b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt @@ -28,6 +28,7 @@ package com.tencent.devops.monitoring.configuration import com.tencent.devops.common.event.dispatcher.pipeline.mq.MQ +import com.tencent.devops.common.event.dispatcher.pipeline.mq.Tools import com.tencent.devops.common.web.mq.EXTEND_CONNECTION_FACTORY_NAME import com.tencent.devops.common.web.mq.EXTEND_RABBIT_ADMIN_NAME import com.tencent.devops.monitoring.consumer.AtomMonitorReportListener @@ -44,7 +45,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Qualifier import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import java.lang.Integer.max @Configuration class ListenerConfiguration { @@ -81,16 +81,16 @@ class ListenerConfiguration { ): SimpleMessageListenerContainer { val adapter = MessageListenerAdapter(listener, listener::execute.name) adapter.setMessageConverter(messageConverter) - val container = SimpleMessageListenerContainer(connectionFactory) - container.setQueueNames(atomMonitorDataReportQueue.name) - container.setConcurrentConsumers(1) - container.setMaxConcurrentConsumers(max(10, 1)) - container.setAmqpAdmin(rabbitAdmin) - container.setStartConsumerMinInterval(5000) - container.setConsecutiveActiveTrigger(10) - container.setMismatchedQueuesFatal(true) - container.setMessageListener(adapter) - return container + return Tools.createSimpleMessageListenerContainerByAdapter( + connectionFactory = connectionFactory, + queue = atomMonitorDataReportQueue, + rabbitAdmin = rabbitAdmin, + adapter = adapter, + startConsumerMinInterval = 5000, + consecutiveActiveTrigger = 10, + concurrency = 1, + maxConcurrency = 10 + ) } companion object { diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/ProjectMQConfiguration.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/ProjectMQConfiguration.kt index bc6c46b7b3d..6d883b09ba1 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/ProjectMQConfiguration.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/ProjectMQConfiguration.kt @@ -28,6 +28,7 @@ package com.tencent.devops.project.config import com.tencent.devops.common.event.dispatcher.pipeline.mq.MQ +import com.tencent.devops.common.event.dispatcher.pipeline.mq.Tools import com.tencent.devops.project.listener.ProjectEventListener import org.springframework.amqp.core.Binding import org.springframework.amqp.core.BindingBuilder @@ -115,15 +116,18 @@ class ProjectMQConfiguration { @Autowired listener: ProjectEventListener, @Autowired messageConverter: Jackson2JsonMessageConverter ): SimpleMessageListenerContainer { - val container = SimpleMessageListenerContainer(connectionFactory) - container.setQueueNames(projectCreateQueue.name) - container.setConcurrentConsumers(5) - container.setMaxConcurrentConsumers(10) - container.setAmqpAdmin(rabbitAdmin) val adapter = MessageListenerAdapter(listener, listener::execute.name) adapter.setMessageConverter(messageConverter) - container.setMessageListener(adapter) - return container + return Tools.createSimpleMessageListenerContainerByAdapter( + connectionFactory = connectionFactory, + queue = projectCreateQueue, + rabbitAdmin = rabbitAdmin, + adapter = adapter, + startConsumerMinInterval = 1000, + consecutiveActiveTrigger = 5, + concurrency = 5, + maxConcurrency = 10 + ) } @Bean @@ -134,15 +138,18 @@ class ProjectMQConfiguration { @Autowired listener: ProjectEventListener, @Autowired messageConverter: Jackson2JsonMessageConverter ): SimpleMessageListenerContainer { - val container = SimpleMessageListenerContainer(connectionFactory) - container.setQueueNames(projectUpdateQueue.name) - container.setConcurrentConsumers(5) - container.setMaxConcurrentConsumers(10) - container.setAmqpAdmin(rabbitAdmin) val adapter = MessageListenerAdapter(listener, listener::execute.name) adapter.setMessageConverter(messageConverter) - container.setMessageListener(adapter) - return container + return Tools.createSimpleMessageListenerContainerByAdapter( + connectionFactory = connectionFactory, + queue = projectUpdateQueue, + rabbitAdmin = rabbitAdmin, + adapter = adapter, + startConsumerMinInterval = 1000, + consecutiveActiveTrigger = 5, + concurrency = 5, + maxConcurrency = 10 + ) } @Bean @@ -153,14 +160,17 @@ class ProjectMQConfiguration { @Autowired listener: ProjectEventListener, @Autowired messageConverter: Jackson2JsonMessageConverter ): SimpleMessageListenerContainer { - val container = SimpleMessageListenerContainer(connectionFactory) - container.setQueueNames(projectUpdateLogoQueue.name) - container.setConcurrentConsumers(5) - container.setMaxConcurrentConsumers(10) - container.setAmqpAdmin(rabbitAdmin) val adapter = MessageListenerAdapter(listener, listener::execute.name) adapter.setMessageConverter(messageConverter) - container.setMessageListener(adapter) - return container + return Tools.createSimpleMessageListenerContainerByAdapter( + connectionFactory = connectionFactory, + queue = projectUpdateLogoQueue, + rabbitAdmin = rabbitAdmin, + adapter = adapter, + startConsumerMinInterval = 1000, + consecutiveActiveTrigger = 5, + concurrency = 5, + maxConcurrency = 10 + ) } } From 05a8f8661aca5a93b4563dd9c47055e136d91239 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Fri, 8 Sep 2023 17:04:23 +0800 Subject: [PATCH 28/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/.gitignore | 1 + .../src/main/kotlin/plugins/task-render-template.gradle.kts | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/.gitignore b/src/backend/ci/.gitignore index 9537b7ff18d..055d199d12e 100644 --- a/src/backend/ci/.gitignore +++ b/src/backend/ci/.gitignore @@ -18,3 +18,4 @@ build.yml *.log.gz i18n/ core/mutijar/boot-mutijar/src/main/resources/application-*.yml +core/mutijar/boot-mutijar/bkenv.properties diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts index 5da1a0c7ffc..fd612c270c6 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts @@ -25,7 +25,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import java.util.Properties -import java.io.File tasks.register("replacePlaceholders") { doLast { @@ -36,7 +35,7 @@ tasks.register("replacePlaceholders") { "${File.separator}src${File.separator}backend${File.separator}ci", "" ) - val bkEnvPath = joinPath(rootDirPath, "scripts", "bkenv.properties") + val bkEnvPath = joinPath(projectDir.absolutePath, "bkenv.properties") val templatesDir = joinPath(rootDirPath, "support-files", "templates") val bkEnvProperties = loadProperties(bkEnvPath) val bkEnvFileContent = renderTemplate(bkEnvPath, bkEnvProperties) @@ -45,7 +44,7 @@ tasks.register("replacePlaceholders") { } } -tasks.register("deleteApplicationTemplate"){ +tasks.register("deleteApplicationTemplate") { val destDir = joinPath(projectDir.absolutePath, "src", "main", "resources") deleteFiles(destDir) } From d97b16a7d89ddf4aa527b5b24d40b7773f80beb9 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Fri, 8 Sep 2023 18:10:18 +0800 Subject: [PATCH 29/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-multi-boot-run.gradle.kts | 1 + .../com/tencent/devops/common/api/util/PropertyUtil.kt | 5 +++++ .../devops/common/event/dispatcher/pipeline/mq/Tools.kt | 6 ++++-- support-files/templates/#etc#ci#application-store.yml | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index d94b8a33904..15696bf2c47 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -40,6 +40,7 @@ tasks.register("multiBootRun") { systemProperty("spring.cloud.consul.enabled", "false") systemProperty("spring.cloud.consul.discovery.enabled", "false") systemProperty("server.port", "8081") + systemProperty("local.run", "true") systemProperty("service.log.dir", joinPath(projectDir.absolutePath, "log")) } dependsOn("multiBootJar") diff --git a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/PropertyUtil.kt b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/PropertyUtil.kt index b810fa6d4e1..a7558479ac4 100644 --- a/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/PropertyUtil.kt +++ b/src/backend/ci/core/common/common-api/src/main/kotlin/com/tencent/devops/common/api/util/PropertyUtil.kt @@ -72,4 +72,9 @@ object PropertyUtil { properties.load(propertyFileContent.reader()) return properties[propertyKey]?.toString() } + + /** + * 判断是否为本地运行 + */ + fun isLocalRun() = System.getProperty("local.run") == "true" } diff --git a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt index 9762a96d82c..c3c60e13010 100644 --- a/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt +++ b/src/backend/ci/core/common/common-event/src/main/kotlin/com/tencent/devops/common/event/dispatcher/pipeline/mq/Tools.kt @@ -27,6 +27,7 @@ package com.tencent.devops.common.event.dispatcher.pipeline.mq +import com.tencent.devops.common.api.util.PropertyUtil import com.tencent.devops.common.event.listener.Listener import com.tencent.devops.common.service.trace.TraceTag import org.slf4j.LoggerFactory @@ -89,16 +90,17 @@ object Tools { ): SimpleMessageListenerContainer { val container = SimpleMessageListenerContainer(connectionFactory) container.setQueues(queue) - if (connectionFactory.virtualHost == "default-vhost") { + if (PropertyUtil.isLocalRun()) { container.lazyLoad() + container.setMismatchedQueuesFatal(false) } else { container.setConcurrentConsumers(concurrency) container.setMaxConcurrentConsumers(max(maxConcurrency, concurrency)) + container.setMismatchedQueuesFatal(true) } container.setAmqpAdmin(rabbitAdmin) container.setStartConsumerMinInterval(startConsumerMinInterval) container.setConsecutiveActiveTrigger(consecutiveActiveTrigger) - container.setMismatchedQueuesFatal(true) container.setMessageListener(adapter) container.setPrefetchCount(prefetchCount) container.addAfterReceivePostProcessors(traceMessagePostProcessor) diff --git a/support-files/templates/#etc#ci#application-store.yml b/support-files/templates/#etc#ci#application-store.yml index 8cf674e868d..37171d1e982 100644 --- a/support-files/templates/#etc#ci#application-store.yml +++ b/support-files/templates/#etc#ci#application-store.yml @@ -1,7 +1,7 @@ # 服务配置文件模板 spring: datasource: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_artifactory?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION%27 + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_store?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION%27 username: __BK_CI_MYSQL_USER__ password: __BK_CI_MYSQL_PASSWORD__ From 3f6f89c57408be3151849fa93cadb807e21ef7c7 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Fri, 8 Sep 2023 21:30:03 +0800 Subject: [PATCH 30/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dispatch.sdk/config/SDKConfiguration.kt | 2 -- .../resources/ServiceRepositoryGitCheckResourceImpl.kt | 10 +++++----- .../{RepoGitCheckService.kt => GitCheckService.kt} | 2 +- ...rnalGithubResource.kt => ExternalGithubResource.kt} | 2 +- ...amExternalScmResource.kt => ExternalScmResource.kt} | 2 +- ...LoginResource.kt => ExternalStreamLoginResource.kt} | 2 +- ...rnalStreamResource.kt => ExternalStreamResource.kt} | 2 +- ...ubResourceImpl.kt => ExternalGithubResourceImpl.kt} | 8 ++++---- ...alScmResourceImpl.kt => ExternalScmResourceImpl.kt} | 8 ++++---- ...ourceImpl.kt => ExternalStreamLoginResourceImpl.kt} | 6 +++--- ...amResourceImpl.kt => ExternalStreamResourceImpl.kt} | 6 +++--- 11 files changed, 24 insertions(+), 26 deletions(-) rename src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/{RepoGitCheckService.kt => GitCheckService.kt} (96%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{StreamExternalGithubResource.kt => ExternalGithubResource.kt} (98%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{StreamExternalScmResource.kt => ExternalScmResource.kt} (98%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{StreamExternalStreamLoginResource.kt => ExternalStreamLoginResource.kt} (97%) rename src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/{StreamExternalStreamResource.kt => ExternalStreamResource.kt} (98%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{StreamExternalGithubResourceImpl.kt => ExternalGithubResourceImpl.kt} (93%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{StreamExternalScmResourceImpl.kt => ExternalScmResourceImpl.kt} (92%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{StreamExternalStreamLoginResourceImpl.kt => ExternalStreamLoginResourceImpl.kt} (91%) rename src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/{StreamExternalStreamResourceImpl.kt => ExternalStreamResourceImpl.kt} (93%) diff --git a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt index bcd3733afec..6c1421d1c6d 100644 --- a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt +++ b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/SDKConfiguration.kt @@ -86,7 +86,6 @@ class SDKConfiguration { DockerRoutingSdkService(redisOperation) @Bean - @Primary fun pipelineEventDispatcher(@Autowired rabbitTemplate: RabbitTemplate): PipelineEventDispatcher { return MQEventDispatcher(rabbitTemplate) } @@ -95,5 +94,4 @@ class SDKConfiguration { fun channelUtils( @Autowired bkTag: BkTag ) = ChannelUtils(bkTag) - } diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt index 9e270c879b3..82583120b31 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/resources/ServiceRepositoryGitCheckResourceImpl.kt @@ -5,12 +5,12 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource import com.tencent.devops.repository.api.ServiceRepositoryGitCheckResource import com.tencent.devops.repository.pojo.RepositoryGitCheck -import com.tencent.devops.repository.service.RepoGitCheckService +import com.tencent.devops.repository.service.GitCheckService import org.springframework.beans.factory.annotation.Autowired @RestResource class ServiceRepositoryGitCheckResourceImpl @Autowired constructor( - private val repoGitCheckService: RepoGitCheckService + private val gitCheckService: GitCheckService ) : ServiceRepositoryGitCheckResource { override fun getGitCheck( pipelineId: String, @@ -18,14 +18,14 @@ class ServiceRepositoryGitCheckResourceImpl @Autowired constructor( context: String, repositoryConfig: RepositoryConfig ): Result { - return Result(repoGitCheckService.getGitCheck(pipelineId, repositoryConfig, commitId, context)) + return Result(gitCheckService.getGitCheck(pipelineId, repositoryConfig, commitId, context)) } override fun createGitCheck(gitCheck: RepositoryGitCheck) { - repoGitCheckService.creatGitCheck(gitCheck) + gitCheckService.creatGitCheck(gitCheck) } override fun updateGitCheck(gitCheckId: Long, buildNumber: Int) { - repoGitCheckService.updateGitCheck(gitCheckId = gitCheckId, buildNumber = buildNumber) + gitCheckService.updateGitCheck(gitCheckId = gitCheckId, buildNumber = buildNumber) } } diff --git a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoGitCheckService.kt b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/GitCheckService.kt similarity index 96% rename from src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoGitCheckService.kt rename to src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/GitCheckService.kt index 43bdd7456e5..7ecebc342e4 100644 --- a/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/RepoGitCheckService.kt +++ b/src/backend/ci/core/repository/biz-repository/src/main/kotlin/com/tencent/devops/repository/service/GitCheckService.kt @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service -class RepoGitCheckService @Autowired constructor( +class GitCheckService @Autowired constructor( private val dslContext: DSLContext, private val gitCheckDao: GitCheckDao ) { diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalGithubResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalGithubResource.kt similarity index 98% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalGithubResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalGithubResource.kt index 0b7bf705ec0..b3fb80aa1f9 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalGithubResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalGithubResource.kt @@ -45,7 +45,7 @@ import javax.ws.rs.core.Response @Path("/external/github/") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface StreamExternalGithubResource { +interface ExternalGithubResource { @ApiOperation("Github仓库提交") @POST diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalScmResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalScmResource.kt similarity index 98% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalScmResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalScmResource.kt index 91b7f4825a9..9a2ac6c311e 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalScmResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalScmResource.kt @@ -42,7 +42,7 @@ import javax.ws.rs.core.MediaType @Path("/service/scm") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface StreamExternalScmResource { +interface ExternalScmResource { @ApiOperation("Code平台Git仓库提交") @POST diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamLoginResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamLoginResource.kt similarity index 97% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamLoginResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamLoginResource.kt index e7ef106f719..4fe10d6225b 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamLoginResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamLoginResource.kt @@ -43,7 +43,7 @@ import javax.ws.rs.core.MediaType @Path("/external/stream/login") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface StreamExternalStreamLoginResource { +interface ExternalStreamLoginResource { @ApiOperation("获取登录url") @GET diff --git a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamResource.kt b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamResource.kt similarity index 98% rename from src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamResource.kt rename to src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamResource.kt index a72a94ee7d5..e493bf539bd 100644 --- a/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/StreamExternalStreamResource.kt +++ b/src/backend/ci/core/stream/api-stream/src/main/kotlin/com/tencent/devops/stream/api/external/ExternalStreamResource.kt @@ -42,7 +42,7 @@ import javax.ws.rs.core.MediaType @Path("/external/stream") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) -interface StreamExternalStreamResource { +interface ExternalStreamResource { @ApiOperation("获取流水线徽章") @Produces("image/svg+xml") diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalGithubResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalGithubResourceImpl.kt similarity index 93% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalGithubResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalGithubResourceImpl.kt index 3911966e570..178ec1d1190 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalGithubResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalGithubResourceImpl.kt @@ -32,7 +32,7 @@ import com.tencent.devops.common.api.enums.ScmType import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.api.util.ShaUtils import com.tencent.devops.common.web.RestResource -import com.tencent.devops.stream.api.external.StreamExternalGithubResource +import com.tencent.devops.stream.api.external.ExternalGithubResource import com.tencent.devops.stream.config.StreamGitConfig import com.tencent.devops.stream.service.StreamLoginService import com.tencent.devops.stream.trigger.mq.streamRequest.StreamRequestDispatcher @@ -44,14 +44,14 @@ import javax.ws.rs.core.Response import javax.ws.rs.core.UriBuilder @RestResource -class StreamExternalGithubResourceImpl @Autowired constructor( +class ExternalGithubResourceImpl @Autowired constructor( private val streamLoginService: StreamLoginService, private val streamGitConfig: StreamGitConfig, private val rabbitTemplate: RabbitTemplate -) : StreamExternalGithubResource { +) : ExternalGithubResource { companion object { - private val logger = LoggerFactory.getLogger(StreamExternalGithubResourceImpl::class.java) + private val logger = LoggerFactory.getLogger(ExternalGithubResourceImpl::class.java) } override fun webhookCommit(event: String, guid: String, signature: String, body: String): Result { diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalScmResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalScmResourceImpl.kt similarity index 92% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalScmResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalScmResourceImpl.kt index 561632fb0af..25214ae240d 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalScmResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalScmResourceImpl.kt @@ -35,7 +35,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.api.util.JsonUtil import com.tencent.devops.common.web.RestResource import com.tencent.devops.common.webhook.pojo.code.git.GitReviewEvent -import com.tencent.devops.stream.api.external.StreamExternalScmResource +import com.tencent.devops.stream.api.external.ExternalScmResource import com.tencent.devops.stream.trigger.mq.streamRequest.StreamRequestDispatcher import com.tencent.devops.stream.trigger.mq.streamRequest.StreamRequestEvent import org.slf4j.LoggerFactory @@ -43,13 +43,13 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate import org.springframework.beans.factory.annotation.Autowired @RestResource -class StreamExternalScmResourceImpl @Autowired constructor( +class ExternalScmResourceImpl @Autowired constructor( private val objectMapper: ObjectMapper, private val rabbitTemplate: RabbitTemplate -) : StreamExternalScmResource { +) : ExternalScmResource { companion object { - private val logger = LoggerFactory.getLogger(StreamExternalScmResourceImpl::class.java) + private val logger = LoggerFactory.getLogger(ExternalScmResourceImpl::class.java) } override fun webHookCodeGitCommit(token: String, eventType: String, event: String): Result { diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamLoginResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamLoginResourceImpl.kt similarity index 91% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamLoginResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamLoginResourceImpl.kt index 9fae126b848..870ed597d41 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamLoginResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamLoginResourceImpl.kt @@ -30,14 +30,14 @@ package com.tencent.devops.stream.resources.external import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource -import com.tencent.devops.stream.api.external.StreamExternalStreamLoginResource +import com.tencent.devops.stream.api.external.ExternalStreamLoginResource import com.tencent.devops.stream.service.StreamLoginService import org.springframework.beans.factory.annotation.Autowired @RestResource -class StreamExternalStreamLoginResourceImpl @Autowired constructor( +class ExternalStreamLoginResourceImpl @Autowired constructor( private val streamLoginService: StreamLoginService -) : StreamExternalStreamLoginResource { +) : ExternalStreamLoginResource { override fun loginUrl(type: String): Result { return Result(streamLoginService.loginUrl(type)) diff --git a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamResourceImpl.kt b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamResourceImpl.kt similarity index 93% rename from src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamResourceImpl.kt rename to src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamResourceImpl.kt index 62eb3ce91fd..bff09310f0b 100644 --- a/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/StreamExternalStreamResourceImpl.kt +++ b/src/backend/ci/core/stream/biz-stream/src/main/kotlin/com/tencent/devops/stream/resources/external/ExternalStreamResourceImpl.kt @@ -28,13 +28,13 @@ package com.tencent.devops.stream.resources.external import com.tencent.devops.common.web.RestResource -import com.tencent.devops.stream.api.external.StreamExternalStreamResource +import com.tencent.devops.stream.api.external.ExternalStreamResource import com.tencent.devops.stream.service.StreamPipelineBadgeService @RestResource -class StreamExternalStreamResourceImpl( +class ExternalStreamResourceImpl( private val streamPipelineBadgeService: StreamPipelineBadgeService -) : StreamExternalStreamResource { +) : ExternalStreamResource { override fun getPipelineBadge( gitProjectId: Long, filePath: String, From 70dd2b53575ab377b353bfb236e132053e1e22a1 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Fri, 8 Sep 2023 21:49:28 +0800 Subject: [PATCH 31/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/plugins/task-multi-boot-jar.gradle.kts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 793f9845bc8..5069201b9b6 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -35,12 +35,11 @@ tasks.register("multiBootJar") { } fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { - // 由于store微服务下的有些项目名称包含image,在打包image时会把store给误打包,故在打包image时,把store服务剔除 - return if (path.contains("image") && path.contains("store")) { - false + // store服务存在子模块 biz-store-image,该模块会单独在打包image服务时,误打包 + return if (path.contains("biz") && path.contains("image") && path.contains("store")) { + multiModuleList.contains("store") } else { - path.contains("biz") - && multiModuleList.any { module -> path.contains(module) } + path.contains("biz") && multiModuleList.any { module -> path.contains(module) } } } From ea6207c905459305a87371b4fc3f0dde03d17843 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Fri, 8 Sep 2023 23:06:48 +0800 Subject: [PATCH 32/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/.gitignore b/src/backend/ci/.gitignore index 055d199d12e..2b931b881ea 100644 --- a/src/backend/ci/.gitignore +++ b/src/backend/ci/.gitignore @@ -17,5 +17,5 @@ build.yml .codecc *.log.gz i18n/ -core/mutijar/boot-mutijar/src/main/resources/application-*.yml -core/mutijar/boot-mutijar/bkenv.properties +core/multijar/boot-multijar/src/main/resources/application-*.yml +core/multijar/boot-multijar/bkenv.properties From ee229770caf9364928e9d0714c8e499cc3fb59c1 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Fri, 8 Sep 2023 23:12:01 +0800 Subject: [PATCH 33/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/misc/config/JooqConfiguration.kt | 2 +- .../boot-multijar}/build.gradle.kts | 0 .../devops/multijar}/DataSourceDefinitionRegistrar.kt | 5 +---- .../com/tencent/devops/multijar}/JooqDefinitionRegistrar.kt | 3 +-- .../com/tencent/devops/multijar/MultijarApplication.kt} | 2 +- .../devops/multijar/MultijarDslContextConfiguration.kt} | 6 ++---- .../boot-multijar}/src/main/resources/application.yml | 6 +++--- src/backend/ci/core/{mutijar => multijar}/build.gradle.kts | 2 +- src/backend/ci/settings.gradle.kts | 4 ++-- 9 files changed, 12 insertions(+), 18 deletions(-) rename src/backend/ci/core/{mutijar/boot-mutijar => multijar/boot-multijar}/build.gradle.kts (100%) rename src/backend/ci/core/{mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar => multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar}/DataSourceDefinitionRegistrar.kt (95%) rename src/backend/ci/core/{mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar => multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar}/JooqDefinitionRegistrar.kt (97%) rename src/backend/ci/core/{mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt => multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt} (98%) rename src/backend/ci/core/{mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt => multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt} (96%) rename src/backend/ci/core/{mutijar/boot-mutijar => multijar/boot-multijar}/src/main/resources/application.yml (83%) rename src/backend/ci/core/{mutijar => multijar}/build.gradle.kts (96%) diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt index 0ee046bdc7b..b67142b17c5 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/JooqConfiguration.kt @@ -56,7 +56,7 @@ import javax.sql.DataSource */ @Configuration @Import(DataSourceConfig::class, DBBaseConfiguration::class) -@ConditionalOnMissingClass("com.tencent.devops.mutijar.MutijarDslContextConfiguration") +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") @AutoConfigureAfter(DBBaseConfiguration::class) class JooqConfiguration { diff --git a/src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts similarity index 100% rename from src/backend/ci/core/mutijar/boot-mutijar/build.gradle.kts rename to src/backend/ci/core/multijar/boot-multijar/build.gradle.kts diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt similarity index 95% rename from src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt rename to src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt index 1c6c848cb3a..47ddf72902d 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -1,7 +1,6 @@ -package com.tencent.devops.mutijar +package com.tencent.devops.multijar import com.mysql.jdbc.Driver -import com.tencent.devops.common.web.jasypt.DefaultEncryptor import com.zaxxer.hikari.HikariDataSource import org.slf4j.LoggerFactory import org.springframework.beans.factory.config.YamlPropertiesFactoryBean @@ -12,11 +11,9 @@ import org.springframework.boot.autoconfigure.AutoConfigureOrder import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.ImportBeanDefinitionRegistrar import org.springframework.core.Ordered -import org.springframework.core.env.Environment import org.springframework.core.io.ClassPathResource import org.springframework.core.type.AnnotationMetadata import org.springframework.transaction.annotation.EnableTransactionManagement -import java.util.Properties @Configuration diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt similarity index 97% rename from src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt rename to src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt index 33ceb828a5c..375877a79f6 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt @@ -1,11 +1,10 @@ -package com.tencent.devops.mutijar +package com.tencent.devops.multijar import com.tencent.devops.common.db.listener.BkJooqExecuteListener import org.jooq.SQLDialect import org.jooq.impl.DataSourceConnectionProvider import org.jooq.impl.DefaultConfiguration import org.jooq.impl.DefaultExecuteListenerProvider -import org.slf4j.LoggerFactory import org.springframework.beans.factory.support.BeanDefinitionBuilder import org.springframework.beans.factory.support.BeanDefinitionRegistry import org.springframework.beans.factory.support.BeanNameGenerator diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt similarity index 98% rename from src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt rename to src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt index fd3dbeced32..0dd7dc85295 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarApplication.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.devops.mutijar +package com.tencent.devops.multijar import com.tencent.devops.common.service.MicroService import com.tencent.devops.common.service.MicroServiceApplication diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt similarity index 96% rename from src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt rename to src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt index a7816beff06..e1440abe441 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/kotlin/com/tencent/devops/mutijar/MutijarDslContextConfiguration.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt @@ -24,13 +24,12 @@ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.devops.mutijar +package com.tencent.devops.multijar import com.tencent.devops.common.db.config.DBBaseConfiguration import org.jooq.DSLContext import org.jooq.impl.DSL import org.jooq.impl.DefaultConfiguration -import org.slf4j.LoggerFactory import org.springframework.beans.factory.InjectionPoint import org.springframework.beans.factory.NoSuchBeanDefinitionException import org.springframework.beans.factory.config.ConfigurableBeanFactory @@ -43,7 +42,6 @@ import java.lang.reflect.AnnotatedElement import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Method -import java.lang.reflect.Parameter /** * @@ -51,7 +49,7 @@ import java.lang.reflect.Parameter */ @Configuration @Import(DBBaseConfiguration::class, DataSourceDefinitionRegistrar::class, JooqDefinitionRegistrar::class) -class MutijarDslContextConfiguration { +class MultijarDslContextConfiguration { @Bean @Primary @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) diff --git a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml similarity index 83% rename from src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml rename to src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml index 784630be524..d2acda23cee 100644 --- a/src/backend/ci/core/mutijar/boot-mutijar/src/main/resources/application.yml +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml @@ -27,7 +27,7 @@ spring: - store - quality application: - name: mutijar - desc: DevOps MUTIJAR Service + name: multijar + desc: DevOps MULTIJAR Service version: 4.0.0 - packageName: com.tencent.devops.mutijar + packageName: com.tencent.devops.multijar diff --git a/src/backend/ci/core/mutijar/build.gradle.kts b/src/backend/ci/core/multijar/build.gradle.kts similarity index 96% rename from src/backend/ci/core/mutijar/build.gradle.kts rename to src/backend/ci/core/multijar/build.gradle.kts index 1216a155ec6..81207f18ecc 100644 --- a/src/backend/ci/core/mutijar/build.gradle.kts +++ b/src/backend/ci/core/multijar/build.gradle.kts @@ -26,5 +26,5 @@ */ subprojects { - group = "com.tencent.bk.devops.ci.mutijar" + group = "com.tencent.bk.devops.ci.multijar" } diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index 61aa2ef5016..94b6c8a0c78 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -268,5 +268,5 @@ include(":core:metrics:biz-metrics-sample") include(":core:metrics:boot-metrics") include(":core:metrics:model-metrics") -include("core:mutijar") -include("core:mutijar:boot-mutijar") +include("core:multijar") +include("core:multijar:boot-multijar") From f61e2cd0a8e4060f85f98dcd6f08cfa18bf2aa71 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Mon, 11 Sep 2023 15:25:37 +0800 Subject: [PATCH 34/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-render-template.gradle.kts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts index fd612c270c6..9cb67bdd901 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts @@ -35,11 +35,23 @@ tasks.register("replacePlaceholders") { "${File.separator}src${File.separator}backend${File.separator}ci", "" ) + + // 基础变量 + val baseBkEnvPath = joinPath(rootDirPath, "scripts", "bkenv.properties") + val bkEnvProperties = loadProperties(baseBkEnvPath) + val bkEnvFileContent = renderTemplate(baseBkEnvPath, bkEnvProperties) + bkEnvProperties.load(bkEnvFileContent.byteInputStream()) + + // 自定义变量 val bkEnvPath = joinPath(projectDir.absolutePath, "bkenv.properties") + file(bkEnvPath).let { + if (it.exists()) { + bkEnvProperties.load(it.inputStream()) + } + } + + // 渲染模板 val templatesDir = joinPath(rootDirPath, "support-files", "templates") - val bkEnvProperties = loadProperties(bkEnvPath) - val bkEnvFileContent = renderTemplate(bkEnvPath, bkEnvProperties) - bkEnvProperties.load(bkEnvFileContent.byteInputStream()) generateFiles(templatesDir, destDir, bkEnvProperties) } } @@ -58,9 +70,9 @@ fun deleteFiles(dir: String) { } } -fun loadProperties(path: String): Properties { +fun loadProperties(basePath: String): Properties { val properties = Properties() - properties.load(file(path).inputStream()) + properties.load(file(basePath).inputStream()) return properties } From 7dbe035ed68b6465ab2e2906eac501833d71c1d3 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Mon, 11 Sep 2023 20:40:36 +0800 Subject: [PATCH 35/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bkenv.properties | 4 ++++ src/gateway/core/lua/router_srv.lua | 7 +++++++ support-files/templates/gateway#core#lua#init.lua | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index c5c13fe5960..6de66013b09 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -215,6 +215,10 @@ BK_CI_KUBERNETES_CPU=8 BK_CI_KUBERNETES_MEMORY=16048 # BK_CI_KUBERNETES_WEBCONSOLE_PROXY无默认值,KUBERNETES登录调试代理地址,按需修改 BK_CI_KUBERNETES_WEBCONSOLE_PROXY= +# BK_CI_LOCAL_RUN_ENABLED +BK_CI_LOCAL_RUN_ENABLED=false +# BK_CI_LOCAL_RUN_TARGET +BK_CI_LOCAL_RUN_TARGET= ########## # 3-微服务配置 diff --git a/src/gateway/core/lua/router_srv.lua b/src/gateway/core/lua/router_srv.lua index 89e81ea8fe8..4a0d64b71a8 100644 --- a/src/gateway/core/lua/router_srv.lua +++ b/src/gateway/core/lua/router_srv.lua @@ -15,6 +15,13 @@ -- NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +-- 本地运行 +if config.local_run and config.local_run.enabled == true then + ngx.var.target = config.local_run.target + return +end + -- 获取服务名称 local service_name = ngx.var.service if config.service_name ~= nil and config.service_name ~= "" then diff --git a/support-files/templates/gateway#core#lua#init.lua b/support-files/templates/gateway#core#lua#init.lua index 2cab793af03..602451d8162 100644 --- a/support-files/templates/gateway#core#lua#init.lua +++ b/support-files/templates/gateway#core#lua#init.lua @@ -48,6 +48,10 @@ config = { suffix = "-__BK_CI_CONSUL_DISCOVERY_TAG__", nodes_url = "/v1/catalog/nodes" }, + local_run = { + enabled = __BK_CI_LOCAL_RUN_ENABLED__, + target = "__BK_CI_LOCAL_RUN_TARGET__" + }, paasCIDomain = "__BK_CI_PAASCI_FQDN__", job = {domain = "__BK_CI_JOB_FQDN__"}, redis = { From 205e53f3b640281fe04337a33d8afc15500c4a09 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Tue, 12 Sep 2023 20:11:44 +0800 Subject: [PATCH 36/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bkenv.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index 6de66013b09..1473b54c24c 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -218,7 +218,7 @@ BK_CI_KUBERNETES_WEBCONSOLE_PROXY= # BK_CI_LOCAL_RUN_ENABLED BK_CI_LOCAL_RUN_ENABLED=false # BK_CI_LOCAL_RUN_TARGET -BK_CI_LOCAL_RUN_TARGET= +BK_CI_LOCAL_RUN_TARGET=host.docker.internal:8081 ########## # 3-微服务配置 @@ -298,7 +298,7 @@ BK_CI_PROJECT_ROUTER_TAG=$BK_CI_CONSUL_DISCOVERY_TAG # BK_CI_STREAM_URL stream独立页面地址 BK_CI_STREAM_URL= # BK_CI_GIT_GITHUB_URL stream当前对接的Git源的类型如 CODE_GIT GITHUB 等,参考代码中的ScmType -BK_CI_STREAM_SCM_TYPE= CODE_GIT +BK_CI_STREAM_SCM_TYPE=CODE_GIT # BK_CI_GIT_GITCODE_URL stream跳转时用到的git url地址 BK_CI_STREAM_GIT_URL= # BK_CI_STREAM_REPORT_PREFIX stream展示报告时的前置链接 From 0dc76b2933437460fe55bf57e0a65c7f2d433615 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Thu, 14 Sep 2023 20:29:28 +0800 Subject: [PATCH 37/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-charts/core/ci/base/default_env.yaml | 3 +++ scripts/bkenv.properties | 2 ++ src/gateway/core/lua/util/tag_util.lua | 2 +- support-files/templates/gateway#core#lua#init.lua | 3 ++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/helm-charts/core/ci/base/default_env.yaml b/helm-charts/core/ci/base/default_env.yaml index e80e7d322e8..b4a1a947711 100644 --- a/helm-charts/core/ci/base/default_env.yaml +++ b/helm-charts/core/ci/base/default_env.yaml @@ -46,3 +46,6 @@ bkCiEsHttps: false bkCiDefaultLocale: zh_CN bkCiSupportLanguages: zh_CN,en_US bkEsbEnabled: false +bkCiLocalRunEnabled: false +bkCiLocalRunTarget: host.docker.internal:8081 +bkCiUseDefaultTag: false diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index 1473b54c24c..ecf25cca64b 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -219,6 +219,8 @@ BK_CI_KUBERNETES_WEBCONSOLE_PROXY= BK_CI_LOCAL_RUN_ENABLED=false # BK_CI_LOCAL_RUN_TARGET BK_CI_LOCAL_RUN_TARGET=host.docker.internal:8081 +# BK_CI_DEFAULT_TAG +BK_CI_USE_DEFAULT_TAG=false ########## # 3-微服务配置 diff --git a/src/gateway/core/lua/util/tag_util.lua b/src/gateway/core/lua/util/tag_util.lua index 26dd4451d44..4b5525b13cb 100644 --- a/src/gateway/core/lua/util/tag_util.lua +++ b/src/gateway/core/lua/util/tag_util.lua @@ -18,7 +18,7 @@ _M = {} -- 判断当前请求属于哪个tag function _M:get_tag(ns_config) - if ngx.var.use_default_tag == 'true' then + if ngx.var.use_default_tag == 'true' or ns_config.use_default_tag then return ns_config.tag end diff --git a/support-files/templates/gateway#core#lua#init.lua b/support-files/templates/gateway#core#lua#init.lua index 602451d8162..e8e618834ca 100644 --- a/support-files/templates/gateway#core#lua#init.lua +++ b/support-files/templates/gateway#core#lua#init.lua @@ -37,7 +37,8 @@ config = { domain = "__BK_CI_CONSUL_DOMAIN__", tag = "__BK_CI_CONSUL_DISCOVERY_TAG__", suffix = "-__BK_CI_CONSUL_DISCOVERY_TAG__", - nodes_url = "/v1/catalog/nodes" + nodes_url = "/v1/catalog/nodes", + use_default_tag=__BK_CI_USE_DEFAULT_TAG__ }, ns_devnet = { ip = {"__BK_CI_CONSUL_DEVNET_IP__"}, From 07f8c407add3bc674d19b2093a95fb1dc3a140cf Mon Sep 17 00:00:00 2001 From: greysonfang Date: Sun, 8 Oct 2023 16:05:44 +0800 Subject: [PATCH 38/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../devops/buildless/ContainerPoolExecutor.kt | 14 +++++++------- ...lessScheduleConfig.kt => ScheduleConfig.kt} | 2 +- .../devops/buildless/rejected/JumpPolicy.kt | 6 +++--- .../schedule/ContainerPoolSchedule.kt | 10 +++++----- ...SystemInfoRunner.kt => SystemInfoRunner.kt} | 2 +- .../service/BuildLessContainerService.kt | 18 +++++++++--------- .../buildless/service/BuildLessTaskService.kt | 14 +++++++------- .../{BuildlessRedisUtils.kt => RedisUtils.kt} | 4 ++-- ...tResource.kt => BuildDockerHostResource.kt} | 2 +- ...esource.kt => ServiceDockerHostResource.kt} | 2 +- ...eImpl.kt => BuildDockerHostResourceImpl.kt} | 18 +++++++++--------- .../controller/OpDockerBuildResourceImpl.kt | 6 +++--- ...mpl.kt => ServiceDockerHostResourceImpl.kt} | 14 +++++++------- .../controller/UserDockerHostResourceImpl.kt | 8 ++++---- .../docker/listener/DockerVMListener.kt | 6 +++--- ...ildService.kt => DockerHostBuildService.kt} | 4 ++-- ...SystemInfoRunner.kt => SystemInfoRunner.kt} | 2 +- .../apigw/v4/ApigwDispatchResourceV4Impl.kt | 4 ++-- 18 files changed, 68 insertions(+), 68 deletions(-) rename src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/{BuildlessScheduleConfig.kt => ScheduleConfig.kt} (93%) rename src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/{BuildlessSystemInfoRunner.kt => SystemInfoRunner.kt} (98%) rename src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/{BuildlessRedisUtils.kt => RedisUtils.kt} (97%) rename src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/{DispatchBuildDockerHostResource.kt => BuildDockerHostResource.kt} (99%) rename src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/{ServiceDispatchDockerHostResource.kt => ServiceDockerHostResource.kt} (98%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/{DispatchBuildDockerHostResourceImpl.kt => BuildDockerHostResourceImpl.kt} (82%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/{ServiceDispatchDockerHostResourceImpl.kt => ServiceDockerHostResourceImpl.kt} (87%) rename src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/{DispatchDockerHostBuildService.kt => DockerHostBuildService.kt} (98%) rename src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/{DockerhostSystemInfoRunner.kt => SystemInfoRunner.kt} (98%) diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt index dee6392e560..61cabcca441 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/ContainerPoolExecutor.kt @@ -10,7 +10,7 @@ import com.tencent.devops.buildless.pojo.RejectedExecutionType import com.tencent.devops.buildless.rejected.RejectedExecutionFactory import com.tencent.devops.buildless.service.BuildLessContainerService import com.tencent.devops.buildless.utils.CommonUtils -import com.tencent.devops.buildless.utils.BuildlessRedisUtils +import com.tencent.devops.buildless.utils.RedisUtils import com.tencent.devops.buildless.utils.ThreadPoolName import com.tencent.devops.buildless.utils.ThreadPoolUtils import org.slf4j.LoggerFactory @@ -22,7 +22,7 @@ import java.util.concurrent.locks.ReentrantLock @Component class ContainerPoolExecutor @Autowired constructor( - private val buildlessRedisUtils: BuildlessRedisUtils, + private val redisUtils: RedisUtils, private val buildLessConfig: BuildLessConfig, private val rejectedExecutionFactory: RejectedExecutionFactory, private val buildLessContainerService: BuildLessContainerService @@ -35,7 +35,7 @@ class ContainerPoolExecutor @Autowired constructor( } logger.info("$buildId|$vmSeqId|$executionCount left push buildLessReadyTask") - buildlessRedisUtils.leftPushBuildLessReadyTask( + redisUtils.leftPushBuildLessReadyTask( BuildLessTask( projectId = projectId, pipelineId = pipelineId, @@ -85,7 +85,7 @@ class ContainerPoolExecutor @Autowired constructor( fun getContainerStatus(containerId: String): BuildLessPoolInfo? { synchronized(containerId.intern()) { - return buildlessRedisUtils.getBuildLessPoolContainer(containerId) + return redisUtils.getBuildLessPoolContainer(containerId) } } @@ -124,7 +124,7 @@ class ContainerPoolExecutor @Autowired constructor( } retry@ while (true) { - val idlePoolSize = buildlessRedisUtils.getIdlePoolSize() + val idlePoolSize = redisUtils.getIdlePoolSize() // 无空闲容器时执行拒绝策略 logger.info("${buildLessStartInfo.buildId}|${buildLessStartInfo.vmSeqId} idlePoolSize: $idlePoolSize") @@ -135,10 +135,10 @@ class ContainerPoolExecutor @Autowired constructor( } // 再次check idlePoolSize,有变更则retry - if (idlePoolSize != buildlessRedisUtils.getIdlePoolSize()) continue@retry + if (idlePoolSize != redisUtils.getIdlePoolSize()) continue@retry // 已经进入需求池,资源池减1 - buildlessRedisUtils.increIdlePool(-1) + redisUtils.increIdlePool(-1) return false } } finally { diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/BuildlessScheduleConfig.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/ScheduleConfig.kt similarity index 93% rename from src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/BuildlessScheduleConfig.kt rename to src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/ScheduleConfig.kt index 479c3c4900e..e5693b73a46 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/BuildlessScheduleConfig.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/config/ScheduleConfig.kt @@ -8,7 +8,7 @@ import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit @Configuration -class BuildlessScheduleConfig : SchedulingConfigurer { +class ScheduleConfig : SchedulingConfigurer { override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar) { val scheduler = ScheduledThreadPoolExecutor(5) scheduler.maximumPoolSize = 5 diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt index ba8dc803c43..cab0aeda40e 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/rejected/JumpPolicy.kt @@ -29,19 +29,19 @@ package com.tencent.devops.buildless.rejected import com.tencent.devops.buildless.pojo.BuildLessStartInfo import com.tencent.devops.buildless.pojo.BuildLessTask -import com.tencent.devops.buildless.utils.BuildlessRedisUtils +import com.tencent.devops.buildless.utils.RedisUtils import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service class JumpPolicy @Autowired constructor( - private val buildlessRedisUtils: BuildlessRedisUtils + private val redisUtils: RedisUtils ) : RejectedExecutionHandler { override fun rejectedExecution(buildLessStartInfo: BuildLessStartInfo): Boolean { with(buildLessStartInfo) { logger.info("$buildId|$vmSeqId|$executionCount jump allocate container.") - buildlessRedisUtils.rightPushBuildLessReadyTask( + redisUtils.rightPushBuildLessReadyTask( BuildLessTask( projectId = projectId, pipelineId = pipelineId, diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt index 640e4002ae2..d95223c1b36 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/ContainerPoolSchedule.kt @@ -28,14 +28,14 @@ package com.tencent.devops.buildless.schedule import com.tencent.devops.buildless.ContainerPoolExecutor -import com.tencent.devops.buildless.utils.BuildlessRedisUtils +import com.tencent.devops.buildless.utils.RedisUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component class ContainerPoolSchedule @Autowired constructor( - private val buildlessRedisUtils: BuildlessRedisUtils, + private val redisUtils: RedisUtils, private val containerPoolExecutor: ContainerPoolExecutor ) { /** @@ -44,9 +44,9 @@ class ContainerPoolSchedule @Autowired constructor( @Scheduled(cron = "0 0/1 * * * ?") fun execute() { // 校准空闲池大小 - if (buildlessRedisUtils.getBuildLessReadyTaskSize() == 0L) { - val idleContainerPoolSize = buildlessRedisUtils.getBuildLessPoolContainerIdle() - buildlessRedisUtils.setIdlePool(idleContainerPoolSize) + if (redisUtils.getBuildLessReadyTaskSize() == 0L) { + val idleContainerPoolSize = redisUtils.getBuildLessPoolContainerIdle() + redisUtils.setIdlePool(idleContainerPoolSize) } containerPoolExecutor.addContainer() diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/BuildlessSystemInfoRunner.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/SystemInfoRunner.kt similarity index 98% rename from src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/BuildlessSystemInfoRunner.kt rename to src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/SystemInfoRunner.kt index a2602d236f2..ada662c20ac 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/BuildlessSystemInfoRunner.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/schedule/SystemInfoRunner.kt @@ -32,7 +32,7 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component -class BuildlessSystemInfoRunner { +class SystemInfoRunner { @Scheduled(cron = "0/5 * * * * ?") fun startCollect() { diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt index 4a1f59a889a..1fc8a5dfb02 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessContainerService.kt @@ -56,7 +56,7 @@ import com.tencent.devops.buildless.utils.ENV_JOB_BUILD_TYPE import com.tencent.devops.buildless.utils.ENV_KEY_BK_TAG import com.tencent.devops.buildless.utils.ENV_KEY_GATEWAY import com.tencent.devops.buildless.utils.RandomUtil -import com.tencent.devops.buildless.utils.BuildlessRedisUtils +import com.tencent.devops.buildless.utils.RedisUtils import com.tencent.devops.common.api.util.ShaUtils import com.tencent.devops.common.service.BkTag import com.tencent.devops.common.service.config.CommonConfig @@ -76,7 +76,7 @@ import kotlin.streams.toList @Service class BuildLessContainerService( private val bkTag: BkTag, - private val buildlessRedisUtils: BuildlessRedisUtils, + private val redisUtils: RedisUtils, private val commonConfig: CommonConfig, private val buildLessConfig: BuildLessConfig ) { @@ -139,8 +139,8 @@ class BuildLessContainerService( httpDockerCli.startContainerCmd(container.id).exec() logger.info("===> created container: $container, containerName: $containerName. ") - buildlessRedisUtils.setBuildLessPoolContainer(container.id, ContainerStatus.IDLE) - buildlessRedisUtils.increIdlePool(1) + redisUtils.setBuildLessPoolContainer(container.id, ContainerStatus.IDLE) + redisUtils.increIdlePool(1) logger.info("===> buildLessPoolKey hset ${container.id} ${ContainerStatus.IDLE.name}.") } catch (e: Exception) { logger.error("===> failed to created container.", e) @@ -181,7 +181,7 @@ class BuildLessContainerService( ignored ) } finally { - buildlessRedisUtils.deleteBuildLessPoolContainer(containerId) + redisUtils.deleteBuildLessPoolContainer(containerId) } } @@ -206,10 +206,10 @@ class BuildLessContainerService( }.toList() // 不在containerIds列表内的同步删除缓存 - val buildLessPoolContainerMap = buildlessRedisUtils.getBuildLessPoolContainerList() + val buildLessPoolContainerMap = redisUtils.getBuildLessPoolContainerList() buildLessPoolContainerMap.forEach { (key, _) -> if (!containerIds.contains(key)) { - buildlessRedisUtils.deleteBuildLessPoolContainer(key) + redisUtils.deleteBuildLessPoolContainer(key) } } @@ -217,7 +217,7 @@ class BuildLessContainerService( containerIds.forEach { if (!buildLessPoolContainerMap.keys.contains(it)) { logger.info("Supplemental cache buildLessPoolKey hset $it ${ContainerStatus.IDLE.name}.") - buildlessRedisUtils.setBuildLessPoolContainer(it, ContainerStatus.IDLE) + redisUtils.setBuildLessPoolContainer(it, ContainerStatus.IDLE) } } } @@ -231,7 +231,7 @@ class BuildLessContainerService( for (container in containerInfo) { val startTime = httpDockerCli.inspectContainerCmd(container.id).exec().state.startedAt // 是否已运行超过12小时 - val buildLessPoolInfo = buildlessRedisUtils.getBuildLessPoolContainer(container.id) + val buildLessPoolInfo = redisUtils.getBuildLessPoolContainer(container.id) if (checkStartTime(startTime) && (buildLessPoolInfo == null || buildLessPoolInfo.status == ContainerStatus.IDLE)) { timeoutContainerList.add(container.id) diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt index c06db537b4f..71786bde04a 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/service/BuildLessTaskService.kt @@ -31,7 +31,7 @@ import com.tencent.devops.buildless.ContainerPoolExecutor import com.tencent.devops.buildless.client.DispatchClient import com.tencent.devops.buildless.pojo.BuildLessTask import com.tencent.devops.buildless.utils.ContainerStatus -import com.tencent.devops.buildless.utils.BuildlessRedisUtils +import com.tencent.devops.buildless.utils.RedisUtils import org.slf4j.LoggerFactory import org.springframework.scheduling.annotation.Async import org.springframework.scheduling.annotation.AsyncResult @@ -44,7 +44,7 @@ import java.util.concurrent.Future */ @Service class BuildLessTaskService( - private val buildlessRedisUtils: BuildlessRedisUtils, + private val redisUtils: RedisUtils, private val dispatchClient: DispatchClient, private val containerPoolExecutor: ContainerPoolExecutor ) { @@ -60,7 +60,7 @@ class BuildLessTaskService( return AsyncResult(buildLessPoolInfo.buildLessTask) } - val buildLessTask = buildlessRedisUtils.popBuildLessReadyTask() + val buildLessTask = redisUtils.popBuildLessReadyTask() if (buildLessTask != null) { try { logger.info("****> container: $containerId claim buildLessTask: $buildLessTask") @@ -70,14 +70,14 @@ class BuildLessTaskService( ) logger.info("****> claim task buildLessPoolKey hset $containerId ${ContainerStatus.BUSY.name}.") - buildlessRedisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) + redisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) return AsyncResult(buildLessTask) } catch (e: Exception) { // 异常时任务重新回队列 logger.info("****> container: $containerId claim buildLessTask: $buildLessTask get error, " + "retry.", e) - buildlessRedisUtils.leftPushBuildLessReadyTask(buildLessTask) + redisUtils.leftPushBuildLessReadyTask(buildLessTask) continue } @@ -105,7 +105,7 @@ class BuildLessTaskService( return } - val buildLessTask = buildlessRedisUtils.popBuildLessReadyTask() + val buildLessTask = redisUtils.popBuildLessReadyTask() if (buildLessTask != null) { logger.info("****> container: $containerId claim buildLessTask: $buildLessTask") dispatchClient.updateContainerId( @@ -114,7 +114,7 @@ class BuildLessTaskService( ) logger.info("****> claim task buildLessPoolKey hset $containerId ${ContainerStatus.BUSY.name}.") - buildlessRedisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) + redisUtils.setBuildLessPoolContainer(containerId, ContainerStatus.BUSY, buildLessTask) deferredResult.setResult(buildLessTask) return diff --git a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/BuildlessRedisUtils.kt b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/RedisUtils.kt similarity index 97% rename from src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/BuildlessRedisUtils.kt rename to src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/RedisUtils.kt index de9d6e6a550..6ef5c5b68fa 100644 --- a/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/BuildlessRedisUtils.kt +++ b/src/backend/ci/core/buildless/biz-buildless/src/main/kotlin/com/tencent/devops/buildless/utils/RedisUtils.kt @@ -36,7 +36,7 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @Component -class BuildlessRedisUtils @Autowired constructor( +class RedisUtils @Autowired constructor( private val redisOperation: RedisOperation, private val objectMapper: ObjectMapper ) { @@ -139,6 +139,6 @@ class BuildlessRedisUtils @Autowired constructor( } companion object { - private val logger = LoggerFactory.getLogger(BuildlessRedisUtils::class.java) + private val logger = LoggerFactory.getLogger(RedisUtils::class.java) } } diff --git a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/DispatchBuildDockerHostResource.kt b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/BuildDockerHostResource.kt similarity index 99% rename from src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/DispatchBuildDockerHostResource.kt rename to src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/BuildDockerHostResource.kt index b699b02ad2f..f09a2c00453 100644 --- a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/DispatchBuildDockerHostResource.kt +++ b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/builds/BuildDockerHostResource.kt @@ -47,7 +47,7 @@ import javax.ws.rs.core.MediaType @Path("/dockerhost") @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)@Suppress("ALL") -interface DispatchBuildDockerHostResource { +interface BuildDockerHostResource { @GET @Path("/resource-config/pipelines/{pipelineId}/vmSeqs/{vmSeqId}") @ApiOperation("获取蓝盾项目的docker性能配置") diff --git a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDispatchDockerHostResource.kt b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDockerHostResource.kt similarity index 98% rename from src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDispatchDockerHostResource.kt rename to src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDockerHostResource.kt index 5839a31fd75..877cce5a674 100644 --- a/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDispatchDockerHostResource.kt +++ b/src/backend/ci/core/dispatch-docker/api-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/api/service/ServiceDockerHostResource.kt @@ -54,7 +54,7 @@ import javax.ws.rs.core.MediaType @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) @ServiceInterface("dispatch-docker") // 指明接入到哪个微服务 -interface ServiceDispatchDockerHostResource { +interface ServiceDockerHostResource { @ApiOperation("获取dockerhost列表") @GET diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/DispatchBuildDockerHostResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/BuildDockerHostResourceImpl.kt similarity index 82% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/DispatchBuildDockerHostResourceImpl.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/BuildDockerHostResourceImpl.kt index f44ad442cad..17dedbbbdcc 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/DispatchBuildDockerHostResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/BuildDockerHostResourceImpl.kt @@ -29,21 +29,21 @@ package com.tencent.devops.dispatch.docker.controller import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource -import com.tencent.devops.dispatch.docker.api.builds.DispatchBuildDockerHostResource +import com.tencent.devops.dispatch.docker.api.builds.BuildDockerHostResource import com.tencent.devops.dispatch.docker.pojo.DockerIpInfoVO import com.tencent.devops.dispatch.docker.pojo.resource.DockerResourceOptionsVO import com.tencent.devops.dispatch.docker.service.DispatchDockerService -import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DockerHostBuildService import com.tencent.devops.dispatch.docker.service.DockerResourceOptionsService import com.tencent.devops.store.pojo.image.response.ImageRepoInfo import org.springframework.beans.factory.annotation.Autowired @RestResource -class DispatchBuildDockerHostResourceImpl @Autowired constructor( - private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, +class BuildDockerHostResourceImpl @Autowired constructor( + private val dockerHostBuildService: DockerHostBuildService, private val dispatchDockerService: DispatchDockerService, private val dockerResourceOptionsService: DockerResourceOptionsService -) : DispatchBuildDockerHostResource { +) : BuildDockerHostResource { override fun getResourceConfig(pipelineId: String, vmSeqId: String): Result { return Result(dockerResourceOptionsService.getDockerResourceConfig(pipelineId, vmSeqId)) @@ -55,11 +55,11 @@ class DispatchBuildDockerHostResourceImpl @Autowired constructor( vmSeqId: String, poolNo: Int ): Result> { - return Result(dispatchDockerHostBuildService.getQpcGitProjectList(projectId, buildId, vmSeqId, poolNo)) + return Result(dockerHostBuildService.getQpcGitProjectList(projectId, buildId, vmSeqId, poolNo)) } override fun log(buildId: String, red: Boolean, message: String, tag: String?, jobId: String?): Result? { - dispatchDockerHostBuildService.log(buildId, red, message, tag, jobId) + dockerHostBuildService.log(buildId, red, message, tag, jobId) return Result(0, "success") } @@ -70,12 +70,12 @@ class DispatchBuildDockerHostResourceImpl @Autowired constructor( tag: String?, jobId: String? ): Result? { - dispatchDockerHostBuildService.log(buildId, red, message, tag, jobId) + dockerHostBuildService.log(buildId, red, message, tag, jobId) return Result(0, "success") } override fun getPublicImages(): Result> { - return dispatchDockerHostBuildService.getPublicImage() + return dockerHostBuildService.getPublicImage() } override fun refresh(dockerIp: String, dockerIpInfoVO: DockerIpInfoVO): Result { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt index 000be5b4b60..8c8153657cd 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/OpDockerBuildResourceImpl.kt @@ -30,19 +30,19 @@ package com.tencent.devops.dispatch.docker.controller import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource import com.tencent.devops.dispatch.docker.api.op.OpDockerBuildResource -import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DockerHostBuildService import com.tencent.devops.dispatch.docker.service.DockerHostQpcService import org.springframework.beans.factory.annotation.Autowired @RestResource class OpDockerBuildResourceImpl @Autowired constructor( - private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, + private val dockerHostBuildService: DockerHostBuildService, private val dockerHostQpcService: DockerHostQpcService ) : OpDockerBuildResource { override fun enable(pipelineId: String, vmSeqId: Int?, enable: Boolean): Result { - dispatchDockerHostBuildService.enable(pipelineId, vmSeqId, enable) + dockerHostBuildService.enable(pipelineId, vmSeqId, enable) return Result(true) } diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDispatchDockerHostResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDockerHostResourceImpl.kt similarity index 87% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDispatchDockerHostResourceImpl.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDockerHostResourceImpl.kt index 57299a1fc2d..e447193c9ba 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDispatchDockerHostResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/ServiceDockerHostResourceImpl.kt @@ -31,22 +31,22 @@ import com.tencent.devops.common.api.exception.ParamBlankException import com.tencent.devops.common.api.pojo.Page import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.web.RestResource -import com.tencent.devops.dispatch.docker.api.service.ServiceDispatchDockerHostResource +import com.tencent.devops.dispatch.docker.api.service.ServiceDockerHostResource import com.tencent.devops.dispatch.docker.pojo.DockerHostZone import com.tencent.devops.dispatch.docker.pojo.DockerIpInfoVO import com.tencent.devops.dispatch.docker.pojo.SpecialDockerHostVO import com.tencent.devops.dispatch.docker.service.DispatchDockerService -import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DockerHostBuildService import com.tencent.devops.dispatch.docker.service.DockerHostZoneTaskService import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @RestResource@Suppress("ALL") -class ServiceDispatchDockerHostResourceImpl @Autowired constructor( - private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, +class ServiceDockerHostResourceImpl @Autowired constructor( + private val dockerHostBuildService: DockerHostBuildService, private val dispatchDockerService: DispatchDockerService, private val dockerHostZoneTaskService: DockerHostZoneTaskService -) : ServiceDispatchDockerHostResource { +) : ServiceDockerHostResource { override fun list(page: Int?, pageSize: Int?): Page { checkParams(page, pageSize) val realPage = page ?: 1 @@ -62,7 +62,7 @@ class ServiceDispatchDockerHostResourceImpl @Autowired constructor( } override fun updateContainerId(buildId: String, vmSeqId: Int, containerId: String): Result { - dispatchDockerHostBuildService.updateContainerId(buildId, vmSeqId, containerId) + dockerHostBuildService.updateContainerId(buildId, vmSeqId, containerId) return Result(true) } @@ -78,7 +78,7 @@ class ServiceDispatchDockerHostResourceImpl @Autowired constructor( } companion object { - private val logger = LoggerFactory.getLogger(ServiceDispatchDockerHostResourceImpl::class.java) + private val logger = LoggerFactory.getLogger(ServiceDockerHostResourceImpl::class.java) } fun checkParams(page: Int?, pageSize: Int?) { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt index 7489d453b36..8d029821acf 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/controller/UserDockerHostResourceImpl.kt @@ -48,7 +48,7 @@ import com.tencent.devops.dispatch.docker.dao.PipelineDockerTaskSimpleDao import com.tencent.devops.dispatch.docker.pojo.ContainerInfo import com.tencent.devops.dispatch.docker.pojo.DebugStartParam import com.tencent.devops.dispatch.docker.pojo.DockerHostLoad -import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DockerHostBuildService import com.tencent.devops.dispatch.docker.service.debug.impl.DockerHostDebugServiceImpl import com.tencent.devops.dispatch.docker.utils.DockerHostUtils import com.tencent.devops.dispatch.pojo.enums.PipelineTaskStatus @@ -60,7 +60,7 @@ import org.springframework.beans.factory.annotation.Autowired @RestResource @Suppress("ALL") class UserDockerHostResourceImpl @Autowired constructor( - private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, + private val dockerHostBuildService: DockerHostBuildService, private val dockerHostDebugService: DockerHostDebugServiceImpl, private val bkAuthPermissionApi: AuthPermissionApi, private val pipelineAuthServiceCode: PipelineAuthServiceCode, @@ -185,7 +185,7 @@ class UserDockerHostResourceImpl @Autowired constructor( ): Result? { checkPermission(userId, projectId, pipelineId, vmSeqId) - return dispatchDockerHostBuildService.getContainerInfo(buildId, vmSeqId.toInt()) + return dockerHostBuildService.getContainerInfo(buildId, vmSeqId.toInt()) } override fun getGreyWebConsoleProject(userId: String): Result> { @@ -198,7 +198,7 @@ class UserDockerHostResourceImpl @Autowired constructor( } override fun getDockerHostLoad(userId: String): Result { - return Result(dispatchDockerHostBuildService.getDockerHostLoad(userId)) + return Result(dockerHostBuildService.getDockerHostLoad(userId)) } fun checkParam(userId: String, projectId: String, pipelineId: String, vmSeqId: String) { diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt index 1981f76ab30..3b77386962a 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/listener/DockerVMListener.kt @@ -51,7 +51,7 @@ import com.tencent.devops.dispatch.docker.dao.PipelineDockerTaskSimpleDao import com.tencent.devops.dispatch.docker.exception.DockerServiceException import com.tencent.devops.dispatch.docker.pojo.Credential import com.tencent.devops.dispatch.docker.pojo.Pool -import com.tencent.devops.dispatch.docker.service.DispatchDockerHostBuildService +import com.tencent.devops.dispatch.docker.service.DockerHostBuildService import com.tencent.devops.dispatch.docker.utils.CommonUtils import com.tencent.devops.dispatch.docker.utils.DockerHostUtils import com.tencent.devops.dispatch.pojo.enums.JobQuotaVmType @@ -71,7 +71,7 @@ class DockerVMListener @Autowired constructor( private val dslContext: DSLContext, private val buildLogPrinter: BuildLogPrinter, private val defaultImageConfig: DefaultImageConfig, - private val dispatchDockerHostBuildService: DispatchDockerHostBuildService, + private val dockerHostBuildService: DockerHostBuildService, private val dockerHostClient: DockerHostClient, private val dockerHostUtils: DockerHostUtils, private val pipelineDockerTaskSimpleDao: PipelineDockerTaskSimpleDao, @@ -117,7 +117,7 @@ class DockerVMListener @Autowired constructor( val dockerRoutingType = dockerRoutingSdkService.getDockerRoutingType(event.projectId) if (dockerRoutingType == DockerRoutingType.VM) { - dispatchDockerHostBuildService.finishDockerBuild(event) + dockerHostBuildService.finishDockerBuild(event) } else { pipelineEventDispatcher.dispatch(event.copy( routeKeySuffix = DispatchRouteKeySuffix.KUBERNETES.routeKeySuffix, diff --git a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DispatchDockerHostBuildService.kt b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostBuildService.kt similarity index 98% rename from src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DispatchDockerHostBuildService.kt rename to src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostBuildService.kt index c0bba62d933..40a6f577007 100644 --- a/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DispatchDockerHostBuildService.kt +++ b/src/backend/ci/core/dispatch-docker/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/service/DockerHostBuildService.kt @@ -55,7 +55,7 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Service @Service -class DispatchDockerHostBuildService @Autowired constructor( +class DockerHostBuildService @Autowired constructor( private val dslContext: DSLContext, private val dockerHostClient: DockerHostClient, private val pipelineDockerEnableDao: PipelineDockerEnableDao, @@ -349,6 +349,6 @@ class DispatchDockerHostBuildService @Autowired constructor( } companion object { - private val LOG = LoggerFactory.getLogger(DispatchDockerHostBuildService::class.java) + private val LOG = LoggerFactory.getLogger(DockerHostBuildService::class.java) } } diff --git a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/DockerhostSystemInfoRunner.kt b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/SystemInfoRunner.kt similarity index 98% rename from src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/DockerhostSystemInfoRunner.kt rename to src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/SystemInfoRunner.kt index b31d7c15748..d7f9073052e 100644 --- a/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/DockerhostSystemInfoRunner.kt +++ b/src/backend/ci/core/dockerhost/biz-dockerhost/src/main/kotlin/com/tencent/devops/dockerhost/cron/SystemInfoRunner.kt @@ -32,7 +32,7 @@ import org.springframework.scheduling.annotation.Scheduled import org.springframework.stereotype.Component @Component -class DockerhostSystemInfoRunner { +class SystemInfoRunner { @Scheduled(cron = "0/5 * * * * ?") fun startCollect() { diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt index aa78521df8c..87f6e4316c5 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwDispatchResourceV4Impl.kt @@ -29,7 +29,7 @@ package com.tencent.devops.openapi.resources.apigw.v4 import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client import com.tencent.devops.common.web.RestResource -import com.tencent.devops.dispatch.docker.api.service.ServiceDispatchDockerHostResource +import com.tencent.devops.dispatch.docker.api.service.ServiceDockerHostResource import com.tencent.devops.dispatch.docker.pojo.SpecialDockerHostVO import com.tencent.devops.openapi.api.apigw.v4.ApigwDispatchResourceV4 import org.slf4j.LoggerFactory @@ -47,7 +47,7 @@ class ApigwDispatchResourceV4Impl @Autowired constructor( specialDockerHostVOs: List ): Result { logger.info("OPENAPI_DISPATCH_V4|$userId|create special docker host|$specialDockerHostVOs") - client.get(ServiceDispatchDockerHostResource::class).createSpecialDockerHost( + client.get(ServiceDockerHostResource::class).createSpecialDockerHost( userId = userId, specialDockerHostVOs = specialDockerHostVOs ) From 16a74dcf6a550603424b365d6ec866b6f0f861b5 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 9 Oct 2023 10:13:53 +0800 Subject: [PATCH 39/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../boot-multijar/src/main/resources/application.yml | 6 +----- .../apigw/v4/ApigwArtifactoryFileTaskResourceV4Impl.kt | 6 +++--- .../resources/apigw/v4/ApigwArtifactoryResourceV4Impl.kt | 6 +++--- .../openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt | 6 +++--- .../openapi/resources/apigw/v4/ApigwLogResourceV4Impl.kt | 6 +++--- .../apigw/v4/ApigwRepositoryCommitResourceV4Impl.kt | 6 +++--- .../service/{IndexService.kt => OpenApiIndexService.kt} | 2 +- 7 files changed, 17 insertions(+), 21 deletions(-) rename src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/{IndexService.kt => OpenApiIndexService.kt} (98%) diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml index d2acda23cee..ed2a660cc76 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml @@ -15,17 +15,13 @@ spring: - dispatch-docker - dispatch-kubernetes - artifactory - - buildless - - dockerhost - - metrics - - monitoring - plugin - - stream - worker - websocket - misc - store - quality + - log application: name: multijar desc: DevOps MULTIJAR Service diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryFileTaskResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryFileTaskResourceV4Impl.kt index 6e9335a8e70..aaa1c0bed2b 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryFileTaskResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryFileTaskResourceV4Impl.kt @@ -35,7 +35,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v4.ApigwArtifactoryFileTaskResourceV4 -import com.tencent.devops.openapi.service.IndexService +import com.tencent.devops.openapi.service.OpenApiIndexService import com.tencent.devops.process.api.service.ServiceBuildResource import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -43,7 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired @RestResource class ApigwArtifactoryFileTaskResourceV4Impl @Autowired constructor( private val client: Client, - private val indexService: IndexService + private val openApiIndexService: OpenApiIndexService ) : ApigwArtifactoryFileTaskResourceV4 { override fun createFileTask( userId: String, @@ -99,7 +99,7 @@ class ApigwArtifactoryFileTaskResourceV4Impl @Autowired constructor( } private fun checkPipelineId(projectId: String, pipelineId: String?, buildId: String): String { - val pipelineIdFormDB = indexService.getHandle(buildId) { + val pipelineIdFormDB = openApiIndexService.getHandle(buildId) { kotlin.runCatching { client.get(ServiceBuildResource::class).getPipelineIdFromBuildId(projectId, buildId).data }.getOrElse { diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryResourceV4Impl.kt index 2917e2e336c..55ae4670d57 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwArtifactoryResourceV4Impl.kt @@ -39,7 +39,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v4.ApigwArtifactoryResourceV4 -import com.tencent.devops.openapi.service.IndexService +import com.tencent.devops.openapi.service.OpenApiIndexService import com.tencent.devops.process.api.service.ServiceBuildResource import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -48,7 +48,7 @@ import org.springframework.beans.factory.annotation.Autowired @Suppress("UNUSED") class ApigwArtifactoryResourceV4Impl @Autowired constructor( private val client: Client, - private val indexService: IndexService + private val openApiIndexService: OpenApiIndexService ) : ApigwArtifactoryResourceV4 { override fun getUserDownloadUrl( @@ -163,7 +163,7 @@ class ApigwArtifactoryResourceV4Impl @Autowired constructor( } private fun checkPipelineId(projectId: String, pipelineId: String?, buildId: String): String { - val pipelineIdFormDB = indexService.getHandle(buildId) { + val pipelineIdFormDB = openApiIndexService.getHandle(buildId) { kotlin.runCatching { client.get(ServiceBuildResource::class).getPipelineIdFromBuildId(projectId, buildId).data }.getOrElse { diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt index 975e2a9b24c..1dbcf0903e5 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwBuildResourceV4Impl.kt @@ -38,7 +38,7 @@ import com.tencent.devops.common.pipeline.pojo.BuildFormValue import com.tencent.devops.common.pipeline.pojo.StageReviewRequest import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v4.ApigwBuildResourceV4 -import com.tencent.devops.openapi.service.IndexService +import com.tencent.devops.openapi.service.OpenApiIndexService import com.tencent.devops.openapi.utils.ApiGatewayUtil import com.tencent.devops.process.api.service.ServiceBuildResource import com.tencent.devops.process.pojo.BuildHistory @@ -56,7 +56,7 @@ import org.springframework.beans.factory.annotation.Autowired class ApigwBuildResourceV4Impl @Autowired constructor( private val client: Client, private val apiGatewayUtil: ApiGatewayUtil, - private val indexService: IndexService + private val openApiIndexService: OpenApiIndexService ) : ApigwBuildResourceV4 { override fun manualStartupInfo( appCode: String?, @@ -407,7 +407,7 @@ class ApigwBuildResourceV4Impl @Autowired constructor( } private fun checkPipelineId(projectId: String, pipelineId: String?, buildId: String): String { - val pipelineIdFormDB = indexService.getHandle(buildId) { + val pipelineIdFormDB = openApiIndexService.getHandle(buildId) { kotlin.runCatching { client.get(ServiceBuildResource::class).getPipelineIdFromBuildId(projectId, buildId).data }.getOrElse { diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwLogResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwLogResourceV4Impl.kt index 361d7789803..bb5be2393d0 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwLogResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwLogResourceV4Impl.kt @@ -40,7 +40,7 @@ import com.tencent.devops.common.security.util.EnvironmentUtil import com.tencent.devops.common.web.RestResource import com.tencent.devops.log.api.ServiceLogResource import com.tencent.devops.openapi.api.apigw.v4.ApigwLogResourceV4 -import com.tencent.devops.openapi.service.IndexService +import com.tencent.devops.openapi.service.OpenApiIndexService import com.tencent.devops.process.api.service.ServiceBuildResource import org.slf4j.LoggerFactory import org.springframework.beans.factory.annotation.Autowired @@ -51,7 +51,7 @@ import javax.ws.rs.core.Response @RestResource class ApigwLogResourceV4Impl @Autowired constructor( private val client: Client, - private val indexService: IndexService + private val openApiIndexService: OpenApiIndexService ) : ApigwLogResourceV4 { @Value("\${devopsGateway.api:#{null}}") @@ -223,7 +223,7 @@ class ApigwLogResourceV4Impl @Autowired constructor( } private fun checkPipelineId(projectId: String, pipelineId: String?, buildId: String): String { - val pipelineIdFormDB = indexService.getHandle(buildId) { + val pipelineIdFormDB = openApiIndexService.getHandle(buildId) { kotlin.runCatching { client.get(ServiceBuildResource::class).getPipelineIdFromBuildId(projectId, buildId).data }.getOrElse { diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwRepositoryCommitResourceV4Impl.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwRepositoryCommitResourceV4Impl.kt index 17ca7970b37..3b58dd61f76 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwRepositoryCommitResourceV4Impl.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/resources/apigw/v4/ApigwRepositoryCommitResourceV4Impl.kt @@ -31,7 +31,7 @@ import com.tencent.devops.common.api.pojo.Result import com.tencent.devops.common.client.Client import com.tencent.devops.common.web.RestResource import com.tencent.devops.openapi.api.apigw.v4.ApigwRepositoryCommitResourceV4 -import com.tencent.devops.openapi.service.IndexService +import com.tencent.devops.openapi.service.OpenApiIndexService import com.tencent.devops.process.api.service.ServiceBuildResource import com.tencent.devops.repository.api.UserRepositoryResource import com.tencent.devops.repository.pojo.commit.CommitResponse @@ -41,7 +41,7 @@ import org.springframework.beans.factory.annotation.Autowired @RestResource class ApigwRepositoryCommitResourceV4Impl @Autowired constructor( private val client: Client, - private val indexService: IndexService + private val openApiIndexService: OpenApiIndexService ) : ApigwRepositoryCommitResourceV4 { companion object { @@ -62,7 +62,7 @@ class ApigwRepositoryCommitResourceV4Impl @Autowired constructor( } private fun checkPipelineId(projectId: String, pipelineId: String?, buildId: String): String { - val pipelineIdFormDB = indexService.getHandle(buildId) { + val pipelineIdFormDB = openApiIndexService.getHandle(buildId) { kotlin.runCatching { client.get(ServiceBuildResource::class).getPipelineIdFromBuildId(projectId, buildId).data }.getOrElse { diff --git a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/IndexService.kt b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/OpenApiIndexService.kt similarity index 98% rename from src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/IndexService.kt rename to src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/OpenApiIndexService.kt index ed385539960..058df1f1788 100644 --- a/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/IndexService.kt +++ b/src/backend/ci/core/openapi/biz-openapi/src/main/kotlin/com/tencent/devops/openapi/service/OpenApiIndexService.kt @@ -31,7 +31,7 @@ import org.springframework.stereotype.Service import java.util.concurrent.TimeUnit @Service -class IndexService { +class OpenApiIndexService { private val indexCache = CacheBuilder.newBuilder() .maximumSize(100000) .expireAfterAccess(30, TimeUnit.MINUTES) From 25d707c1d0ae69a7afb53b48d53a4f5eea004ed9 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Tue, 10 Oct 2023 11:01:48 +0800 Subject: [PATCH 40/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/com/tencent/devops/multijar/MultijarApplication.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt index 0dd7dc85295..c11c8d2d719 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt @@ -42,8 +42,8 @@ import org.springframework.context.annotation.FilterType ) ] ) -class MutijarApplication +class MultijarApplication fun main(args: Array) { - MicroServiceApplication.run(MutijarApplication::class, args) + MicroServiceApplication.run(MultijarApplication::class, args) } From a779b3c8f57edea9833fe50d82ef3758d2f82002 Mon Sep 17 00:00:00 2001 From: stubenhuang Date: Fri, 13 Oct 2023 14:43:13 +0800 Subject: [PATCH 41/62] =?UTF-8?q?feat:=20=E6=8C=87=E5=AE=9A=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=BB=9F=E4=B8=80=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=20#8672?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-charts/core/ci/base/default_env.yaml | 1 - scripts/bkenv.properties | 2 -- src/gateway/core/lua/util/tag_util.lua | 2 +- support-files/templates/gateway#core#lua#init.lua | 3 +-- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/helm-charts/core/ci/base/default_env.yaml b/helm-charts/core/ci/base/default_env.yaml index b4a1a947711..93cf8da6dc4 100644 --- a/helm-charts/core/ci/base/default_env.yaml +++ b/helm-charts/core/ci/base/default_env.yaml @@ -48,4 +48,3 @@ bkCiSupportLanguages: zh_CN,en_US bkEsbEnabled: false bkCiLocalRunEnabled: false bkCiLocalRunTarget: host.docker.internal:8081 -bkCiUseDefaultTag: false diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index ecf25cca64b..1473b54c24c 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -219,8 +219,6 @@ BK_CI_KUBERNETES_WEBCONSOLE_PROXY= BK_CI_LOCAL_RUN_ENABLED=false # BK_CI_LOCAL_RUN_TARGET BK_CI_LOCAL_RUN_TARGET=host.docker.internal:8081 -# BK_CI_DEFAULT_TAG -BK_CI_USE_DEFAULT_TAG=false ########## # 3-微服务配置 diff --git a/src/gateway/core/lua/util/tag_util.lua b/src/gateway/core/lua/util/tag_util.lua index 4b5525b13cb..26dd4451d44 100644 --- a/src/gateway/core/lua/util/tag_util.lua +++ b/src/gateway/core/lua/util/tag_util.lua @@ -18,7 +18,7 @@ _M = {} -- 判断当前请求属于哪个tag function _M:get_tag(ns_config) - if ngx.var.use_default_tag == 'true' or ns_config.use_default_tag then + if ngx.var.use_default_tag == 'true' then return ns_config.tag end diff --git a/support-files/templates/gateway#core#lua#init.lua b/support-files/templates/gateway#core#lua#init.lua index e8e618834ca..602451d8162 100644 --- a/support-files/templates/gateway#core#lua#init.lua +++ b/support-files/templates/gateway#core#lua#init.lua @@ -37,8 +37,7 @@ config = { domain = "__BK_CI_CONSUL_DOMAIN__", tag = "__BK_CI_CONSUL_DISCOVERY_TAG__", suffix = "-__BK_CI_CONSUL_DISCOVERY_TAG__", - nodes_url = "/v1/catalog/nodes", - use_default_tag=__BK_CI_USE_DEFAULT_TAG__ + nodes_url = "/v1/catalog/nodes" }, ns_devnet = { ip = {"__BK_CI_CONSUL_DEVNET_IP__"}, From a96b837e2667f21ad4221a4ee564c1dbea2ced8a Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 10:57:01 +0800 Subject: [PATCH 42/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/ci/buildSrc/build.gradle.kts | 1 + .../tencent/devops/common/client/Client.kt | 48 +++---------------- ...{DataSourceDao.kt => MiscDataSourceDao.kt} | 2 +- .../misc/service/project/DataSourceService.kt | 6 +-- ...taSourceDao.kt => ProjectDataSourceDao.kt} | 2 +- .../resources/OPDataSourceResourceImpl.kt | 14 +++--- ...Service.kt => ProjectDataSourceService.kt} | 2 +- ...mpl.kt => ProjectDataSourceServiceImpl.kt} | 26 +++++----- .../ShardingRoutingRuleAssignServiceImpl.kt | 6 +-- 9 files changed, 37 insertions(+), 70 deletions(-) rename src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/{DataSourceDao.kt => MiscDataSourceDao.kt} (99%) rename src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/{DataSourceDao.kt => ProjectDataSourceDao.kt} (99%) rename src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/{DataSourceService.kt => ProjectDataSourceService.kt} (98%) rename src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/{DataSourceServiceImpl.kt => ProjectDataSourceServiceImpl.kt} (87%) diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index ad094cf42b5..e0a1c0fada4 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -22,5 +22,6 @@ dependencies { implementation("org.apache.logging.log4j:log4j-core:2.17.1") implementation("org.owasp:dependency-check-gradle:7.1.0.1") implementation("com.google.cloud.tools:jib-gradle-plugin:3.3.1") + implementation("org.springframework.boot:spring-boot-gradle-plugin:2.6.13") implementation("com.github.jk1:gradle-license-report:1.17") // 2.x need gradle-7.0 } diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt index fb0b06aa1e2..630eda4c56d 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt @@ -49,13 +49,6 @@ import feign.jackson.JacksonEncoder import feign.jaxrs.JAXRSContract import feign.okhttp.OkHttpClient import feign.spring.SpringContract -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.beans.factory.annotation.Value -import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient -import org.springframework.context.annotation.DependsOn -import org.springframework.core.annotation.AnnotationUtils -import org.springframework.stereotype.Component import java.lang.reflect.Method import java.security.cert.CertificateException import java.util.concurrent.TimeUnit @@ -63,6 +56,12 @@ import javax.net.ssl.SSLContext import javax.net.ssl.SSLSocketFactory import javax.net.ssl.TrustManager import javax.net.ssl.X509TrustManager +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.beans.factory.annotation.Value +import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient +import org.springframework.context.annotation.DependsOn +import org.springframework.stereotype.Component import kotlin.reflect.KClass /** @@ -80,6 +79,7 @@ class Client @Autowired constructor( private val mutilJarServiceMapConfiguration: MutilJarServiceMapConfiguration, objectMapper: ObjectMapper ) { + companion object { private val logger = LoggerFactory.getLogger(Client::class.java) private const val readWriteTimeoutSeconds = 15L @@ -280,40 +280,6 @@ class Client @Autowired constructor( ).url() } - private fun findServiceName(clz: KClass<*>): String { - // 单体结构,不分微服务的方式 - if (!assemblyServiceName.isNullOrBlank()) { - return assemblyServiceName - } - val serviceName = interfaces.getOrPut(clz) { - val serviceInterface = AnnotationUtils.findAnnotation(clz.java, ServiceInterface::class.java) - if (serviceInterface != null && serviceInterface.value.isNotBlank()) { - serviceInterface.value - } else { - val packageName = clz.qualifiedName.toString() - val regex = Regex("""com.tencent.devops.([a-z]+).api.([a-zA-Z]+)""") - val matches = regex.find(packageName) - ?: throw ErrorCodeException( - errorCode = SERVICE_COULD_NOT_BE_ANALYZED, - params = arrayOf(packageName) - ) - matches.groupValues[1] - } - } - return generateServiceName(serviceName) - } - - private fun generateServiceName(serviceName: String): String { - val mutilJarServiceMap = mutilJarServiceMapConfiguration.propertiesMap - val finalServiceName = mutilJarServiceMap[serviceName] ?: serviceName - logger.info("findServiceName:serviceName({})", finalServiceName) - return if (serviceSuffix.isNullOrBlank() || KubernetesUtils.inContainer()) { - finalServiceName - } else { - "$finalServiceName$serviceSuffix" - } - } - private fun buildGatewayUrl(path: String, gatewayType: GatewayType = GatewayType.IDC): String { return if (path.startsWith("http://") || path.startsWith("https://")) { diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/DataSourceDao.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/MiscDataSourceDao.kt similarity index 99% rename from src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/DataSourceDao.kt rename to src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/MiscDataSourceDao.kt index 65b699dc10a..448daffd048 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/DataSourceDao.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/dao/project/MiscDataSourceDao.kt @@ -36,7 +36,7 @@ import org.jooq.Result import org.springframework.stereotype.Repository @Repository -class DataSourceDao { +class MiscDataSourceDao { fun listByModule( dslContext: DSLContext, diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/service/project/DataSourceService.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/service/project/DataSourceService.kt index e57ca4f41f3..f8ba9d0f488 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/service/project/DataSourceService.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/service/project/DataSourceService.kt @@ -28,7 +28,7 @@ package com.tencent.devops.misc.service.project import com.tencent.devops.common.api.enums.SystemModuleEnum -import com.tencent.devops.misc.dao.project.DataSourceDao +import com.tencent.devops.misc.dao.project.MiscDataSourceDao import com.tencent.devops.project.pojo.DataSource import org.jooq.DSLContext import org.springframework.beans.factory.annotation.Autowired @@ -37,7 +37,7 @@ import org.springframework.stereotype.Service @Service class DataSourceService @Autowired constructor( private val dslContext: DSLContext, - private val dataSourceDao: DataSourceDao + private val miscDataSourceDao: MiscDataSourceDao ) { fun listByModule( @@ -46,7 +46,7 @@ class DataSourceService @Autowired constructor( fullFlag: Boolean? = false, dataTag: String? = null ): List? { - val dataSourceRecords = dataSourceDao.listByModule( + val dataSourceRecords = miscDataSourceDao.listByModule( dslContext = dslContext, clusterName = clusterName, moduleCode = moduleCode, diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/DataSourceDao.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDataSourceDao.kt similarity index 99% rename from src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/DataSourceDao.kt rename to src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDataSourceDao.kt index 81680219638..c18cb76eff6 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/DataSourceDao.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/dao/ProjectDataSourceDao.kt @@ -39,7 +39,7 @@ import org.springframework.stereotype.Repository import java.time.LocalDateTime @Repository -class DataSourceDao { +class ProjectDataSourceDao { fun add(dslContext: DSLContext, userId: String, dataSource: DataSource) { with(TDataSource.T_DATA_SOURCE) { diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPDataSourceResourceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPDataSourceResourceImpl.kt index c220c8b1e3d..799ce0a29bd 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPDataSourceResourceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/resources/OPDataSourceResourceImpl.kt @@ -33,28 +33,28 @@ import com.tencent.devops.common.web.RestResource import com.tencent.devops.project.api.op.OPDataSourceResource import com.tencent.devops.project.pojo.DataBasePiecewiseInfo import com.tencent.devops.project.pojo.DataSource -import com.tencent.devops.project.service.DataSourceService +import com.tencent.devops.project.service.ProjectDataSourceService import org.springframework.beans.factory.annotation.Autowired @RestResource class OPDataSourceResourceImpl @Autowired constructor( - private val dataSourceService: DataSourceService + private val projectDataSourceService: ProjectDataSourceService ) : OPDataSourceResource { override fun addDataSource(userId: String, dataSource: DataSource): Result { - return Result(dataSourceService.addDataSource(userId, dataSource)) + return Result(projectDataSourceService.addDataSource(userId, dataSource)) } override fun updateDataSource(userId: String, id: String, dataSource: DataSource): Result { - return Result(dataSourceService.updateDataSource(userId, id, dataSource)) + return Result(projectDataSourceService.updateDataSource(userId, id, dataSource)) } override fun getDataSourceById(id: String): Result { - return Result(dataSourceService.getDataSourceById(id)) + return Result(projectDataSourceService.getDataSourceById(id)) } override fun deleteDataSourceById(userId: String, id: String): Result { - return Result(dataSourceService.deleteDataSource(userId, id)) + return Result(projectDataSourceService.deleteDataSource(userId, id)) } override fun getDataBasePiecewiseById( @@ -64,7 +64,7 @@ class OPDataSourceResourceImpl @Autowired constructor( ruleType: ShardingRuleTypeEnum, tableName: String? ): Result { - return Result(dataSourceService.getDataBasePiecewiseById( + return Result(projectDataSourceService.getDataBasePiecewiseById( projectId = projectId, moduleCode = moduleCode, clusterName = clusterName, diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/DataSourceService.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectDataSourceService.kt similarity index 98% rename from src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/DataSourceService.kt rename to src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectDataSourceService.kt index ebeb2fa1c92..f14a3c1c256 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/DataSourceService.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/ProjectDataSourceService.kt @@ -32,7 +32,7 @@ import com.tencent.devops.common.api.pojo.ShardingRuleTypeEnum import com.tencent.devops.project.pojo.DataBasePiecewiseInfo import com.tencent.devops.project.pojo.DataSource -interface DataSourceService { +interface ProjectDataSourceService { fun addDataSource(userId: String, dataSource: DataSource): Boolean diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/DataSourceServiceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ProjectDataSourceServiceImpl.kt similarity index 87% rename from src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/DataSourceServiceImpl.kt rename to src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ProjectDataSourceServiceImpl.kt index b545f0bf5be..d31ccbad4c6 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/DataSourceServiceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ProjectDataSourceServiceImpl.kt @@ -31,27 +31,27 @@ import com.tencent.devops.common.api.constant.CommonMessageCode import com.tencent.devops.common.api.enums.SystemModuleEnum import com.tencent.devops.common.api.exception.ErrorCodeException import com.tencent.devops.common.api.pojo.ShardingRuleTypeEnum -import com.tencent.devops.project.dao.DataSourceDao +import com.tencent.devops.project.dao.ProjectDataSourceDao import com.tencent.devops.project.dao.ShardingRoutingRuleDao import com.tencent.devops.project.pojo.DataBasePiecewiseInfo import com.tencent.devops.project.pojo.DataSource -import com.tencent.devops.project.service.DataSourceService +import com.tencent.devops.project.service.ProjectDataSourceService import org.jooq.DSLContext import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Service @Service -class DataSourceServiceImpl @Autowired constructor( +class ProjectDataSourceServiceImpl @Autowired constructor( private val dslContext: DSLContext, private val shardingRoutingRuleDao: ShardingRoutingRuleDao, - private val dataSourceDao: DataSourceDao -) : DataSourceService { + private val projectDataSourceDao: ProjectDataSourceDao +) : ProjectDataSourceService { override fun addDataSource(userId: String, dataSource: DataSource): Boolean { val clusterName = dataSource.clusterName val dataSourceName = dataSource.dataSourceName val moduleCode = dataSource.moduleCode.name - val nameCount = dataSourceDao.countByName( + val nameCount = projectDataSourceDao.countByName( dslContext = dslContext, clusterName = clusterName, moduleCode = moduleCode, @@ -64,12 +64,12 @@ class DataSourceServiceImpl @Autowired constructor( params = arrayOf("[$clusterName-$moduleCode]$dataSourceName") ) } - dataSourceDao.add(dslContext, userId, dataSource) + projectDataSourceDao.add(dslContext, userId, dataSource) return true } override fun deleteDataSource(userId: String, id: String): Boolean { - dataSourceDao.delete(dslContext, id) + projectDataSourceDao.delete(dslContext, id) return true } @@ -77,7 +77,7 @@ class DataSourceServiceImpl @Autowired constructor( val clusterName = dataSource.clusterName val dataSourceName = dataSource.dataSourceName val moduleCode = dataSource.moduleCode.name - val nameCount = dataSourceDao.countByName( + val nameCount = projectDataSourceDao.countByName( dslContext = dslContext, clusterName = clusterName, moduleCode = moduleCode, @@ -85,7 +85,7 @@ class DataSourceServiceImpl @Autowired constructor( ) if (nameCount > 0) { // 判断更新的名称是否属于自已 - val obj = dataSourceDao.getById(dslContext, id) + val obj = projectDataSourceDao.getById(dslContext, id) if (null != obj && moduleCode != obj.moduleCode && dataSourceName != obj.dataSourceName) { // 抛出错误提示 throw ErrorCodeException( @@ -94,12 +94,12 @@ class DataSourceServiceImpl @Autowired constructor( ) } } - dataSourceDao.update(dslContext, id, dataSource) + projectDataSourceDao.update(dslContext, id, dataSource) return true } override fun getDataSourceById(id: String): DataSource? { - val record = dataSourceDao.getById(dslContext, id) + val record = projectDataSourceDao.getById(dslContext, id) return if (record != null) { DataSource( clusterName = record.clusterName, @@ -129,7 +129,7 @@ class DataSourceServiceImpl @Autowired constructor( tableName = tableName ) if (routingRuleRecord != null) { - val dataSource = dataSourceDao.getDataBasePiecewiseById( + val dataSource = projectDataSourceDao.getDataBasePiecewiseById( dslContext = dslContext, moduleCode = moduleCode, clusterName = clusterName, diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ShardingRoutingRuleAssignServiceImpl.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ShardingRoutingRuleAssignServiceImpl.kt index ea63acd9191..bcd5fe020fd 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ShardingRoutingRuleAssignServiceImpl.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/service/impl/ShardingRoutingRuleAssignServiceImpl.kt @@ -34,7 +34,7 @@ import com.tencent.devops.common.api.pojo.ShardingRoutingRule import com.tencent.devops.common.api.pojo.ShardingRuleTypeEnum import com.tencent.devops.common.service.utils.CommonUtils import com.tencent.devops.project.constant.ProjectMessageCode -import com.tencent.devops.project.dao.DataSourceDao +import com.tencent.devops.project.dao.ProjectDataSourceDao import com.tencent.devops.project.pojo.TableShardingConfig import com.tencent.devops.project.pojo.enums.ProjectChannelCode import com.tencent.devops.project.service.ShardingRoutingRuleAssignService @@ -49,7 +49,7 @@ import org.springframework.stereotype.Service @Service class ShardingRoutingRuleAssignServiceImpl @Autowired constructor( private val dslContext: DSLContext, - private val dataSourceDao: DataSourceDao, + private val projectDataSourceDao: ProjectDataSourceDao, private val shardingRoutingRuleService: ShardingRoutingRuleService, private val tableShardingConfigService: TableShardingConfigService ) : ShardingRoutingRuleAssignService { @@ -110,7 +110,7 @@ class ShardingRoutingRuleAssignServiceImpl @Autowired constructor( var validDataSourceName = DEFAULT_DATA_SOURCE_NAME // 根据模块查找还有空余容量的数据源 val dataTagModules = dataTagModulesConfig.split(",") - val dataSourceNames = dataSourceDao.listByModule( + val dataSourceNames = projectDataSourceDao.listByModule( dslContext = dslContext, clusterName = clusterName, moduleCode = moduleCode, From 0fbcc39468c329fd757833d25c639602b3174dca Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 12:27:02 +0800 Subject: [PATCH 43/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 5069201b9b6..ff38e9079b9 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -35,6 +35,8 @@ tasks.register("multiBootJar") { } fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { + if (!path.contains("core")) + return false // store服务存在子模块 biz-store-image,该模块会单独在打包image服务时,误打包 return if (path.contains("biz") && path.contains("image") && path.contains("store")) { multiModuleList.contains("store") From 46fe034e2461ae27e6aa2fdc331e86afb025f7d5 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 15:36:47 +0800 Subject: [PATCH 44/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-docker-build.gradle.kts | 17 +-- .../plugins/task-multi-boot-jar.gradle.kts | 7 +- .../plugins/task-multi-boot-run.gradle.kts | 6 +- .../BkServiceInstanceApplicationRunner.kt | 123 +++++++++--------- .../multijar/boot-multijar/build.gradle.kts | 4 - .../multijar/DataSourceDefinitionRegistrar.kt | 4 +- 6 files changed, 77 insertions(+), 84 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index d3e19d05af6..621b8f27820 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -31,13 +31,9 @@ plugins { val toImageRepo = System.getProperty("to.image.repo") val toImageTag = System.getProperty("to.image.tag") var toImage = System.getProperty("jib.to.image") -val serviceName = System.getProperty("serviceName") - - // 加这个判断 , 主要是为了编译kts时不报错 if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNullOrBlank())) { - val service = serviceName.takeUnless { it.isNullOrBlank() } - ?: name.replace("boot-", "").replace("-tencent", "") + val service = name.replace("boot-", "").replace("-tencent", "") if (toImage.isNullOrBlank() && !toImageRepo.isNullOrBlank()) { toImage = toImageRepo.let { if (toImageRepo.endsWith("/")) it else it + "/" @@ -45,8 +41,6 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull } val configNamespace = System.getProperty("config.namespace") val jvmFlagList = System.getProperty("jvmFlags.file")?.let { File(it).readLines() } ?: emptyList() - val multiModelService = System.getProperty("devops.multi.from") - val multiDataSource = System.getProperty("devops.multi.datasource") val finalJvmFlags = mutableListOf( "-server", @@ -82,14 +76,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-Dspring.cloud.kubernetes.config.includeProfileSpecificSources=false", "-Dio.undertow.legacy.cookie.ALLOW_HTTP_SEPARATORS_IN_V0=true", "-Dserver.port=80" - ).also { - if (multiModelService != null) { - it.add("-Ddevops.multi.from=$multiModelService") - } - if (multiDataSource != null) { - it.add("-Ddevops.multi.datasource=$multiDataSource") - } - } + ) finalJvmFlags.addAll(jvmFlagList) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index ff38e9079b9..9c710315430 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -25,7 +25,8 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ tasks.register("multiBootJar") { - System.getProperty("devops.multi.from")?.let { multiModuleStr -> + val finalServices = System.getProperty("devops.multi.from") ?: localRunMultiServices + finalServices.let { multiModuleStr -> val multiModuleList = multiModuleStr.split(",").toMutableList() rootProject.subprojects.filter { isSpecifiedModulePath(it.path, multiModuleList) @@ -50,3 +51,7 @@ fun addDependencies(path: String) { add("implementation", project(path)) } } + +val localRunMultiServices = "process,auth,image,environment,repository,ticket,project," + + "notify,openapi,quality,dispatch,dispatch-docker,dispatch-kubernetes,artifactory," + + "monitoring,plugin,websocket,worker,misc,store,log" diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index 15696bf2c47..b2214a87e72 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -29,7 +29,7 @@ import org.springframework.boot.gradle.tasks.run.BootRun tasks.register("multiBootRun") { doFirst { - systemProperty("devops.multi.from", System.getProperty("devops.multi.from")) + systemProperty("devops.multi.from", localRunMultiServices) systemProperty("spring.main.allow-circular-references", "true") systemProperty("spring.cloud.config.enabled", "false") systemProperty("spring.cloud.config.fail-fast", "true") @@ -53,3 +53,7 @@ tasks.register("multiBootRun") { */ fun joinPath(vararg folders: String) = folders.joinToString(File.separator) tasks.getByName("compileKotlin").dependsOn("replacePlaceholders") + +val localRunMultiServices = "process,auth,image,environment,repository,ticket,project," + + "notify,openapi,quality,dispatch,dispatch-docker,dispatch-kubernetes,artifactory," + + "monitoring,plugin,websocket,worker,misc,store,log" diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt index c42ee1c2d16..b2f2fbcd914 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt @@ -28,72 +28,75 @@ class BkServiceInstanceApplicationRunner constructor( @Suppress("SpreadOperator") override fun run(args: ApplicationArguments) { - object : Thread() { - override fun run() { - val serviceName = BkServiceUtil.findServiceName() - logger.info("initServiceHostInfo serviceName:$serviceName begin") - val cacheKey = BkServiceUtil.getServiceHostKey(serviceName) - logger.info("initServiceHostInfo serviceName:$serviceName cacheKey:$cacheKey") - val discoveryTag = bkTag.getFinalTag() - val namespace = discoveryTag.replace("kubernetes-", "") - val svrName = KubernetesUtils.getSvrName(serviceName, namespace) - // 睡眠一会儿以便从注册最新拿到微服务最新的IP列表 - sleep(THREAD_SLEEP_TIMEOUT) - val serviceHosts = compositeDiscoveryClient.getInstances(svrName).map { it.host }.toTypedArray() - logger.info( - "initServiceHostInfo serviceName:[$serviceName],IP:[${CommonUtils.getInnerIP()}],serviceHosts:${ - JsonUtil.toJson( - serviceHosts - ) - }" - ) - val environment: Environment = SpringContextUtil.getBean(Environment::class.java) - val shardingDbFlag = environment.containsProperty("spring.datasource.dataSourceConfigs[0].url") - logger.info("initServiceHostInfo serviceName:$serviceName shardingDbFlag:$shardingDbFlag") - if (shardingDbFlag) { - // 如果微服务的DB采用了分库分表方案,那么需要清理规则动态队列 - try { - deleteDynamicMqQueue(cacheKey, serviceName, serviceHosts) - } catch (ignored: Throwable) { - logger.warn( - "serviceName:$serviceName delete dynamicMqQueue fail!", ignored - ) + // 当本地运行时为单体服务,不需要存储各服务的实例ip + if (!System.getProperty("local.run").toBoolean()) { + object : Thread() { + override fun run() { + val serviceName = BkServiceUtil.findServiceName() + logger.info("initServiceHostInfo serviceName:$serviceName begin") + val cacheKey = BkServiceUtil.getServiceHostKey(serviceName) + logger.info("initServiceHostInfo serviceName:$serviceName cacheKey:$cacheKey") + val discoveryTag = bkTag.getFinalTag() + val namespace = discoveryTag.replace("kubernetes-", "") + val svrName = KubernetesUtils.getSvrName(serviceName, namespace) + // 睡眠一会儿以便从注册最新拿到微服务最新的IP列表 + sleep(THREAD_SLEEP_TIMEOUT) + val serviceHosts = compositeDiscoveryClient.getInstances(svrName).map { it.host }.toTypedArray() + logger.info( + "initServiceHostInfo serviceName:[$serviceName],IP:[${CommonUtils.getInnerIP()}],serviceHosts:${ + JsonUtil.toJson( + serviceHosts + ) + }" + ) + val environment: Environment = SpringContextUtil.getBean(Environment::class.java) + val shardingDbFlag = environment.containsProperty("spring.datasource.dataSourceConfigs[0].url") + logger.info("initServiceHostInfo serviceName:$serviceName shardingDbFlag:$shardingDbFlag") + if (shardingDbFlag) { + // 如果微服务的DB采用了分库分表方案,那么需要清理规则动态队列 + try { + deleteDynamicMqQueue(cacheKey, serviceName, serviceHosts) + } catch (ignored: Throwable) { + logger.warn( + "serviceName:$serviceName delete dynamicMqQueue fail!", ignored + ) + } } + // 清空redis中微服务的主机IP列表 + redisOperation.delete(cacheKey) + // 把微服务的最新主机IP列表写入redis中 + redisOperation.sadd(cacheKey, *serviceHosts) } - // 清空redis中微服务的主机IP列表 - redisOperation.delete(cacheKey) - // 把微服务的最新主机IP列表写入redis中 - redisOperation.sadd(cacheKey, *serviceHosts) - } - private fun deleteDynamicMqQueue(cacheKey: String, serviceName: String, serviceHosts: Array) { - // 将微服务在redis的主机IP列表取出 - val historyServiceHosts = redisOperation.getSetMembers(cacheKey)?.toMutableSet() - logger.info("initServiceHostInfo serviceName:$serviceName historyServiceHosts:$historyServiceHosts") - if (historyServiceHosts.isNullOrEmpty()) { - return - } - historyServiceHosts.removeAll(serviceHosts.toSet()) - historyServiceHosts.forEach { historyServiceHost -> - val queueName = BkServiceUtil.getDynamicMqQueue(serviceName, historyServiceHost) - logger.info("serviceName:$serviceName delete dynamicMqQueue($queueName) start!") - var queueProperties = rabbitAdmin.getQueueProperties(queueName) - if (queueProperties == null) { - // 队列属性为空说明删除成功 - logger.info("serviceName:$serviceName dynamicMqQueue($queueName) does not exist!") + private fun deleteDynamicMqQueue(cacheKey: String, serviceName: String, serviceHosts: Array) { + // 将微服务在redis的主机IP列表取出 + val historyServiceHosts = redisOperation.getSetMembers(cacheKey)?.toMutableSet() + logger.info("initServiceHostInfo serviceName:$serviceName historyServiceHosts:$historyServiceHosts") + if (historyServiceHosts.isNullOrEmpty()) { return } - rabbitAdmin.purgeQueue(queueName) - rabbitAdmin.deleteQueue(queueName) - queueProperties = rabbitAdmin.getQueueProperties(queueName) - if (queueProperties != null) { - // 队列属性不为空说明删除未成功,把队列名称写入redis中 - logger.info("serviceName:$serviceName delete dynamicMqQueue($queueName) fail!") - } else { - logger.info("serviceName:$serviceName delete dynamicMqQueue($queueName) success!") + historyServiceHosts.removeAll(serviceHosts.toSet()) + historyServiceHosts.forEach { historyServiceHost -> + val queueName = BkServiceUtil.getDynamicMqQueue(serviceName, historyServiceHost) + logger.info("serviceName:$serviceName delete dynamicMqQueue($queueName) start!") + var queueProperties = rabbitAdmin.getQueueProperties(queueName) + if (queueProperties == null) { + // 队列属性为空说明删除成功 + logger.info("serviceName:$serviceName dynamicMqQueue($queueName) does not exist!") + return + } + rabbitAdmin.purgeQueue(queueName) + rabbitAdmin.deleteQueue(queueName) + queueProperties = rabbitAdmin.getQueueProperties(queueName) + if (queueProperties != null) { + // 队列属性不为空说明删除未成功,把队列名称写入redis中 + logger.info("serviceName:$serviceName delete dynamicMqQueue($queueName) fail!") + } else { + logger.info("serviceName:$serviceName delete dynamicMqQueue($queueName) success!") + } } } - } - }.start() + }.start() + } } } diff --git a/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts index bf4473a6806..24368fca8df 100644 --- a/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts +++ b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts @@ -38,8 +38,4 @@ plugins { `task-multi-boot-run` } -tasks.named("bootJar") { - val finalModuleName = System.getProperty("devops.multi.to") - archiveBaseName.set("boot-$finalModuleName") -} tasks.getByName("multiBootRun").dependsOn("replacePlaceholders") diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt index 47ddf72902d..cbe73d57039 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -52,15 +52,13 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { } } - companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) private val notNeedDataSourceService = listOf( "buildless", "dockerhost", "metrics", "misc", "monitoring", "process","worker","websocket" ) - private - val multiDataSource = System.getProperty("devops.multi.from") + private val multiDataSource = System.getProperty("devops.multi.from") .split(",").filterNot { notNeedDataSourceService.contains(it) } } } From e7d7d55e8ae096e0bd9b4d38caa7f0ba958a55d8 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 17:15:49 +0800 Subject: [PATCH 45/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/plugins/task-docker-build.gradle.kts | 2 +- .../kotlin/plugins/task-multi-boot-jar.gradle.kts | 13 ++++++------- .../kotlin/plugins/task-render-template.gradle.kts | 4 +--- .../com/tencent/devops/common/client/Client.kt | 1 - .../devops/common/client/ClientAutoConfiguration.kt | 4 +--- .../client/MutilJarServiceMapConfiguration.kt | 10 ---------- .../tencent/devops/common/db/DBAutoConfiguration.kt | 1 - .../kubernetes/service/DispatchBaseDebugService.kt | 6 +++--- .../tencent/devops/misc/config/DataSourceConfig.kt | 2 +- .../devops/monitoring/service/AtomMonitorService.kt | 0 .../multijar/MultijarDslContextConfiguration.kt | 6 +++--- .../src/main/resources/application.yml | 2 +- .../engine/service/measure/MeasureServiceImpl.kt | 2 ++ src/gateway/core/lua/router_srv.lua | 5 ----- 14 files changed, 19 insertions(+), 39 deletions(-) delete mode 100644 src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt delete mode 100644 src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/service/AtomMonitorService.kt diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index 621b8f27820..568814f4a4a 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -49,7 +49,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-XX:+PrintTenuringDistribution", "-XX:+PrintGCDetails", "-XX:+PrintGCDateStamps", - "-XX:MaxGCPauseMillis=100", + "-XX:MaxGCPauseMillis=200", "-XX:+UseG1GC", "-XX:NativeMemoryTracking=summary", "-XX:+HeapDumpOnOutOfMemoryError", diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 9c710315430..f5ebdc1419f 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -26,13 +26,12 @@ */ tasks.register("multiBootJar") { val finalServices = System.getProperty("devops.multi.from") ?: localRunMultiServices - finalServices.let { multiModuleStr -> - val multiModuleList = multiModuleStr.split(",").toMutableList() - rootProject.subprojects.filter { - isSpecifiedModulePath(it.path, multiModuleList) - }.forEach { subProject -> addDependencies(subProject.path) } - dependsOn("copyToRelease") - } + val finalServiceList = finalServices.split(",").toMutableList() + rootProject.subprojects.filter { + isSpecifiedModulePath(it.path, finalServiceList) + }.forEach { subProject -> addDependencies(subProject.path) } + dependsOn("copyToRelease") + } fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts index 9cb67bdd901..8fd623660c4 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts @@ -29,19 +29,18 @@ import java.util.Properties tasks.register("replacePlaceholders") { doLast { val destDir = joinPath(projectDir.absolutePath, "src", "main", "resources") + // 每次启动时,首先清空application文件,再根据模板文件重新渲染 deleteFiles(destDir) val rootDirPath = rootDir.absolutePath.replace( "${File.separator}src${File.separator}backend${File.separator}ci", "" ) - // 基础变量 val baseBkEnvPath = joinPath(rootDirPath, "scripts", "bkenv.properties") val bkEnvProperties = loadProperties(baseBkEnvPath) val bkEnvFileContent = renderTemplate(baseBkEnvPath, bkEnvProperties) bkEnvProperties.load(bkEnvFileContent.byteInputStream()) - // 自定义变量 val bkEnvPath = joinPath(projectDir.absolutePath, "bkenv.properties") file(bkEnvPath).let { @@ -49,7 +48,6 @@ tasks.register("replacePlaceholders") { bkEnvProperties.load(it.inputStream()) } } - // 渲染模板 val templatesDir = joinPath(rootDirPath, "support-files", "templates") generateFiles(templatesDir, destDir, bkEnvProperties) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt index 630eda4c56d..cb18ae1a929 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/Client.kt @@ -76,7 +76,6 @@ class Client @Autowired constructor( private val clientErrorDecoder: ClientErrorDecoder, private val commonConfig: CommonConfig, private val bkTag: BkTag, - private val mutilJarServiceMapConfiguration: MutilJarServiceMapConfiguration, objectMapper: ObjectMapper ) { diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt index daab8a27bc0..73a3447eea7 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt @@ -54,7 +54,6 @@ import org.springframework.core.Ordered @PropertySource("classpath:/common-client.properties") @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @AutoConfigureAfter(ServiceAutoConfiguration::class, LoadBalancerAutoConfiguration::class) -@EnableConfigurationProperties(MutilJarServiceMapConfiguration::class) class ClientAutoConfiguration { @Value("\${spring.cloud.consul.discovery.tags:prod}") @@ -79,10 +78,9 @@ class ClientAutoConfiguration { clientErrorDecoder: ClientErrorDecoder, commonConfig: CommonConfig, bkTag: BkTag, - mutilJarServiceMapConfiguration: MutilJarServiceMapConfiguration, objectMapper: ObjectMapper, @Autowired(required = false) compositeDiscoveryClient: CompositeDiscoveryClient? - ) = Client(compositeDiscoveryClient, clientErrorDecoder, commonConfig, bkTag, mutilJarServiceMapConfiguration, objectMapper) + ) = Client(compositeDiscoveryClient, clientErrorDecoder, commonConfig, bkTag, objectMapper) @Bean fun consulFilter(bkTag: BkTag) = ConsulFilter(bkTag) diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt deleted file mode 100644 index 1f613c6a4d8..00000000000 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/MutilJarServiceMapConfiguration.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.tencent.devops.common.client - -import org.springframework.boot.context.properties.ConfigurationProperties -import org.springframework.boot.context.properties.ConstructorBinding - -@ConstructorBinding -@ConfigurationProperties(prefix = "mutiljar.service") -class MutilJarServiceMapConfiguration { - val propertiesMap: Map = mutableMapOf() -} diff --git a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt index cd70a82c09e..7370c0bded2 100644 --- a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt @@ -52,7 +52,6 @@ import javax.sql.DataSource @Configuration @PropertySource("classpath:/common-db.properties") @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) -@ConditionalOnMissingClass("com.tencent.devops.accessories.DataSourceDefinitionRegistrar") @AutoConfigureBefore(DataSourceAutoConfiguration::class, JooqAutoConfiguration::class) @Import(DBBaseConfiguration::class) @EnableTransactionManagement diff --git a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt index 316593d0a58..93882de771b 100644 --- a/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt +++ b/src/backend/ci/core/dispatch-kubernetes/common-dispatch-kubernetes/src/main/kotlin/com/tencent/devops/dispatch/kubernetes/service/DispatchBaseDebugService.kt @@ -69,7 +69,7 @@ class DispatchBaseDebugService @Autowired constructor( private val dispatchKubernetesBuildHisDao: DispatchKubernetesBuildHisDao, private val bkAuthPermissionApi: AuthPermissionApi, private val pipelineAuthServiceCode: PipelineAuthServiceCode, - private val DispatchKubernetesRedisUtils: DispatchKubernetesRedisUtils, + private val dispatchKubernetesRedisUtils: DispatchKubernetesRedisUtils, private val dockerRoutingSdkService: DockerRoutingSdkService ) { @@ -186,7 +186,7 @@ class DispatchBaseDebugService @Autowired constructor( } // 设置containerName缓存 - DispatchKubernetesRedisUtils.setDebugBuilderName(userId, pipelineId, vmSeqId, builderName) + dispatchKubernetesRedisUtils.setDebugBuilderName(userId, pipelineId, vmSeqId, builderName) return DebugResponse( websocketUrl = containerServiceFactory.load(projectId).getDebugWebsocketUrl( @@ -210,7 +210,7 @@ class DispatchBaseDebugService @Autowired constructor( val dockerRoutingType = dockerRoutingSdkService.getDockerRoutingType(projectId) val debugBuilderName = builderName.ifBlank { - DispatchKubernetesRedisUtils.getDebugBuilderName(userId, pipelineId, vmSeqId) ?: "" + dispatchKubernetesRedisUtils.getDebugBuilderName(userId, pipelineId, vmSeqId) ?: "" } logger.info( diff --git a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt index 4058b0d85fa..861903be997 100644 --- a/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt +++ b/src/backend/ci/core/misc/biz-misc/src/main/kotlin/com/tencent/devops/misc/config/DataSourceConfig.kt @@ -47,7 +47,7 @@ import javax.sql.DataSource @Configuration @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement -@ConditionalOnMissingClass("com.tencent.devops.mutijar.MutijarDslContextConfiguration") +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") class DataSourceConfig { @Bean diff --git a/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/service/AtomMonitorService.kt b/src/backend/ci/core/monitoring/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/service/AtomMonitorService.kt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt index e1440abe441..a64c7e2b3aa 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt @@ -75,13 +75,13 @@ class MultijarDslContextConfiguration { val configurationName = if (packageName.contains(".misc")) { val matchResult = miscServiceRegex.find(packageName) "${matchResult?.groupValues?.get(1) ?: "default"}JooqConfiguration" - } else if (packageName.contains(".store")){ + } else if (packageName.contains(".store")) { "storeJooqConfiguration" - }else { + } else { serviceName.plus("JooqConfiguration") } - val configuration: org.jooq.Configuration = configurationMap[configurationName] + val configuration = configurationMap[configurationName] ?: throw NoSuchBeanDefinitionException("no $configurationName") return DSL.using(configuration) diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml index ed2a660cc76..cf3d5e1e988 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml @@ -24,6 +24,6 @@ spring: - log application: name: multijar - desc: DevOps MULTIJAR Service + desc: DevOps MultiJar Service version: 4.0.0 packageName: com.tencent.devops.multijar diff --git a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt index 9288ded4468..ffdf3cfe166 100644 --- a/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt +++ b/src/backend/ci/core/process/biz-base/src/main/kotlin/com/tencent/devops/process/engine/service/measure/MeasureServiceImpl.kt @@ -67,6 +67,8 @@ class MeasureServiceImpl : MeasureService { @Autowired lateinit var buildVariableService: BuildVariableService @Autowired + lateinit var dslContext: DSLContext + @Autowired lateinit var templateService: TemplateService @Autowired lateinit var pipelineInfoService: PipelineInfoService diff --git a/src/gateway/core/lua/router_srv.lua b/src/gateway/core/lua/router_srv.lua index 4a0d64b71a8..da5415b6252 100644 --- a/src/gateway/core/lua/router_srv.lua +++ b/src/gateway/core/lua/router_srv.lua @@ -45,11 +45,6 @@ if service_name == "bkrepo" then return end --- 服务合并 -if config.accessories and config.accessories[service_name] then - service_name = config.accessories[service_name] -end - -- 获取灰度设置 local cache_tail = "" local ns_config = nil From c0553b3eab614ae6b8e32c838e107451e5f38e75 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 17:39:56 +0800 Subject: [PATCH 46/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/runner/BkServiceInstanceApplicationRunner.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt index b2f2fbcd914..e16a626a39f 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt @@ -28,8 +28,10 @@ class BkServiceInstanceApplicationRunner constructor( @Suppress("SpreadOperator") override fun run(args: ApplicationArguments) { + val localRunProperty = System.getProperty("local.run") + val isLocalRun = !localRunProperty.isNullOrBlank() && localRunProperty.toBoolean() // 当本地运行时为单体服务,不需要存储各服务的实例ip - if (!System.getProperty("local.run").toBoolean()) { + if (!isLocalRun) { object : Thread() { override fun run() { val serviceName = BkServiceUtil.findServiceName() From a444e12be9835bd3e56dab2b8f7807103f5066b3 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 17:44:50 +0800 Subject: [PATCH 47/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/runner/BkServiceInstanceApplicationRunner.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt index e16a626a39f..0c5749374ad 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt @@ -28,8 +28,7 @@ class BkServiceInstanceApplicationRunner constructor( @Suppress("SpreadOperator") override fun run(args: ApplicationArguments) { - val localRunProperty = System.getProperty("local.run") - val isLocalRun = !localRunProperty.isNullOrBlank() && localRunProperty.toBoolean() + val isLocalRun = System.getProperty("local.run") == "true" // 当本地运行时为单体服务,不需要存储各服务的实例ip if (!isLocalRun) { object : Thread() { From 025e4972736337abcef656425e7403948fff5780 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 17:47:57 +0800 Subject: [PATCH 48/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/runner/BkServiceInstanceApplicationRunner.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt index 0c5749374ad..52ff3fc0c72 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt @@ -1,6 +1,7 @@ package com.tencent.devops.common.web.runner import com.tencent.devops.common.api.util.JsonUtil +import com.tencent.devops.common.api.util.PropertyUtil import com.tencent.devops.common.redis.RedisOperation import com.tencent.devops.common.service.BkTag import com.tencent.devops.common.service.utils.BkServiceUtil @@ -16,6 +17,7 @@ import org.springframework.core.env.Environment class BkServiceInstanceApplicationRunner constructor( private val compositeDiscoveryClient: CompositeDiscoveryClient, + private val propertyUtil: PropertyUtil, private val bkTag: BkTag, private val redisOperation: RedisOperation, private val rabbitAdmin: RabbitAdmin @@ -28,9 +30,8 @@ class BkServiceInstanceApplicationRunner constructor( @Suppress("SpreadOperator") override fun run(args: ApplicationArguments) { - val isLocalRun = System.getProperty("local.run") == "true" // 当本地运行时为单体服务,不需要存储各服务的实例ip - if (!isLocalRun) { + if (!propertyUtil.isLocalRun()) { object : Thread() { override fun run() { val serviceName = BkServiceUtil.findServiceName() From acb476137d9b670d89c13466d136c5ad6cd1ad9c Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 18 Oct 2023 17:53:23 +0800 Subject: [PATCH 49/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/web/runner/BkServiceInstanceApplicationRunner.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt index 52ff3fc0c72..f54a50f152b 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt @@ -17,7 +17,6 @@ import org.springframework.core.env.Environment class BkServiceInstanceApplicationRunner constructor( private val compositeDiscoveryClient: CompositeDiscoveryClient, - private val propertyUtil: PropertyUtil, private val bkTag: BkTag, private val redisOperation: RedisOperation, private val rabbitAdmin: RabbitAdmin @@ -31,7 +30,7 @@ class BkServiceInstanceApplicationRunner constructor( @Suppress("SpreadOperator") override fun run(args: ApplicationArguments) { // 当本地运行时为单体服务,不需要存储各服务的实例ip - if (!propertyUtil.isLocalRun()) { + if (!PropertyUtil.isLocalRun()) { object : Thread() { override fun run() { val serviceName = BkServiceUtil.findServiceName() From 4ad5939d8e69203e789ef36b5257462d9f124755 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 09:28:16 +0800 Subject: [PATCH 50/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-jar.gradle.kts | 12 +-- .../plugins/task-multi-boot-run.gradle.kts | 24 ++++- .../devops/common/db/DBAutoConfiguration.kt | 1 + .../dispatch.sdk/config/MQConfiguration.kt | 2 + .../tencent/devops/common/util/RegexUtils.kt | 22 ++++ .../config/DispatchDockerBeanConfiguration.kt | 2 +- .../config/DispatchDockerScheduleConfig.kt | 0 .../dispatch/docker/config/ScheduleConfig.kt | 2 +- .../configuration/DataSourceConfig.kt | 2 + .../configuration/JooqConfiguration.kt | 2 + .../LogESAutoConfiguration.kt | 2 +- .../log/service/impl/LogServiceESImpl.kt | 2 + .../main/resources/META-INF/spring.factories | 2 +- .../multijar/boot-multijar/build.gradle.kts | 2 +- .../multijar/DataSourceDefinitionRegistrar.kt | 59 +++++----- .../multijar/JooqDefinitionRegistrar.kt | 43 +++++--- .../MultijarDslContextConfiguration.kt | 63 +++++++---- .../templates/#etc#ci#application-misc.yml | 101 +++++++++--------- 18 files changed, 215 insertions(+), 128 deletions(-) delete mode 100644 src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerScheduleConfig.kt rename src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/{es => configuration}/LogESAutoConfiguration.kt (98%) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index f5ebdc1419f..28a56cba819 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -25,24 +25,18 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ tasks.register("multiBootJar") { - val finalServices = System.getProperty("devops.multi.from") ?: localRunMultiServices + val finalServices = System.getProperty("devops.multi.from") ?: localRunMultiModules val finalServiceList = finalServices.split(",").toMutableList() rootProject.subprojects.filter { isSpecifiedModulePath(it.path, finalServiceList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") - } fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { if (!path.contains("core")) return false - // store服务存在子模块 biz-store-image,该模块会单独在打包image服务时,误打包 - return if (path.contains("biz") && path.contains("image") && path.contains("store")) { - multiModuleList.contains("store") - } else { - path.contains("biz") && multiModuleList.any { module -> path.contains(module) } - } + return path.contains("biz") && multiModuleList.any { module -> path.contains(module) } } fun addDependencies(path: String) { @@ -51,6 +45,6 @@ fun addDependencies(path: String) { } } -val localRunMultiServices = "process,auth,image,environment,repository,ticket,project," + +val localRunMultiModules = "process,auth,image,environment,repository,ticket,project," + "notify,openapi,quality,dispatch,dispatch-docker,dispatch-kubernetes,artifactory," + "monitoring,plugin,websocket,worker,misc,store,log" diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index b2214a87e72..ac17aa2d0c2 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -26,10 +26,22 @@ */ import org.springframework.boot.gradle.tasks.bundling.BootJar import org.springframework.boot.gradle.tasks.run.BootRun +import java.util.Properties tasks.register("multiBootRun") { + + val bkEnvPath = joinPath(projectDir.absolutePath, "bkenv.properties") + val bkEnvProperties = Properties() + file(bkEnvPath).let { + if (it.exists()) { + bkEnvProperties.load(it.inputStream()) + } + } doFirst { systemProperty("devops.multi.from", localRunMultiServices) + systemProperty("spring.datasource.url", System.getProperty("mysqlURL")) + systemProperty("spring.datasource.username", System.getProperty("mysqlUser")) + systemProperty("spring.datasource.password", System.getProperty("mysqlPasswd")) systemProperty("spring.main.allow-circular-references", "true") systemProperty("spring.cloud.config.enabled", "false") systemProperty("spring.cloud.config.fail-fast", "true") @@ -48,12 +60,18 @@ tasks.register("multiBootRun") { mainClass.set(bootJarTask.mainClass) classpath = bootJarTask.classpath } + +fun loadProperties(basePath: String): Properties { + val properties = Properties() + properties.load(file(basePath).inputStream()) + return properties +} + /** * 返回路径 */ fun joinPath(vararg folders: String) = folders.joinToString(File.separator) tasks.getByName("compileKotlin").dependsOn("replacePlaceholders") -val localRunMultiServices = "process,auth,image,environment,repository,ticket,project," + - "notify,openapi,quality,dispatch,dispatch-docker,dispatch-kubernetes,artifactory," + - "monitoring,plugin,websocket,worker,misc,store,log" +val localRunMultiServices = "process,auth,environment,repository,ticket,project,notify,openapi,quality,dispatch," + + "dispatch-kubernetes,artifactory,monitoring,plugin,websocket,worker,misc,store,log,image" diff --git a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt index 7370c0bded2..0a6ca8f3c67 100644 --- a/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-db/src/main/kotlin/com/tencent/devops/common/db/DBAutoConfiguration.kt @@ -55,6 +55,7 @@ import javax.sql.DataSource @AutoConfigureBefore(DataSourceAutoConfiguration::class, JooqAutoConfiguration::class) @Import(DBBaseConfiguration::class) @EnableTransactionManagement +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") class DBAutoConfiguration { @Value("\${spring.datasource.url:#{null}}") diff --git a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/MQConfiguration.kt b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/MQConfiguration.kt index 9018a4cd004..07876033c09 100644 --- a/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/MQConfiguration.kt +++ b/src/backend/ci/core/common/common-dispatch-sdk/src/main/kotlin/com/tencent/devops/common/dispatch.sdk/config/MQConfiguration.kt @@ -48,9 +48,11 @@ import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter import org.springframework.beans.factory.annotation.Autowired import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass import org.springframework.context.annotation.Bean @Suppress("ALL") +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") class MQConfiguration @Autowired constructor() { @Value("\${dispatch.demoteQueue.concurrency:2}") diff --git a/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt b/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt index 4f5dcabe891..0fb45a84a6f 100644 --- a/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt +++ b/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt @@ -27,6 +27,8 @@ package com.tencent.devops.common.util +import java.util.Locale + @Suppress("MagicNumber", "ReturnCount") object RegexUtils { @@ -63,4 +65,24 @@ object RegexUtils { url } } + + + /** + * 转换驼峰,将dispatch-kubernetes类似字符串,转化为dispatchKubernetes + * */ + fun convertToCamelCase(input: String): String { + val words = input.split("-") + return if (words.size > 1) { + val camelCaseWords = words.mapIndexed { index, word -> + if (index == 0) { + word + } else { + word.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } + } + } + camelCaseWords.joinToString("") + } else { + input + } + } } diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt index 48e236c22ab..9f5bfabdedf 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt @@ -47,7 +47,7 @@ import org.springframework.core.Ordered @Suppress("ALL") @Configuration @ConditionalOnWebApplication -@DependsOn(value = ["jooqConfiguration"]) +//@DependsOn(value = ["jooqConfiguration"]) @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) class DispatchDockerBeanConfiguration @Autowired constructor( private val dslContext: DSLContext diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerScheduleConfig.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerScheduleConfig.kt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt index 71929165567..cd7325c2207 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/ScheduleConfig.kt @@ -8,7 +8,7 @@ import java.util.concurrent.ThreadPoolExecutor import java.util.concurrent.TimeUnit @Configuration -class DispatchDockerScheduleConfig : SchedulingConfigurer { +class ScheduleConfig : SchedulingConfigurer { override fun configureTasks(taskRegistrar: ScheduledTaskRegistrar) { val scheduler = ScheduledThreadPoolExecutor(5) scheduler.maximumPoolSize = 5 diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt index c416f901e57..4a68ee55ecf 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt @@ -31,6 +31,7 @@ import com.mysql.cj.jdbc.Driver import com.zaxxer.hikari.HikariDataSource import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary @@ -46,6 +47,7 @@ import javax.sql.DataSource @Configuration @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") class DataSourceConfig { @Bean diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt index 79d4acb2619..4d18fdf4afa 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt @@ -38,6 +38,7 @@ import org.springframework.beans.factory.InjectionPoint import org.springframework.beans.factory.NoSuchBeanDefinitionException import org.springframework.beans.factory.annotation.Qualifier import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Import @@ -53,6 +54,7 @@ import javax.sql.DataSource */ @Configuration @Import(DataSourceConfig::class, DBBaseConfiguration::class) +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") class JooqConfiguration { companion object { diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/es/LogESAutoConfiguration.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/configuration/LogESAutoConfiguration.kt similarity index 98% rename from src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/es/LogESAutoConfiguration.kt rename to src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/configuration/LogESAutoConfiguration.kt index 4f896bb099f..4d1eebc8064 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/es/LogESAutoConfiguration.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/configuration/LogESAutoConfiguration.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.devops.log.es +package com.tencent.devops.log.configuration import com.tencent.devops.common.es.ESAutoConfiguration import com.tencent.devops.common.es.ESProperties diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt index ee5f8187f52..2ac2dec0f03 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt @@ -85,6 +85,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder import org.elasticsearch.search.sort.SortOrder import org.slf4j.LoggerFactory +import org.springframework.stereotype.Service @Suppress( "LongParameterList", @@ -95,6 +96,7 @@ import org.slf4j.LoggerFactory "ReturnCount", "ComplexMethod" ) +@Service class LogServiceESImpl( private val logClient: LogClient, private val indexService: IndexService, diff --git a/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories b/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories index c5a4f1375f7..97c7df4354e 100644 --- a/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories +++ b/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories @@ -1,3 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.tencent.devops.log.es.LogESAutoConfiguration,\ +com.tencent.devops.log.configuration.LogESAutoConfiguration,\ com.tencent.devops.log.lucene.LuceneAutoConfiguration diff --git a/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts index 24368fca8df..578df1f0881 100644 --- a/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts +++ b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts @@ -24,11 +24,11 @@ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import org.springframework.boot.gradle.tasks.bundling.BootJar dependencies { api(project(":core:common:common-web")) api(project(":core:common:common-db-base")) + api(project(":core:common:common-util")) api("mysql:mysql-connector-java") implementation(kotlin("stdlib")) } diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt index cbe73d57039..b16cf95c667 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -1,9 +1,9 @@ package com.tencent.devops.multijar import com.mysql.jdbc.Driver +import com.tencent.devops.common.util.RegexUtils.convertToCamelCase import com.zaxxer.hikari.HikariDataSource import org.slf4j.LoggerFactory -import org.springframework.beans.factory.config.YamlPropertiesFactoryBean import org.springframework.beans.factory.support.BeanDefinitionBuilder import org.springframework.beans.factory.support.BeanDefinitionRegistry import org.springframework.beans.factory.support.BeanNameGenerator @@ -11,7 +11,6 @@ import org.springframework.boot.autoconfigure.AutoConfigureOrder import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.ImportBeanDefinitionRegistrar import org.springframework.core.Ordered -import org.springframework.core.io.ClassPathResource import org.springframework.core.type.AnnotationMetadata import org.springframework.transaction.annotation.EnableTransactionManagement @@ -19,45 +18,49 @@ import org.springframework.transaction.annotation.EnableTransactionManagement @Configuration @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement +@Suppress("MaxLineLength") class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { override fun registerBeanDefinitions( importingClassMetadata: AnnotationMetadata, registry: BeanDefinitionRegistry, importBeanNameGenerator: BeanNameGenerator ) { - multiDataSource.forEach { dataSource -> - logger.info("DataSourceDefinitionRegistrar:$dataSource") - val resource = ClassPathResource("application-$dataSource.yml") - val yamlFactory = YamlPropertiesFactoryBean() - yamlFactory.setResources(resource) - val properties = yamlFactory.getObject()!! - val dataSourceUrl = properties.getProperty("spring.datasource.url") - val datasourceUsername = properties.getProperty("spring.datasource.username") - val datasourcePassword = properties.getProperty("spring.datasource.password") - val datasourceInitSql = properties.getProperty("spring.datasource.initSql") - val leakDetectionThreshold = properties.getProperty("spring.datasource.leakDetectionThreshold") ?: 0 - val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HikariDataSource::class.java) - .addPropertyValue("poolName", "DBPool-$dataSource") - .addPropertyValue("jdbcUrl", dataSourceUrl) - .addPropertyValue("username", datasourceUsername!!) - .addPropertyValue("password", datasourcePassword!!) - .addPropertyValue("driverClassName", Driver::class.java.name) - .addPropertyValue("minimumIdle", 10) - .addPropertyValue("maximumPoolSize", 50) - .addPropertyValue("idleTimeout", 60000) - .addPropertyValue("connectionInitSql", datasourceInitSql) - .addPropertyValue("leakDetectionThreshold", leakDetectionThreshold) - .setPrimary(false) - registry.registerBeanDefinition("${dataSource}DataSource", beanDefinitionBuilder.beanDefinition) + multiDataSource.forEach forEach@{ dataSourceName -> + logger.info("register beanDefinitions :$dataSourceName") + registerBeanDefinition( + dataSourceName = dataSourceName, + registry = registry + ) } } + @Suppress("LongParameterList") + fun registerBeanDefinition( + dataSourceName: String, + registry: BeanDefinitionRegistry + ) { + val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HikariDataSource::class.java) + .addPropertyValue("poolName", "DBPool-$dataSourceName") + .addPropertyValue( + "jdbcUrl", "jdbc:mysql://${System.getProperty("spring.datasource.url")}/devops_ci_$dataSourceName?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8" + + "&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27" + ) + .addPropertyValue("username", System.getProperty("spring.datasource.username")) + .addPropertyValue("password", System.getProperty("spring.datasource.password")) + .addPropertyValue("driverClassName", Driver::class.java.name) + .addPropertyValue("minimumIdle", 10) + .addPropertyValue("maximumPoolSize", 50) + .addPropertyValue("idleTimeout", 60000) + .setPrimary(false) + registry.registerBeanDefinition("${convertToCamelCase(dataSourceName)}DataSource", beanDefinitionBuilder.beanDefinition) + } + companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) private val notNeedDataSourceService = listOf( - "buildless", "dockerhost", "metrics", "misc", "monitoring", "process","worker","websocket" + "buildless", "dockerhost", "metrics", "monitoring", "worker", "process", + "websocket", "dispatch-docker" ) - private val multiDataSource = System.getProperty("devops.multi.from") .split(",").filterNot { notNeedDataSourceService.contains(it) } } diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt index 375877a79f6..25bc1113d57 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt @@ -1,31 +1,46 @@ package com.tencent.devops.multijar import com.tencent.devops.common.db.listener.BkJooqExecuteListener +import com.tencent.devops.common.util.RegexUtils.convertToCamelCase import org.jooq.SQLDialect import org.jooq.impl.DataSourceConnectionProvider import org.jooq.impl.DefaultConfiguration import org.jooq.impl.DefaultExecuteListenerProvider +import org.slf4j.LoggerFactory import org.springframework.beans.factory.support.BeanDefinitionBuilder import org.springframework.beans.factory.support.BeanDefinitionRegistry import org.springframework.beans.factory.support.BeanNameGenerator +import org.springframework.boot.autoconfigure.AutoConfigureOrder import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.ImportBeanDefinitionRegistrar +import org.springframework.core.Ordered import org.springframework.core.type.AnnotationMetadata @Configuration +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { override fun registerBeanDefinitions( importingClassMetadata: AnnotationMetadata, registry: BeanDefinitionRegistry, importBeanNameGenerator: BeanNameGenerator ) { - multiDataSource.forEach { dataSource -> - val finalDataSource = if (dataSource == "process" || dataSource == "metrics") "shardingDataSource" else - "${dataSource}DataSource" - val connectionProvider = BeanDefinitionBuilder.genericBeanDefinition( - DataSourceConnectionProvider::class.java - ).addConstructorArgReference(finalDataSource) - registry.registerBeanDefinition("${dataSource}ConnectionProvider", connectionProvider.beanDefinition) + multiModuleName.forEach { moduleName -> + // 将dispatch-kubernetes类似字符串,转化为dispatchKubernetes + val finalModuleName = convertToCamelCase(moduleName) + logger.info("register Jooq configuration bean definition $finalModuleName") + val dataSource = if (finalModuleName == "process" || finalModuleName == "metrics") { + // process以及metrics使用分库分表数据源 + "shardingDataSource" + } else { + "${finalModuleName}DataSource" + } + + val dataSourceConnectionProvider = BeanDefinitionBuilder.genericBeanDefinition(DataSourceConnectionProvider::class.java) + .addConstructorArgReference(dataSource) + registry.registerBeanDefinition( + "${finalModuleName}ConnectionProvider", + dataSourceConnectionProvider.beanDefinition + ) val beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultConfiguration::class.java) { val configuration = DefaultConfiguration() configuration.set(SQLDialect.MYSQL) @@ -33,14 +48,18 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { configuration.set(DefaultExecuteListenerProvider(BkJooqExecuteListener())) configuration } - beanDefinitionBuilder.addPropertyReference("connectionProvider", "${dataSource}ConnectionProvider") - registry.registerBeanDefinition("${dataSource}JooqConfiguration", beanDefinitionBuilder.beanDefinition) + beanDefinitionBuilder.addPropertyReference("connectionProvider", "${finalModuleName}ConnectionProvider") + registry.registerBeanDefinition( + "${finalModuleName}JooqConfiguration", + beanDefinitionBuilder.beanDefinition + ) } } companion object { - private val notNeedJooqService = listOf("buildless", "dockerhost", "misc", "monitoring", "worker", "websocket") - private val multiDataSource = System.getProperty("devops.multi.from").split(",") - .filterNot { notNeedJooqService.contains(it) } + private val notNeedJooqConfigurationModule = listOf("buildless", "misc", "monitoring", "worker", "websocket") + private val multiModuleName = System.getProperty("devops.multi.from").split(",") + .filterNot { notNeedJooqConfigurationModule.contains(it) } + private val logger = LoggerFactory.getLogger(JooqDefinitionRegistrar::class.java) } } diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt index a64c7e2b3aa..464074c6b3e 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt @@ -30,6 +30,7 @@ import com.tencent.devops.common.db.config.DBBaseConfiguration import org.jooq.DSLContext import org.jooq.impl.DSL import org.jooq.impl.DefaultConfiguration +import org.slf4j.LoggerFactory import org.springframework.beans.factory.InjectionPoint import org.springframework.beans.factory.NoSuchBeanDefinitionException import org.springframework.beans.factory.config.ConfigurableBeanFactory @@ -43,6 +44,7 @@ import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Method + /** * * Powered By Tencent @@ -50,6 +52,7 @@ import java.lang.reflect.Method @Configuration @Import(DBBaseConfiguration::class, DataSourceDefinitionRegistrar::class, JooqDefinitionRegistrar::class) class MultijarDslContextConfiguration { + @Bean @Primary @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) @@ -57,38 +60,62 @@ class MultijarDslContextConfiguration { configurationMap: Map, injectionPoint: InjectionPoint ): DSLContext { - val annotatedElement: AnnotatedElement = injectionPoint.annotatedElement - if (annotatedElement !is Constructor<*> && annotatedElement !is Method && annotatedElement !is Field - ) { - throw IllegalArgumentException("Invalid annotatedElement type") - } - val declaringClass: Class<*> = when (annotatedElement) { + val annotatedElement = injectionPoint.annotatedElement + validateAnnotatedElementType(annotatedElement) + + val declaringClass = when (annotatedElement) { is Constructor<*> -> annotatedElement.declaringClass is Method -> annotatedElement.declaringClass is Field -> annotatedElement.declaringClass else -> throw IllegalArgumentException("Invalid annotatedElement type") } - val packageName = declaringClass.`package`.name - val serviceName = multiModelService.find { packageName.contains(it) } + val currentPackageName = declaringClass.`package`.name + val matchingModuleName = multiModuleName.find { currentPackageName.contains(it) } ?: throw NoSuchBeanDefinitionException("no jooq configuration") - val configurationName = if (packageName.contains(".misc")) { - val matchResult = miscServiceRegex.find(packageName) - "${matchResult?.groupValues?.get(1) ?: "default"}JooqConfiguration" - } else if (packageName.contains(".store")) { - "storeJooqConfiguration" - } else { - serviceName.plus("JooqConfiguration") + + val configurationName = when { + currentPackageName.contains(".misc") -> { + val matchResult = miscServiceRegex.find(currentPackageName) + "${matchResult?.groupValues?.get(1) ?: "default"}JooqConfiguration" + } + currentPackageName.contains(".store") -> "storeJooqConfiguration" + currentPackageName.contains(".dispatch") -> handleDispatchModuleDslContext(currentPackageName) + else -> matchingModuleName.plus("JooqConfiguration") } val configuration = configurationMap[configurationName] - ?: throw NoSuchBeanDefinitionException("no $configurationName") + ?: throw NoSuchBeanDefinitionException("no $configurationName $currentPackageName") return DSL.using(configuration) } + fun validateAnnotatedElementType(annotatedElement: AnnotatedElement) { + if (annotatedElement !is Constructor<*> && annotatedElement !is Method && annotatedElement !is Field) { + throw IllegalArgumentException("Invalid annotatedElement type") + } + } + + fun handleDispatchModuleDslContext(packageName: String): String { + return when { + packageName.startsWith("com.tencent.devops.dispatch.kubernetes") || + packageName.startsWith("com.tencent.devops.dispatch.startcloud") || + packageName.startsWith("com.tencent.devops.dispatch.devcloud") -> { + logger.info("dslContext Configuration: dispatchKubernetesJooqConfiguration") + "dispatchKubernetesJooqConfiguration" + } + packageName.startsWith("com.tencent.devops.dispatch.") -> { + logger.info("dslContext Configuration: dispatchJooqConfiguration|$packageName") + "dispatchJooqConfiguration" + } + else -> "defaultJooqConfiguration" + } + } + companion object { - private val multiModelService = System.getProperty("devops.multi.from").split(",") - private val miscServiceRegex = "\\.(process|project|repository|dispatch|plugin|quality|artifactory|environment)".toRegex() + private val logger = LoggerFactory.getLogger(MultijarDslContextConfiguration::class.java) + private val multiModuleName = System.getProperty("devops.multi.from").split(",") + private val miscServiceRegex = ("\\.(process|project|repository|dispatch|plugin" + + "|quality|artifactory|environment)").toRegex() } } diff --git a/support-files/templates/#etc#ci#application-misc.yml b/support-files/templates/#etc#ci#application-misc.yml index b617d9d3096..8180af92f02 100644 --- a/support-files/templates/#etc#ci#application-misc.yml +++ b/support-files/templates/#etc#ci#application-misc.yml @@ -1,68 +1,68 @@ # Misc Service Template 服务配置文件模板 spring: datasource: - project: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_project?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - repository: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_repository?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - dispatch: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_dispatch?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - plugin: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_plugin?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - quality: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_quality?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - artifactory: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_artifactory?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - environment: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_environment?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - image: - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_image?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - misc: - pkgRegex: "\\.(process|project|repository|dispatch|plugin|quality|artifactory|environment|image)" - # 数据源配置(勿随便变更配置项的顺序) - dataSourceConfigs: - - index: 0 - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_process?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ - archiveDataSourceConfigs: - - index: 0 - url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_archive_process?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 - username: __BK_CI_MYSQL_USER__ - password: __BK_CI_MYSQL_PASSWORD__ + project: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_project?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + repository: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_repository?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + dispatch: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_dispatch?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + plugin: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_plugin?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + quality: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_quality?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + artifactory: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_artifactory?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + environment: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_environment?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + image: + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_image?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + misc: + pkgRegex: "\\.(process|project|repository|dispatch|plugin|quality|artifactory|environment|image)" + # 数据源配置(勿随便变更配置项的顺序) + dataSourceConfigs: + - index: 0 + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_process?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ + archiveDataSourceConfigs: + - index: 0 + url: jdbc:mysql://__BK_CI_MYSQL_ADDR__/devops_ci_archive_process?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27 + username: __BK_CI_MYSQL_USER__ + password: __BK_CI_MYSQL_PASSWORD__ influxdb: server: __BK_CI_INFLUXDB_ADDR__ userName: __BK_CI_INFLUXDB_USER__ password: __BK_CI_INFLUXDB_PASSWORD__ - + # 服务器端口配置,在同一台机器上部署多个微服务,端口号要不同 21927 server: port: __BK_CI_MISC_API_PORT__ - + build: data: clear: switch: __BK_CI_BUILD_DATA_CLEAR_SWITCH__ maxEveryProjectHandleNum: 5 monthRange: -1 - maxKeepNum: 10000 + maxKeepNum: 10000 codeccDayRange: -14 codeccMaxKeepNum: 14 otherMonthRange: -1 @@ -91,11 +91,6 @@ image: registryPassword: __BK_CI_DOCKER_REGISTRY_PASSWORD__ imagePrefix: __BK_CI_DOCKER_IMAGE_PREFIX__ -influxdb: - server: __BK_CI_INFLUXDB_ADDR__ - userName: __BK_CI_INFLUXDB_USER__ - password: __BK_CI_INFLUXDB_PASSWORD__ - plugin: codecc: path: __BK_CODECC_DATA_DIR__/tools From a73bb3bf8247e30c16d6d44b033bd4790d6de527 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 14:56:34 +0800 Subject: [PATCH 51/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LogESAutoConfiguration.kt | 2 +- .../log/service/impl/LogServiceESImpl.kt | 1 - .../main/resources/META-INF/spring.factories | 2 +- .../multijar/DataSourceDefinitionRegistrar.kt | 28 ++++++++++--------- 4 files changed, 17 insertions(+), 16 deletions(-) rename src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/{configuration => es}/LogESAutoConfiguration.kt (98%) diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/configuration/LogESAutoConfiguration.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/es/LogESAutoConfiguration.kt similarity index 98% rename from src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/configuration/LogESAutoConfiguration.kt rename to src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/es/LogESAutoConfiguration.kt index 4d1eebc8064..4f896bb099f 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/configuration/LogESAutoConfiguration.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/es/LogESAutoConfiguration.kt @@ -25,7 +25,7 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.tencent.devops.log.configuration +package com.tencent.devops.log.es import com.tencent.devops.common.es.ESAutoConfiguration import com.tencent.devops.common.es.ESProperties diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt index 2ac2dec0f03..8798f137f14 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt @@ -96,7 +96,6 @@ import org.springframework.stereotype.Service "ReturnCount", "ComplexMethod" ) -@Service class LogServiceESImpl( private val logClient: LogClient, private val indexService: IndexService, diff --git a/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories b/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories index 97c7df4354e..c5a4f1375f7 100644 --- a/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories +++ b/src/backend/ci/core/log/biz-log/src/main/resources/META-INF/spring.factories @@ -1,3 +1,3 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.tencent.devops.log.configuration.LogESAutoConfiguration,\ +com.tencent.devops.log.es.LogESAutoConfiguration,\ com.tencent.devops.log.lucene.LuceneAutoConfiguration diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt index b16cf95c667..d957ff79808 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -25,43 +25,45 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { registry: BeanDefinitionRegistry, importBeanNameGenerator: BeanNameGenerator ) { - multiDataSource.forEach forEach@{ dataSourceName -> - logger.info("register beanDefinitions :$dataSourceName") + multiModuleName.forEach forEach@{ moduleName -> + logger.info("register datasource bean definitions :$moduleName") registerBeanDefinition( - dataSourceName = dataSourceName, + moduleName = moduleName, registry = registry ) } } @Suppress("LongParameterList") - fun registerBeanDefinition( - dataSourceName: String, + fun registerBeanDefinition( + moduleName: String, registry: BeanDefinitionRegistry ) { val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HikariDataSource::class.java) - .addPropertyValue("poolName", "DBPool-$dataSourceName") + .addPropertyValue("poolName", "DBPool-$moduleName") .addPropertyValue( - "jdbcUrl", "jdbc:mysql://${System.getProperty("spring.datasource.url")}/devops_ci_$dataSourceName?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8" + + "jdbcUrl", "jdbc:mysql://$dataSourceUrl/devops_ci_$moduleName?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8" + "&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27" ) - .addPropertyValue("username", System.getProperty("spring.datasource.username")) - .addPropertyValue("password", System.getProperty("spring.datasource.password")) + .addPropertyValue("username", dataSourceUserName) + .addPropertyValue("password", dataSourcePassword) .addPropertyValue("driverClassName", Driver::class.java.name) .addPropertyValue("minimumIdle", 10) .addPropertyValue("maximumPoolSize", 50) .addPropertyValue("idleTimeout", 60000) .setPrimary(false) - registry.registerBeanDefinition("${convertToCamelCase(dataSourceName)}DataSource", beanDefinitionBuilder.beanDefinition) + registry.registerBeanDefinition("${convertToCamelCase(moduleName)}DataSource", beanDefinitionBuilder.beanDefinition) } companion object { private val logger = LoggerFactory.getLogger(DataSourceDefinitionRegistrar::class.java) + private val dataSourceUrl = System.getProperty("spring.datasource.url") + private val dataSourceUserName = System.getProperty("spring.datasource.username") + private val dataSourcePassword = System.getProperty("spring.datasource.password") private val notNeedDataSourceService = listOf( - "buildless", "dockerhost", "metrics", "monitoring", "worker", "process", - "websocket", "dispatch-docker" + "buildless", "metrics", "monitoring", "worker", "process", "websocket", "dispatch-docker" ) - private val multiDataSource = System.getProperty("devops.multi.from") + private val multiModuleName = System.getProperty("devops.multi.from") .split(",").filterNot { notNeedDataSourceService.contains(it) } } } From 0458847f1e931e30cd53e55712e366b7f353b258 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 15:46:59 +0800 Subject: [PATCH 52/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts | 2 +- .../src/main/kotlin/plugins/task-multi-boot-run.gradle.kts | 2 +- .../multijar/boot-multijar/src/main/resources/application.yml | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 28a56cba819..7c1483839b0 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -46,5 +46,5 @@ fun addDependencies(path: String) { } val localRunMultiModules = "process,auth,image,environment,repository,ticket,project," + - "notify,openapi,quality,dispatch,dispatch-docker,dispatch-kubernetes,artifactory," + + "notify,quality,dispatch,dispatch-docker,dispatch-kubernetes,artifactory," + "monitoring,plugin,websocket,worker,misc,store,log" diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index ac17aa2d0c2..bdfe45c9db7 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -73,5 +73,5 @@ fun loadProperties(basePath: String): Properties { fun joinPath(vararg folders: String) = folders.joinToString(File.separator) tasks.getByName("compileKotlin").dependsOn("replacePlaceholders") -val localRunMultiServices = "process,auth,environment,repository,ticket,project,notify,openapi,quality,dispatch," + +val localRunMultiServices = "process,auth,environment,repository,ticket,project,notify,quality,dispatch," + "dispatch-kubernetes,artifactory,monitoring,plugin,websocket,worker,misc,store,log,image" diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml index cf3d5e1e988..3501e734bad 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml @@ -10,7 +10,6 @@ spring: - repository - project - notify - - openapi - dispatch - dispatch-docker - dispatch-kubernetes From 7beee201389777ea982b362cef398e53a7af49cc Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 16:07:28 +0800 Subject: [PATCH 53/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docker/config/DispatchDockerBeanConfiguration.kt | 2 +- .../{DataSourceConfig.kt => DispatchDataSourceConfig.kt} | 2 +- .../{JooqConfiguration.kt => DispatchJooqConfiguration.kt} | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/{DataSourceConfig.kt => DispatchDataSourceConfig.kt} (99%) rename src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/{JooqConfiguration.kt => DispatchJooqConfiguration.kt} (96%) diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt index 9f5bfabdedf..09946c3f79b 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt @@ -47,7 +47,7 @@ import org.springframework.core.Ordered @Suppress("ALL") @Configuration @ConditionalOnWebApplication -//@DependsOn(value = ["jooqConfiguration"]) +@DependsOn(value = ["dispatchJooqConfiguration"]) @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) class DispatchDockerBeanConfiguration @Autowired constructor( private val dslContext: DSLContext diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDataSourceConfig.kt similarity index 99% rename from src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt rename to src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDataSourceConfig.kt index 4a68ee55ecf..5d5b820d2b3 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DataSourceConfig.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDataSourceConfig.kt @@ -48,7 +48,7 @@ import javax.sql.DataSource @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement @ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") -class DataSourceConfig { +class DispatchDataSourceConfig { @Bean @Primary diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt similarity index 96% rename from src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt rename to src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt index 4d18fdf4afa..235338543a5 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/JooqConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt @@ -53,12 +53,12 @@ import javax.sql.DataSource * Powered By Tencent */ @Configuration -@Import(DataSourceConfig::class, DBBaseConfiguration::class) +@Import(DispatchDataSourceConfig::class, DBBaseConfiguration::class) @ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") -class JooqConfiguration { +class DispatchJooqConfiguration { companion object { - private val LOG = LoggerFactory.getLogger(JooqConfiguration::class.java) + private val LOG = LoggerFactory.getLogger(DispatchJooqConfiguration::class.java) } @Bean From 23675b5f567fc0a2ccc87fae9d5ef639111d4c73 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 16:38:23 +0800 Subject: [PATCH 54/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/bkenv.properties | 2 +- .../plugins/task-multi-boot-jar.gradle.kts | 6 ++-- .../log/service/impl/LogServiceESImpl.kt | 31 +++++++++---------- .../multijar/MultijarCommonConfiguration.kt | 18 +++++++++++ .../tencent/devops/project/config/OpConfig.kt | 8 ----- 5 files changed, 37 insertions(+), 28 deletions(-) create mode 100644 src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarCommonConfiguration.kt diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index 6cae659db55..e199d2d1a21 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -314,7 +314,7 @@ BK_CI_PROJECT_ROUTER_TAG=$BK_CI_CONSUL_DISCOVERY_TAG # BK_CI_STREAM_URL stream独立页面地址 BK_CI_STREAM_URL= # BK_CI_GIT_GITHUB_URL stream当前对接的Git源的类型如 CODE_GIT GITHUB 等,参考代码中的ScmType -BK_CI_STREAM_SCM_TYPE=CODE_GIT +BK_CI_STREAM_SCM_TYPE= CODE_GIT # BK_CI_GIT_GITCODE_URL stream跳转时用到的git url地址 BK_CI_STREAM_GIT_URL= # BK_CI_STREAM_REPORT_PREFIX stream展示报告时的前置链接 diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts index 7c1483839b0..ce99c98a30c 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -25,10 +25,10 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ tasks.register("multiBootJar") { - val finalServices = System.getProperty("devops.multi.from") ?: localRunMultiModules - val finalServiceList = finalServices.split(",").toMutableList() + val finalModules = System.getProperty("devops.multi.from") ?: localRunMultiModules + val finalModulesList = finalModules.split(",").toMutableList() rootProject.subprojects.filter { - isSpecifiedModulePath(it.path, finalServiceList) + isSpecifiedModulePath(it.path, finalModulesList) }.forEach { subProject -> addDependencies(subProject.path) } dependsOn("copyToRelease") } diff --git a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt index 8798f137f14..bba583b70db 100644 --- a/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt +++ b/src/backend/ci/core/log/biz-log/src/main/kotlin/com/tencent/devops/log/service/impl/LogServiceESImpl.kt @@ -30,7 +30,9 @@ package com.tencent.devops.log.service.impl import com.github.benmanes.caffeine.cache.Caffeine import com.tencent.devops.common.api.exception.ExecuteException import com.tencent.devops.common.api.pojo.Page +import com.tencent.devops.common.es.ESClient import com.tencent.devops.common.es.client.LogClient +import com.tencent.devops.common.log.constant.Constants import com.tencent.devops.common.log.constant.LogMessageCode.LOG_INDEX_HAS_BEEN_CLEANED import com.tencent.devops.common.log.pojo.EndPageQueryLogs import com.tencent.devops.common.log.pojo.LogLine @@ -43,7 +45,6 @@ import com.tencent.devops.common.log.pojo.message.LogMessageWithLineNo import com.tencent.devops.common.redis.RedisLock import com.tencent.devops.common.redis.RedisOperation import com.tencent.devops.common.web.utils.I18nUtil -import com.tencent.devops.common.es.ESClient import com.tencent.devops.log.event.LogOriginEvent import com.tencent.devops.log.event.LogStatusEvent import com.tencent.devops.log.event.LogStorageEvent @@ -54,17 +55,8 @@ import com.tencent.devops.log.service.IndexService import com.tencent.devops.log.service.LogService import com.tencent.devops.log.service.LogStatusService import com.tencent.devops.log.service.LogTagService -import com.tencent.devops.common.log.constant.Constants import com.tencent.devops.log.util.ESIndexUtils import com.tencent.devops.log.util.IndexNameUtils -import java.io.IOException -import java.sql.Date -import java.text.SimpleDateFormat -import java.util.concurrent.TimeUnit -import javax.ws.rs.core.MediaType -import javax.ws.rs.core.Response -import javax.ws.rs.core.StreamingOutput -import kotlin.math.ceil import org.elasticsearch.ElasticsearchStatusException import org.elasticsearch.action.admin.indices.open.OpenIndexRequest import org.elasticsearch.action.bulk.BulkRequest @@ -85,7 +77,14 @@ import org.elasticsearch.search.builder.SearchSourceBuilder import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder import org.elasticsearch.search.sort.SortOrder import org.slf4j.LoggerFactory -import org.springframework.stereotype.Service +import java.io.IOException +import java.sql.Date +import java.text.SimpleDateFormat +import java.util.concurrent.TimeUnit +import javax.ws.rs.core.MediaType +import javax.ws.rs.core.Response +import javax.ws.rs.core.StreamingOutput +import kotlin.math.ceil @Suppress( "LongParameterList", @@ -144,7 +143,7 @@ class LogServiceESImpl( if (doAddMultiLines(buf, event.buildId) == 0) { throw ExecuteException( "None of lines is inserted successfully to ES " + - "[${event.buildId}|${event.retryTime}]" + "[${event.buildId}|${event.retryTime}]" ) } else { buf.clear() @@ -691,7 +690,7 @@ class LogServiceESImpl( ) logger.info( "[$index|$buildId|$tag|$subTag|$jobId|$executeCount] " + - "doQueryInitLogs get the query builder: $boolQueryBuilder" + "doQueryInitLogs get the query builder: $boolQueryBuilder" ) val searchRequest = SearchRequest(index) @@ -763,7 +762,7 @@ class LogServiceESImpl( logger.info( "[$index|$buildId|$tag|$subTag|$jobId|$executeCount] " + - "doQueryLogsAfterLine get the query builder: $boolQueryBuilder" + "doQueryLogsAfterLine get the query builder: $boolQueryBuilder" ) val searchRequest = SearchRequest(index) .source( @@ -874,7 +873,7 @@ class LogServiceESImpl( .must(QueryBuilders.rangeQuery("lineNo").lte(end)) logger.info( "[$index|$buildId|$tag|$subTag|$jobId|$executeCount] " + - "doQueryLogsBeforeLine get the query builder: $boolQueryBuilder" + "doQueryLogsBeforeLine get the query builder: $boolQueryBuilder" ) val searchRequest = SearchRequest(index) .source( @@ -1154,7 +1153,7 @@ class LogServiceESImpl( return try { logger.info( "[${createClient.clusterName}][$index]|createIndex|: shards[${createClient.shards}]" + - " replicas[${createClient.replicas}] shardsPerNode[${createClient.shardsPerNode}]" + " replicas[${createClient.replicas}] shardsPerNode[${createClient.shardsPerNode}]" ) val request = CreateIndexRequest(index) .settings( diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarCommonConfiguration.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarCommonConfiguration.kt new file mode 100644 index 00000000000..b061f5bc6d8 --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarCommonConfiguration.kt @@ -0,0 +1,18 @@ +package com.tencent.devops.multijar + +import com.tencent.devops.leaf.plugin.LeafSpringBootProperties +import org.springframework.boot.autoconfigure.AutoConfigureOrder +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.Primary +import org.springframework.core.Ordered + +@Configuration +@AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) +class MultijarCommonConfiguration { + @Bean + @Primary + fun leafSpringBootProperties(): LeafSpringBootProperties { + return LeafSpringBootProperties() + } +} diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt index e9fc0cdb290..f5a80e77904 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt @@ -28,7 +28,6 @@ package com.tencent.devops.project.config import com.tencent.devops.common.redis.RedisOperation -import com.tencent.devops.leaf.plugin.LeafSpringBootProperties import com.tencent.devops.project.dao.ProjectDao import com.tencent.devops.project.dao.ProjectLabelRelDao import com.tencent.devops.project.dispatch.ProjectDispatcher @@ -40,7 +39,6 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.Primary @Configuration @@ -64,10 +62,4 @@ class OpConfig { redisOperation = redisOperation, projectService = projectService ) - - @Bean - @Primary - fun leafSpringBootProperties(): LeafSpringBootProperties { - return LeafSpringBootProperties() - } } From 0b477468da769dc0cb3b46fe326e2a3aad9c35eb Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 17:29:56 +0800 Subject: [PATCH 55/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/client/ClientAutoConfiguration.kt | 1 - .../tencent/devops/common/util/RegexUtils.kt | 4 +- .../BkServiceInstanceApplicationRunner.kt | 1 - .../monitoring/client/InfluxdbClient.kt | 192 ------------------ .../client/MonitoringInfluxdbClient.kt | 192 ++++++++++++++++++ .../multijar/boot-multijar/build.gradle.kts | 1 + .../multijar/DataSourceDefinitionRegistrar.kt | 1 - .../MultijarDslContextConfiguration.kt | 1 - .../api/ServiceScmWebhookResourceImpl.kt | 1 - .../tencent/devops/project/config/OpConfig.kt | 1 - 10 files changed, 195 insertions(+), 200 deletions(-) delete mode 100644 src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt diff --git a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt index 73a3447eea7..b16de4a0bb0 100644 --- a/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt +++ b/src/backend/ci/core/common/common-client/src/main/kotlin/com/tencent/devops/common/client/ClientAutoConfiguration.kt @@ -38,7 +38,6 @@ import org.springframework.beans.factory.annotation.Value import org.springframework.boot.autoconfigure.AutoConfigureAfter import org.springframework.boot.autoconfigure.AutoConfigureOrder import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean -import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.cloud.client.discovery.composite.CompositeDiscoveryClient import org.springframework.cloud.client.loadbalancer.LoadBalancerAutoConfiguration import org.springframework.context.annotation.Bean diff --git a/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt b/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt index 0fb45a84a6f..8c978acbc95 100644 --- a/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt +++ b/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt @@ -68,8 +68,8 @@ object RegexUtils { /** - * 转换驼峰,将dispatch-kubernetes类似字符串,转化为dispatchKubernetes - * */ + * 转换驼峰,将dispatch-kubernetes类似字符串,转化为dispatchKubernetes + * */ fun convertToCamelCase(input: String): String { val words = input.split("-") return if (words.size > 1) { diff --git a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt index 2d8c1e3ab7d..dbe66033277 100644 --- a/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt +++ b/src/backend/ci/core/common/common-web/src/main/kotlin/com/tencent/devops/common/web/runner/BkServiceInstanceApplicationRunner.kt @@ -51,7 +51,6 @@ class BkServiceInstanceApplicationRunner constructor( redisOperation.delete(cacheKey) // 把微服务的最新主机IP列表写入redis中 redisOperation.sadd(cacheKey, *serviceHosts) - } }.start() } diff --git a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt b/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt deleted file mode 100644 index c33597fa8c9..00000000000 --- a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. - * - * A copy of the MIT License is included in this file. - * - * - * Terms of the MIT License: - * --------------------------------------------------- - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated - * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of - * the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT - * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, - * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -package com.tencent.devops.monitoring.client - -import com.tencent.devops.common.api.annotation.InfluxTag -import org.apache.commons.lang3.reflect.FieldUtils -import org.influxdb.BatchOptions -import org.influxdb.InfluxDB -import org.influxdb.InfluxDBFactory -import org.influxdb.dto.Point -import org.influxdb.dto.Point.measurement -import org.influxdb.dto.Query -import org.influxdb.dto.QueryResult -import org.slf4j.LoggerFactory -import org.springframework.beans.factory.annotation.Value -import org.springframework.stereotype.Component -import java.lang.reflect.Field -import java.util.concurrent.Executors -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicInteger - -@Component -class MonitoringInfluxdbClient { - companion object { - private val logger = LoggerFactory.getLogger(MonitoringInfluxdbClient::class.java) - private const val actions = 1000 - private const val flushDuration = 100 - private const val bufferLimit = 100 - private const val jitterDuration = 100 - private const val mod = 1000000 - } - - @Value("\${influxdb.server:}") - val influxdbServer: String = "" - - @Value("\${influxdb.userName:}") - val influxdbUserName: String = "" - - @Value("\${influxdb.password:}") - val influxdbPassword: String = "" - - private val dbName = "monitoring" - private val monitoringRetentionPolicy = "monitoring_retention" - private val atomInt = AtomicInteger() - - private val influxDB by lazy { - - val influxdb = InfluxDBFactory.connect(influxdbServer, influxdbUserName, influxdbPassword) - - try { - // 如果指定的数据库不存在,则新建一个新的数据库,并新建一个默认的数据保留规则 - if (!databaseExist(influxdb, dbName)) { - createDatabase(influxdb) - createRetentionPolicy(influxdb) - } - } catch (ignored: Exception) { - logger.error("BKSystemErrorMonitor|Create influxdb failed:", ignored) - } finally { - influxdb.setRetentionPolicy(monitoringRetentionPolicy) - } - - influxdb.setLogLevel(InfluxDB.LogLevel.NONE) - influxdb.enableBatch(BatchOptions.DEFAULTS - .actions(actions) - .flushDuration(flushDuration) - .bufferLimit(bufferLimit) - .jitterDuration(jitterDuration) - .exceptionHandler { points: Iterable, ignored: Throwable? -> - try { - points.forEach { logger.error("BKSystemErrorMonitor|failed to write point $it", ignored) } - } catch (ignored: Exception) { - // Do nothing , 这个handler不能抛异常,否则influxdb批量插入的线程就会停止 - } - } - .threadFactory( - Executors.defaultThreadFactory() - )) - influxdb - } - - private fun createDatabase(influxdb: InfluxDB) { - influxdb.query(Query("CREATE DATABASE $dbName", "")) - influxdb.query(Query("CREATE USER $influxdbUserName WITH PASSWORD '$influxdbPassword'", "")) - influxdb.query(Query("GRANT ALL PRIVILEGES ON $dbName TO $influxdbUserName", "")) - } - - private fun createRetentionPolicy(influxdb: InfluxDB) { - influxdb.query( - Query( - "CREATE RETENTION POLICY $monitoringRetentionPolicy ON $dbName DURATION 30d REPLICATION 1 DEFAULT", - "" - ) - ) - } - - private fun databaseExist(influxdb: InfluxDB, dbName: String): Boolean { - val result = influxdb.query(Query("SHOW DATABASES", "")) - val databaseNames = result.results?.get(index = 0)?.series?.get(index = 0)?.values - if (databaseNames != null) { - for (database in databaseNames) { - if (dbName == database[0].toString()) { - return true - } - } - } - return false - } - - fun insert(any: Any) { - val (fields, tags) = getFieldTagMap(any) - insert(any::class.java.simpleName, tags, fields) - } - - fun insert(measurement: String, tags: Map, fields: Map) { - val builder: Point.Builder = measurement(measurement) - builder.tag(tags) - builder.fields(fields) - builder.time(System.currentTimeMillis() * mod + getTail() % mod, TimeUnit.NANOSECONDS) - influxDB.write(dbName, monitoringRetentionPolicy, builder.build()) - } - - fun select(sql: String): QueryResult? { - return influxDB.query(Query(sql, dbName)) - } - - private fun getFieldTagMap(any: Any): Pair/*field*/, Map/*tag*/> { - val field: MutableMap = mutableMapOf() - val tag: MutableMap = mutableMapOf() - - FieldUtils.getAllFields(any.javaClass).forEach { - it.isAccessible = true - if (it.isAnnotationPresent(InfluxTag::class.java)) { - tag[it.name] = it.get(any)?.toString() ?: "" - } else { - generateField(it, any, field) - } - } - - return field to tag - } - - private fun generateField( - it: Field, - any: Any, - field: MutableMap - ) { - val value = it.get(any) - field[it.name] = if (value == null) null else { - if (value is Number) value else value.toString() - } - } - - /** - * 添加尾巴,避免被覆盖 - */ - private fun getTail(): Int { - val tail = atomInt.incrementAndGet() - return if (tail < 0) { - if (atomInt.compareAndSet(tail, 0)) { - 0 - } else { - atomInt.incrementAndGet() - } - } else { - tail - } - } -} diff --git a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt b/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt index e69de29bb2d..c33597fa8c9 100644 --- a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt +++ b/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt @@ -0,0 +1,192 @@ +/* + * Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. + * + * A copy of the MIT License is included in this file. + * + * + * Terms of the MIT License: + * --------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT + * LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +package com.tencent.devops.monitoring.client + +import com.tencent.devops.common.api.annotation.InfluxTag +import org.apache.commons.lang3.reflect.FieldUtils +import org.influxdb.BatchOptions +import org.influxdb.InfluxDB +import org.influxdb.InfluxDBFactory +import org.influxdb.dto.Point +import org.influxdb.dto.Point.measurement +import org.influxdb.dto.Query +import org.influxdb.dto.QueryResult +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Value +import org.springframework.stereotype.Component +import java.lang.reflect.Field +import java.util.concurrent.Executors +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicInteger + +@Component +class MonitoringInfluxdbClient { + companion object { + private val logger = LoggerFactory.getLogger(MonitoringInfluxdbClient::class.java) + private const val actions = 1000 + private const val flushDuration = 100 + private const val bufferLimit = 100 + private const val jitterDuration = 100 + private const val mod = 1000000 + } + + @Value("\${influxdb.server:}") + val influxdbServer: String = "" + + @Value("\${influxdb.userName:}") + val influxdbUserName: String = "" + + @Value("\${influxdb.password:}") + val influxdbPassword: String = "" + + private val dbName = "monitoring" + private val monitoringRetentionPolicy = "monitoring_retention" + private val atomInt = AtomicInteger() + + private val influxDB by lazy { + + val influxdb = InfluxDBFactory.connect(influxdbServer, influxdbUserName, influxdbPassword) + + try { + // 如果指定的数据库不存在,则新建一个新的数据库,并新建一个默认的数据保留规则 + if (!databaseExist(influxdb, dbName)) { + createDatabase(influxdb) + createRetentionPolicy(influxdb) + } + } catch (ignored: Exception) { + logger.error("BKSystemErrorMonitor|Create influxdb failed:", ignored) + } finally { + influxdb.setRetentionPolicy(monitoringRetentionPolicy) + } + + influxdb.setLogLevel(InfluxDB.LogLevel.NONE) + influxdb.enableBatch(BatchOptions.DEFAULTS + .actions(actions) + .flushDuration(flushDuration) + .bufferLimit(bufferLimit) + .jitterDuration(jitterDuration) + .exceptionHandler { points: Iterable, ignored: Throwable? -> + try { + points.forEach { logger.error("BKSystemErrorMonitor|failed to write point $it", ignored) } + } catch (ignored: Exception) { + // Do nothing , 这个handler不能抛异常,否则influxdb批量插入的线程就会停止 + } + } + .threadFactory( + Executors.defaultThreadFactory() + )) + influxdb + } + + private fun createDatabase(influxdb: InfluxDB) { + influxdb.query(Query("CREATE DATABASE $dbName", "")) + influxdb.query(Query("CREATE USER $influxdbUserName WITH PASSWORD '$influxdbPassword'", "")) + influxdb.query(Query("GRANT ALL PRIVILEGES ON $dbName TO $influxdbUserName", "")) + } + + private fun createRetentionPolicy(influxdb: InfluxDB) { + influxdb.query( + Query( + "CREATE RETENTION POLICY $monitoringRetentionPolicy ON $dbName DURATION 30d REPLICATION 1 DEFAULT", + "" + ) + ) + } + + private fun databaseExist(influxdb: InfluxDB, dbName: String): Boolean { + val result = influxdb.query(Query("SHOW DATABASES", "")) + val databaseNames = result.results?.get(index = 0)?.series?.get(index = 0)?.values + if (databaseNames != null) { + for (database in databaseNames) { + if (dbName == database[0].toString()) { + return true + } + } + } + return false + } + + fun insert(any: Any) { + val (fields, tags) = getFieldTagMap(any) + insert(any::class.java.simpleName, tags, fields) + } + + fun insert(measurement: String, tags: Map, fields: Map) { + val builder: Point.Builder = measurement(measurement) + builder.tag(tags) + builder.fields(fields) + builder.time(System.currentTimeMillis() * mod + getTail() % mod, TimeUnit.NANOSECONDS) + influxDB.write(dbName, monitoringRetentionPolicy, builder.build()) + } + + fun select(sql: String): QueryResult? { + return influxDB.query(Query(sql, dbName)) + } + + private fun getFieldTagMap(any: Any): Pair/*field*/, Map/*tag*/> { + val field: MutableMap = mutableMapOf() + val tag: MutableMap = mutableMapOf() + + FieldUtils.getAllFields(any.javaClass).forEach { + it.isAccessible = true + if (it.isAnnotationPresent(InfluxTag::class.java)) { + tag[it.name] = it.get(any)?.toString() ?: "" + } else { + generateField(it, any, field) + } + } + + return field to tag + } + + private fun generateField( + it: Field, + any: Any, + field: MutableMap + ) { + val value = it.get(any) + field[it.name] = if (value == null) null else { + if (value is Number) value else value.toString() + } + } + + /** + * 添加尾巴,避免被覆盖 + */ + private fun getTail(): Int { + val tail = atomInt.incrementAndGet() + return if (tail < 0) { + if (atomInt.compareAndSet(tail, 0)) { + 0 + } else { + atomInt.incrementAndGet() + } + } else { + tail + } + } +} diff --git a/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts index 578df1f0881..549003f5b72 100644 --- a/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts +++ b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts @@ -30,6 +30,7 @@ dependencies { api(project(":core:common:common-db-base")) api(project(":core:common:common-util")) api("mysql:mysql-connector-java") + api("com.tencent.devops.leaf:leaf-boot-starter") implementation(kotlin("stdlib")) } plugins { diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt index d957ff79808..73c9becc708 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -14,7 +14,6 @@ import org.springframework.core.Ordered import org.springframework.core.type.AnnotationMetadata import org.springframework.transaction.annotation.EnableTransactionManagement - @Configuration @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt index 464074c6b3e..60cecf086f5 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt @@ -44,7 +44,6 @@ import java.lang.reflect.Constructor import java.lang.reflect.Field import java.lang.reflect.Method - /** * * Powered By Tencent diff --git a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt index 105c9a1220b..45075f00109 100644 --- a/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt +++ b/src/backend/ci/core/process/biz-process/src/main/kotlin/com/tencent/devops/process/api/ServiceScmWebhookResourceImpl.kt @@ -39,7 +39,6 @@ import com.tencent.devops.process.webhook.CodeWebhookEventDispatcher import com.tencent.devops.process.webhook.pojo.event.commit.GithubWebhookEvent import org.springframework.amqp.rabbit.core.RabbitTemplate import org.springframework.beans.factory.annotation.Autowired -import org.springframework.context.annotation.Lazy @RestResource class ServiceScmWebhookResourceImpl @Autowired constructor( diff --git a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt index f5a80e77904..339bec6c27b 100644 --- a/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt +++ b/src/backend/ci/core/project/biz-project/src/main/kotlin/com/tencent/devops/project/config/OpConfig.kt @@ -40,7 +40,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration - @Configuration @Suppress("LongParameterList") class OpConfig { From b927791e5e5f6757c24fb2cb25a4684dc25b87f1 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 17:32:30 +0800 Subject: [PATCH 56/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt b/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt index 8c978acbc95..2d3b8a37b2b 100644 --- a/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt +++ b/src/backend/ci/core/common/common-util/src/main/kotlin/com/tencent/devops/common/util/RegexUtils.kt @@ -66,7 +66,6 @@ object RegexUtils { } } - /** * 转换驼峰,将dispatch-kubernetes类似字符串,转化为dispatchKubernetes * */ From 63bf856cfe0209b58f4dca6790fd077dd5ccbb92 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 17:43:34 +0800 Subject: [PATCH 57/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/plugins/task-docker-build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts index 568814f4a4a..621b8f27820 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-docker-build.gradle.kts @@ -49,7 +49,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-XX:+PrintTenuringDistribution", "-XX:+PrintGCDetails", "-XX:+PrintGCDateStamps", - "-XX:MaxGCPauseMillis=200", + "-XX:MaxGCPauseMillis=100", "-XX:+UseG1GC", "-XX:NativeMemoryTracking=summary", "-XX:+HeapDumpOnOutOfMemoryError", From 57cf67dc6584a22415881f28831a892a4acd9f87 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Wed, 20 Mar 2024 17:45:55 +0800 Subject: [PATCH 58/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tencent/devops/multijar/JooqDefinitionRegistrar.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt index 25bc1113d57..9be9df3a9aa 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt @@ -35,8 +35,9 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { "${finalModuleName}DataSource" } - val dataSourceConnectionProvider = BeanDefinitionBuilder.genericBeanDefinition(DataSourceConnectionProvider::class.java) - .addConstructorArgReference(dataSource) + val dataSourceConnectionProvider = BeanDefinitionBuilder.genericBeanDefinition( + DataSourceConnectionProvider::class.java + ).addConstructorArgReference(dataSource) registry.registerBeanDefinition( "${finalModuleName}ConnectionProvider", dataSourceConnectionProvider.beanDefinition From d77913e168918ca8705920e4e85d6d3d10916ecb Mon Sep 17 00:00:00 2001 From: greysonfang Date: Fri, 29 Mar 2024 17:30:24 +0800 Subject: [PATCH 59/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dispatch/docker/config/DispatchDockerBeanConfiguration.kt | 2 +- ...ooqConfiguration.kt => DispatchDslContextConfiguration.kt} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/{DispatchJooqConfiguration.kt => DispatchDslContextConfiguration.kt} (97%) diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt index 09946c3f79b..334c2f9eb35 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt @@ -47,7 +47,7 @@ import org.springframework.core.Ordered @Suppress("ALL") @Configuration @ConditionalOnWebApplication -@DependsOn(value = ["dispatchJooqConfiguration"]) +@DependsOn(value = ["DispatchDslContextConfiguration"]) @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) class DispatchDockerBeanConfiguration @Autowired constructor( private val dslContext: DSLContext diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDslContextConfiguration.kt similarity index 97% rename from src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt rename to src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDslContextConfiguration.kt index 235338543a5..1a50ac46dea 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDslContextConfiguration.kt @@ -55,10 +55,10 @@ import javax.sql.DataSource @Configuration @Import(DispatchDataSourceConfig::class, DBBaseConfiguration::class) @ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") -class DispatchJooqConfiguration { +class DispatchDslContextConfiguration { companion object { - private val LOG = LoggerFactory.getLogger(DispatchJooqConfiguration::class.java) + private val LOG = LoggerFactory.getLogger(DispatchDslContextConfiguration::class.java) } @Bean From 461b6a1eca1796c86fbe42a3be551ca4b3c7b959 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 8 Apr 2024 09:39:52 +0800 Subject: [PATCH 60/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dispatch/docker/config/DispatchDockerBeanConfiguration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt index 334c2f9eb35..94f1cfc1b7c 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt @@ -47,7 +47,7 @@ import org.springframework.core.Ordered @Suppress("ALL") @Configuration @ConditionalOnWebApplication -@DependsOn(value = ["DispatchDslContextConfiguration"]) +@DependsOn(value = ["dispatchDslContextConfiguration"]) @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) class DispatchDockerBeanConfiguration @Autowired constructor( private val dslContext: DSLContext From bb3bc74d3692fa8d70e0d2dabe22d73657d378e1 Mon Sep 17 00:00:00 2001 From: greysonfang Date: Mon, 22 Apr 2024 23:05:06 +0800 Subject: [PATCH 61/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../docker/config/DispatchDockerBeanConfiguration.kt | 2 +- ...ntextConfiguration.kt => DispatchJooqConfiguration.kt} | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/{DispatchDslContextConfiguration.kt => DispatchJooqConfiguration.kt} (95%) diff --git a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt index 94f1cfc1b7c..09946c3f79b 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch-docker/src/main/kotlin/com/tencent/devops/dispatch/docker/config/DispatchDockerBeanConfiguration.kt @@ -47,7 +47,7 @@ import org.springframework.core.Ordered @Suppress("ALL") @Configuration @ConditionalOnWebApplication -@DependsOn(value = ["dispatchDslContextConfiguration"]) +@DependsOn(value = ["dispatchJooqConfiguration"]) @AutoConfigureOrder(Ordered.LOWEST_PRECEDENCE) class DispatchDockerBeanConfiguration @Autowired constructor( private val dslContext: DSLContext diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDslContextConfiguration.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt similarity index 95% rename from src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDslContextConfiguration.kt rename to src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt index 1a50ac46dea..01e9aa784ea 100644 --- a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchDslContextConfiguration.kt +++ b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/configuration/DispatchJooqConfiguration.kt @@ -55,10 +55,10 @@ import javax.sql.DataSource @Configuration @Import(DispatchDataSourceConfig::class, DBBaseConfiguration::class) @ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") -class DispatchDslContextConfiguration { +class DispatchJooqConfiguration { companion object { - private val LOG = LoggerFactory.getLogger(DispatchDslContextConfiguration::class.java) + private val LOG = LoggerFactory.getLogger(DispatchJooqConfiguration::class.java) } @Bean @@ -83,7 +83,7 @@ class DispatchDslContextConfiguration { } if ((packageName.startsWith("com.tencent.devops.dispatch."))) { - val configuration = configurationMap["dispatchJooqConfiguration"] + val configuration = configurationMap["jooqConfiguration"] ?: throw NoSuchBeanDefinitionException("no dispatchJooqConfiguration") LOG.info("dslContext_init|dispatchJooqConfiguration|${declaringClass.name}") return DSL.using(configuration) @@ -93,7 +93,7 @@ class DispatchDslContextConfiguration { } @Bean - fun dispatchJooqConfiguration( + fun jooqConfiguration( @Qualifier("dispatchDataSource") dispatchWindowsDataSource: DataSource, @Qualifier("bkJooqExecuteListenerProvider") From ba928c1fa8f3ab44121479798ef6f382054bd2dc Mon Sep 17 00:00:00 2001 From: greysonfang Date: Tue, 23 Apr 2024 10:52:34 +0800 Subject: [PATCH 62/62] =?UTF-8?q?feat=EF=BC=9A=E8=93=9D=E7=9B=BE=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=BC=80=E5=8F=91=E5=AE=9E=E7=8E=B0=20#9576?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/task-multi-boot-run.gradle.kts | 8 -------- .../multijar/DataSourceDefinitionRegistrar.kt | 17 ++++++++++++----- .../devops/multijar/JooqDefinitionRegistrar.kt | 14 ++++++++------ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts index bdfe45c9db7..d4c204e16ef 100644 --- a/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -29,14 +29,6 @@ import org.springframework.boot.gradle.tasks.run.BootRun import java.util.Properties tasks.register("multiBootRun") { - - val bkEnvPath = joinPath(projectDir.absolutePath, "bkenv.properties") - val bkEnvProperties = Properties() - file(bkEnvPath).let { - if (it.exists()) { - bkEnvProperties.load(it.inputStream()) - } - } doFirst { systemProperty("devops.multi.from", localRunMultiServices) systemProperty("spring.datasource.url", System.getProperty("mysqlURL")) diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt index 73c9becc708..3aa2dd40d36 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -40,10 +40,7 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { ) { val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HikariDataSource::class.java) .addPropertyValue("poolName", "DBPool-$moduleName") - .addPropertyValue( - "jdbcUrl", "jdbc:mysql://$dataSourceUrl/devops_ci_$moduleName?useSSL=false&autoReconnect=true&serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8" + - "&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27" - ) + .addPropertyValue("jdbcUrl", getModuleJdbcUrl(moduleName)) .addPropertyValue("username", dataSourceUserName) .addPropertyValue("password", dataSourcePassword) .addPropertyValue("driverClassName", Driver::class.java.name) @@ -51,7 +48,17 @@ class DataSourceDefinitionRegistrar : ImportBeanDefinitionRegistrar { .addPropertyValue("maximumPoolSize", 50) .addPropertyValue("idleTimeout", 60000) .setPrimary(false) - registry.registerBeanDefinition("${convertToCamelCase(moduleName)}DataSource", beanDefinitionBuilder.beanDefinition) + registry.registerBeanDefinition( + "${convertToCamelCase(moduleName)}DataSource", + beanDefinitionBuilder.beanDefinition + ) + } + + fun getModuleJdbcUrl(moduleName: String): String { + return "jdbc:mysql://$dataSourceUrl/devops_ci_$moduleName?useSSL=false&autoReconnect=true&" + + "serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8" + + "&allowMultiQueries=true&sessionVariables=sql_mode=%27STRICT_TRANS_TABLES," + + "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION%27" } companion object { diff --git a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt index 9be9df3a9aa..86c464af9d6 100644 --- a/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt @@ -35,24 +35,26 @@ class JooqDefinitionRegistrar : ImportBeanDefinitionRegistrar { "${finalModuleName}DataSource" } - val dataSourceConnectionProvider = BeanDefinitionBuilder.genericBeanDefinition( - DataSourceConnectionProvider::class.java - ).addConstructorArgReference(dataSource) + val dataSourceConnectionProvider = BeanDefinitionBuilder.genericBeanDefinition(DataSourceConnectionProvider::class.java) + .addConstructorArgReference(dataSource) registry.registerBeanDefinition( "${finalModuleName}ConnectionProvider", dataSourceConnectionProvider.beanDefinition ) - val beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultConfiguration::class.java) { + val jooqConfigurationBeanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultConfiguration::class.java) { val configuration = DefaultConfiguration() configuration.set(SQLDialect.MYSQL) configuration.settings().isRenderSchema = false configuration.set(DefaultExecuteListenerProvider(BkJooqExecuteListener())) configuration } - beanDefinitionBuilder.addPropertyReference("connectionProvider", "${finalModuleName}ConnectionProvider") + jooqConfigurationBeanDefinitionBuilder.addPropertyReference( + "connectionProvider", + "${finalModuleName}ConnectionProvider" + ) registry.registerBeanDefinition( "${finalModuleName}JooqConfiguration", - beanDefinitionBuilder.beanDefinition + jooqConfigurationBeanDefinitionBuilder.beanDefinition ) } }