Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:第三方构建机支持使用 dcoker 运行构建任务 #9820 #11017

Merged
merged 9 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,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
Expand Down Expand Up @@ -116,9 +152,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 @@ -181,31 +219,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 @@ -219,7 +281,6 @@
nodeHashId: this.nodeHashId
})
this.$store.commit('environment/updateNodeDetail', { res })
this.isEditCount = false
} catch (e) {
this.handleError(
e,
Expand Down Expand Up @@ -260,7 +321,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<template>
<ul class="param-main">
<li
class="param-item"
v-for="(param, index) in parameters"
:key="index"
>
<bk-input
:value="param"
@change="(val) => handleChangeInput(val, index)"
>
</bk-input>
<i
class="bk-icon icon-plus-circle"
@click="plusParam()"
/>
<i
:class="{
'bk-icon icon-minus-circle': true,
'disabled': parameters.length <= 1
}"
@click="minusParam(index)"
/>
</li>
</ul>
</template>

<script>
export default {
name: 'InputParameterArray',
props: {
name: {
type: String,
default: ''
},
value: {
type: Array,
default: () => []
},
handleChange: {
type: Function,
required: true
}
},
data () {
return {
parameters: []
}
},
created () {
this.parameters = this.value
if (!this.parameters.length) this.plusParam()
},
methods: {
handleChangeInput (val, index) {
this.parameters[index] = val
this.handleChange(this.name, this.parameters)
},
plusParam () {
this.parameters.push('')
},
minusParam (index) {
if (this.parameters.length <= 1) return
this.parameters.splice(index, 1)
this.handleChange(this.name, this.parameters)
}
}
}
</script>

<style lang="scss" scoped>
.param-main {
.param-item {
margin-bottom: 10px;
display: flex;
align-items: center;
.select-custom {
flex: 1;
margin-right: 10px;
&.last-child {
margin-right: 0;
}
}
}
.bk-icon {
margin-left: 5px;
font-size: 14px;
cursor: pointer;
&.disabled {
cursor: not-allowed;
}
}
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@

watch: {
buildResourceType (val) {
if (['DOCKER', 'IDC', 'PUBLIC_DEVCLOUD'].includes(val)) {
if (['DOCKER', 'IDC', 'PUBLIC_DEVCLOUD', 'THIRD_PARTY_AGENT_ID', 'THIRD_PARTY_AGENT_ENV'].includes(val)) {
this.isLoading = true
this.searchKey = ''
this.clearData()
Expand Down Expand Up @@ -269,12 +269,15 @@
this.isLoading = true
Promise.all([this.getApiData(tab, false), this.getApiData(tab, true)]).finally(() => (this.isLoading = false))
},

getBuildResourceType () {
if (['THIRD_PARTY_AGENT_ID', 'THIRD_PARTY_AGENT_ENV'].includes(this.buildResourceType)) return 'PUBLIC_DEVCLOUD'
return this.buildResourceType
},
getApiData (tab, recommendFlag) {
this.isLoadingMore = true
const postData = Object.assign({
projectCode: this.$route.params.projectId,
agentType: this.buildResourceType,
agentType: this.getBuildResourceType(),
recommendFlag
}, tab)

Expand Down
Loading
Loading