Skip to content

Commit

Permalink
Merge pull request #8457 from sawyersong2/issue8456_github_branch
Browse files Browse the repository at this point in the history
feat: 补充构建机类型的国际化配置 #8456
  • Loading branch information
irwinsun authored Mar 7, 2023
2 parents b69407a + 255b246 commit 57b8659
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ abstract class AbstractDockerHostBuildService constructor(
dockerBuildInfo.imageRDType.equals(ImageRDTypeEnum.SELF_DEVELOPED.name, ignoreCase = true)) {
log(
buildId = dockerBuildInfo.buildId,
message = "自研公共镜像,不从仓库拉取,直接从本地启动...",
message = "Public image, directly started from the local...",
tag = taskId,
containerHashId = dockerBuildInfo.containerHashId
)
Expand All @@ -146,16 +146,18 @@ abstract class AbstractDockerHostBuildService constructor(
containerHashId = dockerBuildInfo.containerHashId
)
} catch (t: UnauthorizedException) {
val errorMessage = "无权限拉取镜像:$imageName,请检查镜像路径或凭证是否正确;" +
"[buildId=${dockerBuildInfo.buildId}][containerHashId=${dockerBuildInfo.containerHashId}]"
val errorMessage = "No permission to pull image $imageName,Please check if the image path or " +
"credentials are correct. [buildId=${dockerBuildInfo.buildId}]" +
"[containerHashId=${dockerBuildInfo.containerHashId}]"
logger.error(errorMessage, t)
// 直接失败,禁止使用本地镜像
throw ContainerException(
errorCodeEnum = ErrorCodeEnum.NO_AUTH_PULL_IMAGE_ERROR,
message = errorMessage
)
} catch (t: NotFoundException) {
val errorMessage = "镜像不存在:$imageName,请检查镜像路径或凭证是否正确;" +
val errorMessage = "Image does not exist $imageName!!," +
"Please check if the image path or credentials are correct." +
"[buildId=${dockerBuildInfo.buildId}][containerHashId=${dockerBuildInfo.containerHashId}]"
logger.error(errorMessage, t)
// 直接失败,禁止使用本地镜像
Expand All @@ -167,13 +169,13 @@ abstract class AbstractDockerHostBuildService constructor(
logger.warn("Fail to pull the image $imageName of build ${dockerBuildInfo.buildId}", t)
log(
buildId = dockerBuildInfo.buildId,
message = "拉取镜像失败,错误信息${t.message}",
message = "Failed to pull image${t.message}",
tag = taskId,
containerHashId = dockerBuildInfo.containerHashId
)
log(
buildId = dockerBuildInfo.buildId,
message = "尝试使用本地镜像启动...",
message = "Trying to boot from a local image...",
tag = taskId,
containerHashId = dockerBuildInfo.containerHashId
)
Expand All @@ -199,10 +201,10 @@ abstract class AbstractDockerHostBuildService constructor(
)
val dockerImageName = CommonUtils.normalizeImageName(imageName)
val taskId = if (!containerId.isNullOrBlank()) VMUtils.genStartVMTaskId(containerId!!) else ""
log(buildId, "开始拉取镜像,镜像名称:$dockerImageName", taskId, containerHashId)
log(buildId, "Start pulling image $dockerImageName", taskId, containerHashId)
httpLongDockerCli.pullImageCmd(dockerImageName).withAuthConfig(authConfig)
.exec(MyPullImageResultCallback(buildId, dockerHostBuildApi, taskId, containerHashId)).awaitCompletion()
log(buildId, "拉取镜像成功,准备启动构建环境...", taskId, containerHashId)
log(buildId, "Pull the image successfully, ready to start the build environment...", taskId, containerHashId)
return Result(true)
}

Expand Down Expand Up @@ -299,7 +301,7 @@ abstract class AbstractDockerHostBuildService constructor(
dockerHostBuildApi.postLog(
buildId = buildId,
red = false,
message = "正在拉取镜像,第${lays}层,进度$currentProgress%",
message = "Pulling image, layer $lays,process$currentProgress%",
tag = startTaskId,
jobId = containerHashId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ class ContainerCustomizedRunHandler(
log(
buildId = buildId,
red = true,
message = "启动构建环境失败,错误信息:${er.message}",
message = "Failed to start build environment: ${er.message}",
tag = taskId(),
containerHashId = containerHashId
)
if (er is NotFoundException) {
throw ContainerException(
errorCodeEnum = ErrorCodeEnum.IMAGE_NOT_EXIST_ERROR,
message = "构建镜像不存在"
message = "Image does not exist."
)
} else {
throw ContainerException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,15 @@ class ContainerPullImageHandler(
registryUser = registryUser,
registryPwd = registryPwd
)
log(buildId, "开始拉取镜像,镜像名称:$formatImageName!!", taskId, containerHashId)
log(buildId, "Start pulling image $formatImageName!!", taskId, containerHashId)
httpLongDockerCli.pullImageCmd(formatImageName!!).withAuthConfig(authConfig)
.exec(MyPullImageResultCallback(buildId, dockerHostBuildApi, taskId, containerHashId))
.awaitCompletion()
log(buildId, "拉取镜像成功,准备启动构建环境...", taskId, containerHashId)
log(buildId, "Pull the image successfully, " +
"ready to start the build environment...", taskId, containerHashId)
} catch (t: UnauthorizedException) {
val errorMessage = "无权限拉取镜像:$formatImageName,请检查镜像路径或凭证是否正确;" +
val errorMessage = "No permission to pull image $formatImageName" +
"Please check if the image path or credentials are correct." +
"$buildId|$containerHashId]"
logger.error(errorMessage, t)
// 直接失败,禁止使用本地镜像
Expand All @@ -73,20 +75,21 @@ class ContainerPullImageHandler(
message = errorMessage
)
} catch (t: NotFoundException) {
val errorMessage = "镜像不存在:$formatImageName!!,请检查镜像路径或凭证是否正确;" +
val errorMessage = "Image does not exist $formatImageName!!," +
"Please check if the image path or credentials are correct." +
"$buildId|$containerHashId]"
logger.error(errorMessage, t)
} catch (t: Throwable) {
logger.warn("Fail to pull the image $formatImageName!! of build $buildId", t)
log(
buildId = buildId,
message = "拉取镜像失败,错误信息:${t.message}",
message = "Failed to pull image: ${t.message}",
tag = taskId,
containerHashId = containerHashId
)
log(
buildId = buildId,
message = "尝试使用本地镜像启动...",
message = "Trying to boot from a local image...",
tag = taskId,
containerHashId = containerHashId
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ class ContainerRunHandler(
log(
buildId = buildId,
red = true,
message = "启动构建环境失败,错误信息:${er.message}",
message = "Failed to start build environment: ${er.message}",
tag = taskId(),
containerHashId = containerHashId
)
if (er is NotFoundException) {
throw ContainerException(
errorCodeEnum = ErrorCodeEnum.IMAGE_NOT_EXIST_ERROR,
message = "构建镜像不存在"
message = "Image does not exist."
)
} else {
throw ContainerException(
Expand Down
4 changes: 4 additions & 0 deletions support-files/sql/5001_ci_project-init_dml_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,10 @@ REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESS
REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_ZH_TW`, `MESSAGE_DETAIL_EN`) VALUES ('de14d0eb1eba47ac9476b4183a2c415c', '2101604', '01', '流水线组名称重复', '流水線組名稱重復', 'Repeat the name of the pipeline group');
REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_ZH_TW`, `MESSAGE_DETAIL_EN`) VALUES ('fb51008aeb544faebae2fc0d769bb4dd', '2101605', '01', '流水线组名称不合法', '流水線組名稱不合法', 'The name of the pipeline group is illegal');

-- 构建资源类型国际化
REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_ZH_TW`, `MESSAGE_DETAIL_EN`) VALUES ('4ac8de08f1d6463485d3ebff15aeb6e3', 'MSG_CODE_BUILD_TYPE_PREFIX_THIRD_PARTY_AGENT_ID', '20', '私有:单构建机', '私有:單構建機', 'Private: Agent');
REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_ZH_TW`, `MESSAGE_DETAIL_EN`) VALUES ('ac9adffbc77a4dcf9e803668a1b5a923', 'MSG_CODE_BUILD_TYPE_PREFIX_THIRD_PARTY_AGENT_ENV', '20', '私有:构建集群', '私有:構建集群', 'Private: Agent Pools');
REPLACE INTO `T_MESSAGE_CODE_DETAIL` (`ID`, `MESSAGE_CODE`, `MODULE_CODE`, `MESSAGE_DETAIL_ZH_CN`, `MESSAGE_DETAIL_ZH_TW`, `MESSAGE_DETAIL_EN`) VALUES ('66c2ed2f8b034ad68b6c58e33ac4376a', 'MSG_CODE_BUILD_TYPE_PREFIX_DOCKER', '20', 'Docker公共构建机', 'Docker公共構建機', 'Hosted: docker on Linux');

-- 数据源初始化
REPLACE INTO `T_DATA_SOURCE`(`ID`, `MODULE_CODE`, `DATA_SOURCE_NAME`, `FULL_FLAG`, `CLUSTER_NAME`) VALUES ('eae3670d3716427881c93fde46e28534', 'PROCESS', 'ds_0', b'0', 'prod');
Expand Down
2 changes: 1 addition & 1 deletion support-files/sql/5001_ci_store-init_dml_mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ SET NAMES utf8mb4;
use devops_ci_store;

REPLACE INTO `T_ATOM` (`ID`, `NAME`, `ATOM_CODE`, `CLASS_TYPE`, `SERVICE_SCOPE`, `JOB_TYPE`, `OS`, `CLASSIFY_ID`, `DOCS_LINK`, `ATOM_TYPE`, `ATOM_STATUS`, `ATOM_STATUS_MSG`, `SUMMARY`, `DESCRIPTION`, `CATEGROY`, `VERSION`, `LOGO_URL`, `ICON`, `DEFAULT_FLAG`, `LATEST_FLAG`, `BUILD_LESS_RUN_FLAG`, `REPOSITORY_HASH_ID`, `CODE_SRC`, `PAY_FLAG`, `HTML_TEMPLATE_VERSION`, `PROPS`, `DATA`, `PUBLISHER`, `WEIGHT`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `VISIBILITY_LEVEL`) VALUES
('0a1c7837b53e4c459c50f3228f0ed317', 'Timer', 'timerTrigger', 'timerTrigger', '', 'AGENT', '[ \"LINUX\", \"MACOS\", \"WINDOWS\" ]', 'e1bea5430f574f9ea3e0312dc7de9efa', '', 0, 7, NULL, '可通过后台定时任务方式启动流水线,支持快速定时和linux crontab高级定时', '可通过后台定时任务方式启动流水线,支持快速定时和linux crontab高级定时', 0, '1.0.0', '/ms/artifactory/api/user/artifactories/file/download?filePath=%2Ffile%2Fpng%2FtimerTrigger.png&logo=true', NULL, True, True, False, NULL, NULL, False, '1.0', '{\"newExpression\":{\"label\":\"基础规则\",\"required\":true,\"component\":\"cron-timer\"},\"advanceExpression\":{\"label\":\"计划任务规则\",\"required\":false,\"component\":\"vuex-textarea\"},\"noScm\":{\"component\":\"atom-checkbox\",\"required\":false}}', '{}', 'system', 8, 'system', 'system', '2019-03-04 18:09:39', '2019-04-18 13:41:48', 0);
('0a1c7837b53e4c459c50f3228f0ed317', 'Timer', 'timerTrigger', 'timerTrigger', '', 'AGENT', '[ \"LINUX\", \"MACOS\", \"WINDOWS\" ]', 'e1bea5430f574f9ea3e0312dc7de9efa', '', 0, 7, NULL, 'The pipeline can be started through background timing tasks, supporting fast timing and linux crontab advanced timing', '可The pipeline can be started through background timing tasks, supporting fast timing and linux crontab advanced timing', 0, '1.0.0', '/ms/artifactory/api/user/artifactories/file/download?filePath=%2Ffile%2Fpng%2FtimerTrigger.png&logo=true', NULL, True, True, False, NULL, NULL, False, '1.0', '{\"newExpression\":{\"label\":\"Basic Rules\",\"required\":true,\"component\":\"cron-timer\"},\"advanceExpression\":{\"label\":\"Scheduled task rules\",\"required\":false,\"component\":\"vuex-textarea\"},\"noScm\":{\"component\":\"atom-checkbox\",\"required\":false}}', '{}', 'system', 8, 'system', 'system', '2019-03-04 18:09:39', '2019-04-18 13:41:48', 0);
REPLACE INTO `T_ATOM` (`ID`, `NAME`, `ATOM_CODE`, `CLASS_TYPE`, `SERVICE_SCOPE`, `JOB_TYPE`, `OS`, `CLASSIFY_ID`, `DOCS_LINK`, `ATOM_TYPE`, `ATOM_STATUS`, `ATOM_STATUS_MSG`, `SUMMARY`, `DESCRIPTION`, `CATEGROY`, `VERSION`, `LOGO_URL`, `ICON`, `DEFAULT_FLAG`, `LATEST_FLAG`, `BUILD_LESS_RUN_FLAG`, `REPOSITORY_HASH_ID`, `CODE_SRC`, `PAY_FLAG`, `HTML_TEMPLATE_VERSION`, `PROPS`, `DATA`, `PUBLISHER`, `WEIGHT`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `VISIBILITY_LEVEL`) VALUES
('6868f24a5b14479683dcd6d63fdb9b42', 'Review', 'manualReviewUserTask', 'manualReviewUserTask', '[ \"pipeline\" ]', 'AGENT', '[ \"LINUX\", \"MACOS\", \"WINDOWS\" ]', 'e5de5b6e525e4b0abf6b1d88d2242fe7', '', '0', '7', NULL, '', '', '1', '1.0.0', '/ms/artifactory/api/user/artifactories/file/download?filePath=%2Ffile%2Fpng%2FmanualReviewUserTask.png&logo=true', NULL, b'1', b'1', b'1', NULL, NULL, b'0', '1.0', '{\"reviewUsers\":{\"rule\":{},\"required\":true,\"label\":\"Reviewer\",\"component\":\"user-input\",\"placeholder\":\"withing set {var}, separate multiple reviewers with commas\",\"default\":[]}}', '{}', 'system', '1', 'system', 'system', '2019-03-04 18:09:42', '2019-08-08 18:04:38', '0');
REPLACE INTO `T_ATOM` (`ID`, `NAME`, `ATOM_CODE`, `CLASS_TYPE`, `SERVICE_SCOPE`, `JOB_TYPE`, `OS`, `CLASSIFY_ID`, `DOCS_LINK`, `ATOM_TYPE`, `ATOM_STATUS`, `ATOM_STATUS_MSG`, `SUMMARY`, `DESCRIPTION`, `CATEGROY`, `VERSION`, `LOGO_URL`, `ICON`, `DEFAULT_FLAG`, `LATEST_FLAG`, `BUILD_LESS_RUN_FLAG`, `REPOSITORY_HASH_ID`, `CODE_SRC`, `PAY_FLAG`, `HTML_TEMPLATE_VERSION`, `PROPS`, `DATA`, `PUBLISHER`, `WEIGHT`, `CREATOR`, `MODIFIER`, `CREATE_TIME`, `UPDATE_TIME`, `VISIBILITY_LEVEL`) VALUES
Expand Down

0 comments on commit 57b8659

Please sign in to comment.