Skip to content

Commit

Permalink
feat: 构建机的最大并发数设置需要支持设置docker构建的最大并发数,只用支持linux构建机设置 TencentBlueKing#…
Browse files Browse the repository at this point in the history
…9820

# Reviewed, transaction id: 18276
  • Loading branch information
vhwweng committed Sep 12, 2024
1 parent 1c92251 commit 06d91b2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@
</div>
</div>
</div>
<div class="item-content">
<div class="item-label">{{ $t('environment.nodeInfo.dockerMaxConcurrency') }}</div>
<div class="item-value">
<div class="display-item" v-if="isEditDockerCount">
<input type="number" class="bk-form-input parallelTaskCount-input"
ref="dockerParallelTaskCount"
name="dockerParallelTaskCount"
:placeholder="$t('environment.nodeInfo.parallelTaskCountTips')"
v-validate.initial="`required|between:0,100|decimal:0`"
v-model="dockerParallelTaskCount"
:class="{ 'is-danger': errors.has('dockerParallelTaskCount') }">
</div>
<div class="editing-item" v-else>{{ nodeDetails.dockerParallelTaskCount || '--' }}</div>
</div>
<div class="handle-btn">
<div v-if="isEditDockerCount">
<span @click="saveHandle('dockerParallelTaskCount')">{{ $t('environment.save') }}</span>
<span @click="editHandle('dockerParallelTaskCount', false)">{{ $t('environment.cancel') }}</span>
</div>
<div
v-else
v-perm="{
hasPermission: nodeDetails.canEdit,
disablePermissionApi: true,
permissionData: {
projectId: projectId,
resourceType: NODE_RESOURCE_TYPE,
resourceCode: nodeHashId,
action: NODE_RESOURCE_ACTION.EDIT
}
}"
>
<span @click="editHandle('dockerParallelTaskCount', true)">{{ $t('environment.edit') }}</span>
</div>
</div>
</div>
<div class="item-content">
<div class="item-label">{{ $t('environment.status') }}</div>
<div class="item-value" :class="nodeDetails.status === 'NORMAL' ? 'normal' : 'abnormal'">
Expand Down Expand Up @@ -91,9 +127,11 @@
isEditCount: false,
isEditCreatedUser: false,
isEditNoticeType: false,
isEditDockerCount: false,
workspace: '',
createdUser: '',
parallelTaskCount: 0,
dockerParallelTaskCount: 0,
noticeTypeList: [
{ name: 'work-wechat', value: 'RTX', isChecked: true },
{ name: 'wechat', value: 'WECHAT', isChecked: false },
Expand Down Expand Up @@ -156,31 +194,55 @@
case 'noticeType':
this.isEditNoticeType = isOpen
break
case 'dockerParallelTaskCount':
this.isEditDockerCount = isOpen
if (isOpen) {
this.dockerParallelTaskCount = this.nodeDetails.dockerParallelTaskCount
this.$nextTick(() => {
this.$refs.dockerParallelTaskCount.focus()
})
}
break
default:
break
}
},
async saveHandle () {
async saveHandle (type) {
const valid = await this.$validator.validate()
if (valid) {
this.saveParallelTaskCount(this.parallelTaskCount)
if (!valid) return
switch (type) {
case 'parallelTaskCount':
this.saveParallelTaskCount(this.parallelTaskCount, 'parallelTaskCount')
break
case 'dockerParallelTaskCount':
this.saveParallelTaskCount(this.dockerParallelTaskCount, 'dockerParallelTaskCount')
break
default:
break
}
},
async saveParallelTaskCount (parallelTaskCount) {
async saveParallelTaskCount (count, type) {
let message, theme
const fn = type === 'dockerParallelTaskCount'
? 'environment/saveDockerParallelTaskCount'
: 'environment/saveParallelTaskCount'
const params = {
projectId: this.projectId,
nodeHashId: this.nodeHashId,
count: count
}
try {
await this.$store.dispatch('environment/saveParallelTaskCount', {
projectId: this.projectId,
nodeHashId: this.nodeHashId,
parallelTaskCount
})
await this.$store.dispatch(fn, params)
message = this.$t('environment.successfullySaved')
theme = 'success'
this.requestNodeDetail()
} catch (err) {
message = err.message ? err.message : err
theme = 'error'
} finally {
this.isEditCount = false
this.isEditDockerCount = false
this.$bkMessage({
message,
theme
Expand All @@ -194,7 +256,6 @@
nodeHashId: this.nodeHashId
})
this.$store.commit('environment/updateNodeDetail', { res })
this.isEditCount = false
} catch (e) {
this.handleError(
e,
Expand Down Expand Up @@ -235,7 +296,7 @@
align-items: center;
border-bottom: 1px solid #DDE4EB;
.item-label {
width: 180px;
width: 188px;
padding: 12px 20px;
border-right: 1px solid #DDE4EB;
}
Expand Down
13 changes: 11 additions & 2 deletions src/frontend/devops-environment/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ const actions = {
/**
* 设置agent构建并发数
*/
saveParallelTaskCount ({ commit }, { projectId, nodeHashId, parallelTaskCount }) {
return vue.$ajax.post(`${prefix}/user/environment/thirdPartyAgent/projects/${projectId}/nodes/${nodeHashId}/parallelTaskCount?parallelTaskCount=${parallelTaskCount}`).then(response => {
saveParallelTaskCount ({ commit }, { projectId, nodeHashId, count }) {
return vue.$ajax.post(`${prefix}/user/environment/thirdPartyAgent/projects/${projectId}/nodes/${nodeHashId}/parallelTaskCount?parallelTaskCount=${count}`).then(response => {
return response
})
},
Expand Down Expand Up @@ -286,7 +286,16 @@ const actions = {
},
enableNode (_, { projectId, envHashId, nodeHashId, enableNode }) {
return vue.$ajax.put(`${prefix}/user/environment/${projectId}/${envHashId}/enableNode/${nodeHashId}?enableNode=${enableNode}`)
},
/**
* 设置docker构建并发数
*/
saveDockerParallelTaskCount ({ commit }, { projectId, nodeHashId, count }) {
return vue.$ajax.post(`${prefix}/user/environment/thirdPartyAgent/projects/${projectId}/nodes/${nodeHashId}/dockerParallelTaskCount?count=${count}`).then(response => {
return response
})
}

}

export default actions
3 changes: 2 additions & 1 deletion src/frontend/locale/environment/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@
"set": "Set",
"remaining": "Remaining",
"canApplyCount": "Can apply count",
"selectNewNode": "Select new Agent"
"selectNewNode": "Select new Agent",
"dockerMaxConcurrency": "Maximum Docker Build Concurrency"
},
"nodeTypeMap": {
"CC": "CC",
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/locale/environment/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@
"set": "",
"remaining": "还剩",
"canApplyCount": "台可申请",
"selectNewNode": "请选择你的新节点"
"selectNewNode": "请选择你的新节点",
"dockerMaxConcurrency": "docker构建最大并发数"
},
"nodeTypeMap": {
"CC": "CC",
Expand Down

0 comments on commit 06d91b2

Please sign in to comment.