diff --git a/helm-charts/core/ci/base/default_env.yaml b/helm-charts/core/ci/base/default_env.yaml index afe94d25d61..79c461160b6 100644 --- a/helm-charts/core/ci/base/default_env.yaml +++ b/helm-charts/core/ci/base/default_env.yaml @@ -54,3 +54,5 @@ bkCiSm4Enabled: false bkCiMonitorRegister: false bkCiBuildDataClearSwitch: false bkCiOpenapiApiAuth: false +bkCiLocalRunEnabled: false +bkCiLocalRunTarget: host.docker.internal:8081 diff --git a/scripts/bkenv.properties b/scripts/bkenv.properties index 53c66a88ddf..e199d2d1a21 100644 --- a/scripts/bkenv.properties +++ b/scripts/bkenv.properties @@ -231,6 +231,10 @@ BK_CI_KUBERNETES_WEBCONSOLE_PROXY= BK_CI_SM4_KEY=s31^dDjd!3k # BK_CI_SM4_ENABLED BK_CI_SM4_ENABLED=false +# BK_CI_LOCAL_RUN_ENABLED +BK_CI_LOCAL_RUN_ENABLED=false +# BK_CI_LOCAL_RUN_TARGET +BK_CI_LOCAL_RUN_TARGET=host.docker.internal:8081 ########## # 3-微服务配置 diff --git a/src/backend/ci/.gitignore b/src/backend/ci/.gitignore index d858712732c..2b931b881ea 100644 --- a/src/backend/ci/.gitignore +++ b/src/backend/ci/.gitignore @@ -17,3 +17,5 @@ build.yml .codecc *.log.gz i18n/ +core/multijar/boot-multijar/src/main/resources/application-*.yml +core/multijar/boot-multijar/bkenv.properties diff --git a/src/backend/ci/buildSrc/build.gradle.kts b/src/backend/ci/buildSrc/build.gradle.kts index d17338468d1..0125325e295 100644 --- a/src/backend/ci/buildSrc/build.gradle.kts +++ b/src/backend/ci/buildSrc/build.gradle.kts @@ -22,6 +22,7 @@ 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 implementation("com.mysql:mysql-connector-j:8.0.33") } 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..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,19 +31,15 @@ plugins { val toImageRepo = System.getProperty("to.image.repo") val toImageTag = System.getProperty("to.image.tag") var toImage = System.getProperty("jib.to.image") - // 加这个判断 , 主要是为了编译kts时不报错 if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNullOrBlank())) { val service = 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 finalJvmFlags = mutableListOf( @@ -53,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", @@ -81,6 +77,7 @@ if (toImage.isNullOrBlank() || (toImageRepo.isNullOrBlank() && toImageTag.isNull "-Dio.undertow.legacy.cookie.ALLOW_HTTP_SEPARATORS_IN_V0=true", "-Dserver.port=80" ) + finalJvmFlags.addAll(jvmFlagList) jib { 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..ce99c98a30c --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-jar.gradle.kts @@ -0,0 +1,50 @@ +/* + * 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") { + val finalModules = System.getProperty("devops.multi.from") ?: localRunMultiModules + val finalModulesList = finalModules.split(",").toMutableList() + rootProject.subprojects.filter { + isSpecifiedModulePath(it.path, finalModulesList) + }.forEach { subProject -> addDependencies(subProject.path) } + dependsOn("copyToRelease") +} + +fun isSpecifiedModulePath(path: String, multiModuleList: List): Boolean { + if (!path.contains("core")) + return false + return path.contains("biz") && multiModuleList.any { module -> path.contains(module) } +} + +fun addDependencies(path: String) { + dependencies { + add("implementation", project(path)) + } +} + +val localRunMultiModules = "process,auth,image,environment,repository,ticket,project," + + "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 new file mode 100644 index 00000000000..d4c204e16ef --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-multi-boot-run.gradle.kts @@ -0,0 +1,69 @@ +/* + * 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 +import java.util.Properties + +tasks.register("multiBootRun") { + 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") + 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.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") + val bootJarTask = tasks.getByName("bootJar") + 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,environment,repository,ticket,project,notify,quality,dispatch," + + "dispatch-kubernetes,artifactory,monitoring,plugin,websocket,worker,misc,store,log,image" 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..8fd623660c4 --- /dev/null +++ b/src/backend/ci/buildSrc/src/main/kotlin/plugins/task-render-template.gradle.kts @@ -0,0 +1,108 @@ +/* + * 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 + +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 { + if (it.exists()) { + bkEnvProperties.load(it.inputStream()) + } + } + // 渲染模板 + val templatesDir = joinPath(rootDirPath, "support-files", "templates") + generateFiles(templatesDir, destDir, bkEnvProperties) + } +} + +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 -> + if (file.isFile && file.name != "application.yml") { + file.delete() + } + } +} + +fun loadProperties(basePath: String): Properties { + val properties = Properties() + properties.load(file(basePath).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/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 4a1f62761a1..cdfcb177bce 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 @@ -38,6 +38,7 @@ import com.tencent.devops.common.client.ClientTokenService import com.tencent.devops.common.event.dispatcher.pipeline.mq.MeasureEventDispatcher import com.tencent.devops.common.event.dispatcher.pipeline.mq.MQ import com.tencent.devops.common.web.mq.EXTEND_RABBIT_TEMPLATE_NAME +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 @@ -120,17 +121,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-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-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..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,2 +1,2 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ -com.tencent.devops.common.client.ClientAutoConfiguration \ No newline at end of file +com.tencent.devops.common.client.ClientAutoConfiguration 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..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 @@ -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 @@ -54,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-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..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 @@ -59,7 +60,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,13 +89,18 @@ 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 (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/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..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 @@ -27,6 +27,8 @@ package com.tencent.devops.common.util +import java.util.Locale + @Suppress("MagicNumber", "ReturnCount") object RegexUtils { @@ -63,4 +65,23 @@ 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/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 506d00e1711..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 @@ -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 @@ -24,30 +25,34 @@ 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 - ) - }" - ) - // 清空redis中微服务的主机IP列表 - redisOperation.delete(cacheKey) - // 把微服务的最新主机IP列表写入redis中 - redisOperation.sadd(cacheKey, *serviceHosts) - } - }.start() + // 当本地运行时为单体服务,不需要存储各服务的实例ip + if (!PropertyUtil.isLocalRun()) { + 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 + ) + }" + ) + + // 清空redis中微服务的主机IP列表 + redisOperation.delete(cacheKey) + // 把微服务的最新主机IP列表写入redis中 + redisOperation.sadd(cacheKey, *serviceHosts) + } + }.start() + } } } 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..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 96% 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 c416f901e57..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 @@ -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,7 +47,8 @@ import javax.sql.DataSource @Configuration @AutoConfigureOrder(Ordered.HIGHEST_PRECEDENCE) @EnableTransactionManagement -class DataSourceConfig { +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") +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 91% 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 79d4acb2619..01e9aa784ea 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 @@ -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 @@ -52,11 +53,12 @@ import javax.sql.DataSource * Powered By Tencent */ @Configuration -@Import(DataSourceConfig::class, DBBaseConfiguration::class) -class JooqConfiguration { +@Import(DispatchDataSourceConfig::class, DBBaseConfiguration::class) +@ConditionalOnMissingClass("com.tencent.devops.multijar.MultijarDslContextConfiguration") +class DispatchJooqConfiguration { companion object { - private val LOG = LoggerFactory.getLogger(JooqConfiguration::class.java) + private val LOG = LoggerFactory.getLogger(DispatchJooqConfiguration::class.java) } @Bean @@ -81,7 +83,7 @@ class JooqConfiguration { } 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) @@ -91,7 +93,7 @@ class JooqConfiguration { } @Bean - fun dispatchJooqConfiguration( + fun jooqConfiguration( @Qualifier("dispatchDataSource") dispatchWindowsDataSource: DataSource, @Qualifier("bkJooqExecuteListenerProvider") diff --git a/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchAgentService.kt b/src/backend/ci/core/dispatch/biz-dispatch/src/main/kotlin/com/tencent/devops/dispatch/service/dispatcher/agent/DispatchAgentService.kt new file mode 100644 index 00000000000..e69de29bb2d 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..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,6 +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 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", @@ -143,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() @@ -690,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) @@ -762,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( @@ -873,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( @@ -1153,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/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 50e01902bea..c6fd6dcbce1 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.core.Ordered @@ -45,6 +46,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/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 0bcaa2ed785..98e844144dd 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.multijar.MultijarDslContextConfiguration") @AutoConfigureAfter(DBBaseConfiguration::class) class JooqConfiguration { 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/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/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/MonitoringInfluxdbClient.kt similarity index 98% rename from src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/InfluxdbClient.kt rename to src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/client/MonitoringInfluxdbClient.kt index 2c88c1c7b36..c33597fa8c9 100644 --- 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/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/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt b/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt index 381d3c56f13..ac8ce0e9249 100644 --- a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/configuration/ListenerConfiguration.kt +++ b/src/backend/ci/core/misc/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/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt b/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt index 78772d6d49f..a282b79d535 100644 --- a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/AtomMonitorReportListener.kt +++ b/src/backend/ci/core/misc/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/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt b/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt index e81ebdd0f4e..e971a6098e8 100644 --- a/src/backend/ci/core/misc/biz-monitoring/src/main/kotlin/com/tencent/devops/monitoring/consumer/processor/monitor/AbstractMonitorProcessor.kt +++ b/src/backend/ci/core/misc/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/multijar/boot-multijar/build.gradle.kts b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts new file mode 100644 index 00000000000..549003f5b72 --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/build.gradle.kts @@ -0,0 +1,42 @@ +/* + * 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. + */ + +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") + api("com.tencent.devops.leaf:leaf-boot-starter") + implementation(kotlin("stdlib")) +} +plugins { + `task-render-template` + `task-multi-boot-jar` + `task-multi-boot-run` +} + +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 new file mode 100644 index 00000000000..3aa2dd40d36 --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/DataSourceDefinitionRegistrar.kt @@ -0,0 +1,75 @@ +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.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 +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 + ) { + multiModuleName.forEach forEach@{ moduleName -> + logger.info("register datasource bean definitions :$moduleName") + registerBeanDefinition( + moduleName = moduleName, + registry = registry + ) + } + } + + @Suppress("LongParameterList") + fun registerBeanDefinition( + moduleName: String, + registry: BeanDefinitionRegistry + ) { + val beanDefinitionBuilder = BeanDefinitionBuilder.rootBeanDefinition(HikariDataSource::class.java) + .addPropertyValue("poolName", "DBPool-$moduleName") + .addPropertyValue("jdbcUrl", getModuleJdbcUrl(moduleName)) + .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(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 { + 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", "metrics", "monitoring", "worker", "process", "websocket", "dispatch-docker" + ) + private val multiModuleName = 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 new file mode 100644 index 00000000000..86c464af9d6 --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/JooqDefinitionRegistrar.kt @@ -0,0 +1,68 @@ +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 + ) { + 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 jooqConfigurationBeanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultConfiguration::class.java) { + val configuration = DefaultConfiguration() + configuration.set(SQLDialect.MYSQL) + configuration.settings().isRenderSchema = false + configuration.set(DefaultExecuteListenerProvider(BkJooqExecuteListener())) + configuration + } + jooqConfigurationBeanDefinitionBuilder.addPropertyReference( + "connectionProvider", + "${finalModuleName}ConnectionProvider" + ) + registry.registerBeanDefinition( + "${finalModuleName}JooqConfiguration", + jooqConfigurationBeanDefinitionBuilder.beanDefinition + ) + } + } + + companion object { + 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/MultijarApplication.kt b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.kt new file mode 100644 index 00000000000..c11c8d2d719 --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarApplication.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.multijar + +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 MultijarApplication + +fun main(args: Array) { + MicroServiceApplication.run(MultijarApplication::class, args) +} 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/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 new file mode 100644 index 00000000000..60cecf086f5 --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/kotlin/com/tencent/devops/multijar/MultijarDslContextConfiguration.kt @@ -0,0 +1,120 @@ +/* + * 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.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 +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 +import java.lang.reflect.Field +import java.lang.reflect.Method + +/** + * + * Powered By Tencent + */ +@Configuration +@Import(DBBaseConfiguration::class, DataSourceDefinitionRegistrar::class, JooqDefinitionRegistrar::class) +class MultijarDslContextConfiguration { + + @Bean + @Primary + @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) + fun dslContext( + configurationMap: Map, + injectionPoint: InjectionPoint + ): DSLContext { + 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 currentPackageName = declaringClass.`package`.name + val matchingModuleName = multiModuleName.find { currentPackageName.contains(it) } + ?: throw NoSuchBeanDefinitionException("no jooq configuration") + + 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 $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 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/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 new file mode 100644 index 00000000000..3501e734bad --- /dev/null +++ b/src/backend/ci/core/multijar/boot-multijar/src/main/resources/application.yml @@ -0,0 +1,28 @@ +spring: + profiles: + active: + - common + - auth + - image + - process + - environment + - ticket + - repository + - project + - notify + - dispatch + - dispatch-docker + - dispatch-kubernetes + - artifactory + - plugin + - worker + - websocket + - misc + - store + - quality + - log + application: + name: multijar + desc: DevOps MultiJar Service + version: 4.0.0 + packageName: com.tencent.devops.multijar diff --git a/src/backend/ci/core/multijar/build.gradle.kts b/src/backend/ci/core/multijar/build.gradle.kts new file mode 100644 index 00000000000..81207f18ecc --- /dev/null +++ b/src/backend/ci/core/multijar/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.multijar" +} 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 b8af79eb9dd..5fd4dc9d49c 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.openapi.utils.ApigwParamUtil import com.tencent.devops.process.api.service.ServiceBuildResource @@ -57,7 +57,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?, @@ -412,7 +412,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 30bee0f68f5..115ccd95dcc 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}}") @@ -235,7 +235,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) 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 2d1c9155643..5483dc52e73 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 @@ -122,15 +123,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 @@ -141,15 +145,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 @@ -160,14 +167,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 + ) } } 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 bc7f46ea51d..1f251484aa5 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 @@ -40,7 +40,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 6cb5e69df21..14d87d18798 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 @@ -36,7 +36,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 @@ -51,7 +51,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 { @@ -132,7 +132,7 @@ class ShardingRoutingRuleAssignServiceImpl @Autowired constructor( ruleType = ruleType, dataTag = dataTag ) - val dataSourceNames = dataSourceDao.listByModule( + val dataSourceNames = projectDataSourceDao.listByModule( dslContext = dslContext, clusterName = clusterName, moduleCode = moduleCode, diff --git a/src/backend/ci/settings.gradle.kts b/src/backend/ci/settings.gradle.kts index b4d4ba39ba1..721d1a45b23 100644 --- a/src/backend/ci/settings.gradle.kts +++ b/src/backend/ci/settings.gradle.kts @@ -233,3 +233,6 @@ include(":core:metrics:api-metrics") include(":core:metrics:biz-metrics") include(":core:metrics:boot-metrics") include(":core:metrics:model-metrics") + +include("core:multijar") +include("core:multijar:boot-multijar") diff --git a/src/gateway/core/lua/router_srv.lua b/src/gateway/core/lua/router_srv.lua index 68050e5d012..1c992bc7b90 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/#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__ 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 diff --git a/support-files/templates/#etc#ci#application-store.yml b/support-files/templates/#etc#ci#application-store.yml index ad7c5f9fccd..d485ab2e02c 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_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_ENGINE_SUBSTITUTION%27 username: __BK_CI_MYSQL_USER__ password: __BK_CI_MYSQL_PASSWORD__ diff --git a/support-files/templates/gateway#core#lua#init.lua b/support-files/templates/gateway#core#lua#init.lua index 770ef9dbdf9..a1ce1d33c98 100644 --- a/support-files/templates/gateway#core#lua#init.lua +++ b/support-files/templates/gateway#core#lua#init.lua @@ -41,6 +41,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 = {