diff --git a/spug_api/apps/pipeline/utils.py b/spug_api/apps/pipeline/utils.py index 04f60aa..e0f2d13 100644 --- a/spug_api/apps/pipeline/utils.py +++ b/spug_api/apps/pipeline/utils.py @@ -131,7 +131,7 @@ class NodeExecutor: node.source = source = AttrDict(node.source) node.destination = destination = AttrDict(node.destination) host = Host.objects.get(pk=source.target) - local_dir = local_path = os.path.join(settings.TRANSFER_DIR, uuid4().hex) + local_dir = os.path.join(settings.TRANSFER_DIR, uuid4().hex) os.makedirs(local_dir) remote_dir = f'{host.username}@{host.hostname}:{source.path}' with host.get_ssh() as ssh: @@ -139,6 +139,8 @@ class NodeExecutor: if code == 0: remote_dir = f'{host.username}@{host.hostname}:{os.path.dirname(source.path)}' local_path = os.path.join(local_dir, os.path.basename(source.path)) + else: + local_path = local_dir + '/' with tempfile.NamedTemporaryFile(mode='w') as fp: fp.write(host.pkey or AppSetting.get('private_key')) @@ -192,7 +194,7 @@ class NodeExecutor: threads = [] with futures.ThreadPoolExecutor(max_workers=self.max_workers) as executor: for host in Host.objects.filter(id__in=node.targets): - t = executor.submit(self._data_transfer, node, host, f'{local_path}{os.sep}', node.path) + t = executor.submit(self._data_transfer, node, host, f'{local_path}/', node.path) threads.append(t) results = [x.result() for x in futures.as_completed(threads)] shutil.rmtree(local_path) diff --git a/spug_api/apps/pipeline/views.py b/spug_api/apps/pipeline/views.py index 6f3e12e..8d752dd 100644 --- a/spug_api/apps/pipeline/views.py +++ b/spug_api/apps/pipeline/views.py @@ -110,10 +110,10 @@ class DoView(View): else: latest_history = pipe.pipehistory_set.first() ordinal = latest_history.ordinal + 1 if latest_history else 1 - history = PipeHistory.objects.create(pipeline=pipe, ordinal=ordinal, created_by=request.user) + PipeHistory.objects.create(pipeline=pipe, ordinal=ordinal, created_by=request.user) rds = get_redis_connection() - executor = NodeExecutor(rds, history.deploy_key, json.loads(pipe.nodes)) + executor = NodeExecutor(rds, token, json.loads(pipe.nodes)) Thread(target=executor.run).start() response = AttrDict(token=token, nodes=nodes) return json_response(response) diff --git a/spug_web/src/pages/pipeline/console/Body.js b/spug_web/src/pages/pipeline/console/Body.js index 39cfaa6..e281306 100644 --- a/spug_web/src/pages/pipeline/console/Body.js +++ b/spug_web/src/pages/pipeline/console/Body.js @@ -96,7 +96,6 @@ function Body() { }, [S.node]) function handleTabChange(v) { - S.node._id = `${S.node.id}.${v}` S.node._host_id = v S.node = Object.assign({}, S.node) } diff --git a/spug_web/src/pages/pipeline/console/Sider.js b/spug_web/src/pages/pipeline/console/Sider.js index cb17a5a..694d126 100644 --- a/spug_web/src/pages/pipeline/console/Sider.js +++ b/spug_web/src/pages/pipeline/console/Sider.js @@ -14,12 +14,6 @@ import css from './sider.module.less'; function Sider() { function handleClick(node) { node = lds.cloneDeep(node) - if (['ssh_exec', 'data_transfer', 'data_upload'].includes(node.module)) { - node._host_id = node._targets[0].id - node._id = `${node.id}.${node._host_id}` - } else if (node.module === 'build') { - node._host_id = node.target - } S.node = node } diff --git a/spug_web/src/pages/pipeline/console/store.js b/spug_web/src/pages/pipeline/console/store.js index 10fc8c1..f6bfa02 100644 --- a/spug_web/src/pages/pipeline/console/store.js +++ b/spug_web/src/pages/pipeline/console/store.js @@ -7,7 +7,6 @@ import { observable, computed } from 'mobx'; import { transfer } from '../utils'; class Store { - host_id = null; @observable token = null; @observable record = null; @observable node = {}; @@ -16,7 +15,13 @@ class Store { @observable dynamicParams = null; @computed get nodeID() { - return this.node._id ?? this.node.id + if (['ssh_exec', 'data_transfer', 'data_upload'].includes(this.node.module)) { + if (!this.node._host_id) this.node._host_id = this.node._targets[0].id + return `${this.node.id}.${this.node._host_id}` + } else if (this.node.module === 'build') { + this._host_id = this.node.target + } + return this.node.id } @computed get matrixNodes() { diff --git a/spug_web/src/pages/pipeline/modules/DataTransfer.js b/spug_web/src/pages/pipeline/modules/DataTransfer.js index 1b2739a..a9c249c 100644 --- a/spug_web/src/pages/pipeline/modules/DataTransfer.js +++ b/spug_web/src/pages/pipeline/modules/DataTransfer.js @@ -31,7 +31,8 @@ function DataTransfer(props) { - + 上游执行成功时 上游执行失败时 @@ -39,7 +40,8 @@ function DataTransfer(props) { - + @@ -47,7 +49,8 @@ function DataTransfer(props) { - + diff --git a/spug_web/src/pages/pipeline/modules/DataUpload.js b/spug_web/src/pages/pipeline/modules/DataUpload.js index 8da7056..0d2c3af 100644 --- a/spug_web/src/pages/pipeline/modules/DataUpload.js +++ b/spug_web/src/pages/pipeline/modules/DataUpload.js @@ -41,10 +41,10 @@ function DataUpload(props) { 总是执行 - + - + diff --git a/spug_web/src/pages/pipeline/modules/index.module.less b/spug_web/src/pages/pipeline/modules/index.module.less index 3f3d5e9..d1c019c 100644 --- a/spug_web/src/pages/pipeline/modules/index.module.less +++ b/spug_web/src/pages/pipeline/modules/index.module.less @@ -1,11 +1,12 @@ .formTips { margin-bottom: 16px; - padding: 4px; + padding: 4px 4px 0 4px; .content { - font-size: 13px; + font-size: 12px; margin: 0; color: #ff4d4f; + white-space: pre-line; } } diff --git a/spug_web/src/pages/pipeline/store.js b/spug_web/src/pages/pipeline/store.js index 7325f87..e9eb143 100644 --- a/spug_web/src/pages/pipeline/store.js +++ b/spug_web/src/pages/pipeline/store.js @@ -7,6 +7,7 @@ import { computed, observable } from 'mobx'; import { http, includes } from 'libs'; import { message } from 'antd'; import S from './console/store'; +import lds from 'lodash'; class Store { @observable records = []; @@ -51,7 +52,7 @@ class Store { S.record = record S.token = res.token S.nodes = res.nodes - S.node = res.nodes[0] + S.node = lds.cloneDeep(res.nodes[0]) S.outputs = {} S.dynamicParams = res.dynamic_params ? res.dynamic_params : null })