diff --git a/app.yml b/app.yml index a248daf909..a596e70706 100644 --- a/app.yml +++ b/app.yml @@ -6,7 +6,7 @@ is_use_celery: True author: 蓝鲸智云 introduction: 标准运维是通过一套成熟稳定的任务调度引擎,把在多系统间的工作整合到一个流程,助力运维实现跨系统调度自动化的SaaS应用。 introduction_en: SOPS is a SaaS application that utilizes a set of mature and stable task scheduling engines to help realize cross-system scheduling automation, and integrates the work among multiple systems into a single process. -version: 3.31.17 +version: 3.31.18 category: 运维工具 language_support: 中文 desktop: diff --git a/app_desc.yaml b/app_desc.yaml index 4912c9afad..0701a562e2 100644 --- a/app_desc.yaml +++ b/app_desc.yaml @@ -1,5 +1,5 @@ spec_version: 2 -app_version: "3.31.17" +app_version: "3.31.18" app: region: default bk_app_code: bk_sops diff --git a/config/default.py b/config/default.py index 4c71ffb19e..ac8023c4aa 100644 --- a/config/default.py +++ b/config/default.py @@ -211,7 +211,7 @@ # mako模板中: # 如果静态资源修改了以后,上线前改这个版本号即可 -STATIC_VERSION = "3.31.17" +STATIC_VERSION = "3.31.18" DEPLOY_DATETIME = datetime.datetime.now().strftime("%Y%m%d%H%M%S") STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")] @@ -678,6 +678,7 @@ def monitor_report_config(): from bk_monitor_report import MonitorReporter # noqa from bk_monitor_report.contrib.celery import MonitorReportStep # noqa + from blueapps.core.celery import celery_app # noqa reporter = MonitorReporter( diff --git a/gcloud/tasktmpl3/domains/constants.py b/gcloud/tasktmpl3/domains/constants.py index 265c487311..3ab3a6077b 100644 --- a/gcloud/tasktmpl3/domains/constants.py +++ b/gcloud/tasktmpl3/domains/constants.py @@ -10,7 +10,7 @@ an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ - +import copy import logging import re from typing import List @@ -19,6 +19,7 @@ from bamboo_engine.eri import ContextValue, NodeType from bamboo_engine.template import Template from bamboo_engine.utils.constants import VAR_CONTEXT_MAPPING +from pipeline.component_framework.constant import ConstantPool from pipeline.core.data import var from pipeline.core.data.expression import ConstantTemplate from pipeline.core.data.library import VariableLibrary @@ -74,6 +75,31 @@ def get_constant_values(constants, extra_data): return {**constant_values, **hydrated_context} +def get_references(constants: dict, inputs: dict) -> set: + """ + 获取某个变量在上下文中引用的其他变量 + @param constants: {"${ip_lisr}: {}"} + @param inputs: {"${ip_lisr}": {"value": xxx}} + @return: ["${ip_lisr}"] + """ + referenced_keys = [] + while True: + last_count = len(referenced_keys) + cons_pool = ConstantPool(inputs, lazy=True) + refs = cons_pool.get_reference_info(strict=False) + + for keys in list(refs.values()): + for key in keys: + # add outputs keys later + if key in constants and key not in referenced_keys: + referenced_keys.append(key) + inputs.update({key: constants[key]}) + if len(referenced_keys) == last_count: + break + + return set(referenced_keys) + + def preview_node_inputs( runtime: BambooDjangoRuntime, pipeline: dict, @@ -84,21 +110,13 @@ def preview_node_inputs( subprocess_simple_inputs: bool = False, ): def get_need_render_context_keys(): - keys = set() # 如果遇到子流程,到最后一层才会实际去解析需要渲染的变量 node_info = pipeline["activities"][node_id] - inputs_values = node_info.get("component", {}).get("inputs", {}).values() - for item in inputs_values: - if not item["need_render"]: - continue - if isinstance(item["value"], str): - for value in var_pattern.findall(item["value"]): - keys.add("${" + value + "}") - - if keys: - references_keys = runtime.get_context_key_references(pipeline["id"], keys) - return keys | references_keys - return set() + node_inputs = copy.deepcopy(node_info.get("component", {}).get("inputs", {})) + pipeline_inputs = copy.deepcopy(pipeline["data"].get("inputs", {})) + pipeline_inputs.update(parent_params) + keys = get_references(pipeline_inputs, node_inputs) + return keys # 对于子流程内的节点,拿不到当前node_id的type和code node_type = pipeline["activities"].get(node_id, {}).get("type")