Skip to content

Commit

Permalink
Merge pull request TencentBlueKing#10847 from carlyin0801/issue_10844…
Browse files Browse the repository at this point in the history
…_public_host_atom_cache_fix

pref:公共构建机插件缓存区路径和变量调整优化 TencentBlueKing#10844
  • Loading branch information
bkci-bot authored Sep 19, 2024
2 parents c0baabb + 839098c commit 7d3a050
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const val EXCHANGE_TASK = "exchange_vm_task"
const val ROUTE_TASK_BEGIN = "dispatch_vm_task_begin"
const val ROUTE_TASK_END = "dispatch_vm_task_end"
const val ROUTE_TASK_NEDD_END = "dispatch_vm_task_need_end"
const val ENV_PUBLIC_HOST_MAX_ATOM_FILE_CACHE_SIZE = "PUBLIC_HOST_MAX_ATOM_FILE_CACHE_SIZE"
const val ENV_THIRD_HOST_MAX_ATOM_FILE_CACHE_SIZE = "THIRD_HOST_MAX_ATOM_FILE_CACHE_SIZE"

// |Docker构建|最大并行构建量(maximum parallelism)/当前正在运行构建数量(Running):
const val BK_DOCKER_BUILD_VOLUME = "bkDockerBuildVolume"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ object AgentEnv {
const val AGENT_LOG_SAVE_MODE = "devops_log_save_mode"
const val AGENT_PROPERTIES_FILE_NAME = ".agent.properties"
const val BK_TAG = "devops_bk_tag"
const val PUBLIC_HOST_MAX_FILE_CACHE_SIZE = "devops.public.host.maxFileCacheSize"
const val THIRD_HOST_MAX_FILE_CACHE_SIZE = "devops.public.third.maxFileCacheSize"

private var projectId: String? = null
private var agentId: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import com.tencent.devops.common.pipeline.container.VMBuildContainer
import com.tencent.devops.common.pipeline.enums.BuildStatus
import com.tencent.devops.common.service.utils.CommonUtils
import com.tencent.devops.common.webhook.pojo.code.BK_CI_RUN
import com.tencent.devops.dispatch.constants.ENV_PUBLIC_HOST_MAX_ATOM_FILE_CACHE_SIZE
import com.tencent.devops.dispatch.constants.ENV_THIRD_HOST_MAX_ATOM_FILE_CACHE_SIZE
import com.tencent.devops.process.pojo.BuildTask
import com.tencent.devops.process.pojo.BuildTemplateAcrossInfo
import com.tencent.devops.process.pojo.BuildVariables
Expand Down Expand Up @@ -431,16 +433,16 @@ open class MarketAtomTask : ITask() {
} else {
// 如果是公共构建机,插件包缓存放入流水线的工作空间上一级目录中
// 如果workspace路径是相对路径.,workspace.parentFile会为空,故需用file对象包装一下
File(workspace.parentFile, "").absolutePath
File(workspace.parentFile, "cache").absolutePath
}
val fileCacheDir = "$cacheDirPrefix${File.separator}$atomExecuteFileDir"
// 获取构建机缓存文件区域大小
val maxFileCacheSize = if (BuildEnv.isThirdParty()) {
AgentEnv.getEnvProp(AgentEnv.THIRD_HOST_MAX_FILE_CACHE_SIZE)?.toLong()
?: DEFAULT_THIRD_HOST_MAX_FILE_CACHE_SIZE
AgentEnv.getEnvProp(ENV_THIRD_HOST_MAX_ATOM_FILE_CACHE_SIZE)?.toLong()
?: DEFAULT_THIRD_HOST_MAX_ATOM_FILE_CACHE_SIZE
} else {
AgentEnv.getEnvProp(AgentEnv.PUBLIC_HOST_MAX_FILE_CACHE_SIZE)?.toLong()
?: DEFAULT_PUBLIC_HOST_MAX_FILE_CACHE_SIZE
AgentEnv.getEnvProp(ENV_PUBLIC_HOST_MAX_ATOM_FILE_CACHE_SIZE)?.toLong()
?: DEFAULT_PUBLIC_HOST_MAX_ATOM_FILE_CACHE_SIZE
}
logger.info("getDiskLruFileCache fileCacheDir:$fileCacheDir,maxFileCacheSize:$maxFileCacheSize")
val bkDiskLruFileCache = BkDiskLruFileCacheFactory.getDiskLruFileCache(fileCacheDir, maxFileCacheSize)
Expand Down Expand Up @@ -1103,8 +1105,8 @@ open class MarketAtomTask : ITask() {
private const val DIR_ENV = "bk_data_dir"
private const val INPUT_ENV = "bk_data_input"
private const val OUTPUT_ENV = "bk_data_output"
private const val DEFAULT_PUBLIC_HOST_MAX_FILE_CACHE_SIZE = 209715200L
private const val DEFAULT_THIRD_HOST_MAX_FILE_CACHE_SIZE = 2147483648L
private const val DEFAULT_PUBLIC_HOST_MAX_ATOM_FILE_CACHE_SIZE = 209715200L
private const val DEFAULT_THIRD_HOST_MAX_ATOM_FILE_CACHE_SIZE = 2147483648L
private val logger = LoggerFactory.getLogger(MarketAtomTask::class.java)
}
}

0 comments on commit 7d3a050

Please sign in to comment.