Skip to content

Commit

Permalink
fix: windows安装agent出现ieod脚本同时curl和执行 (closed #2409)
Browse files Browse the repository at this point in the history
  • Loading branch information
v_gqpgguo authored and wyyalt committed Aug 22, 2024
1 parent f7446b4 commit b750713
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,12 @@
from apps.core.remote import exceptions
from apps.core.remote.tests import base
from apps.core.remote.tests.base import AsyncMockConn
from apps.core.script_manage.data import (
IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO,
JUMP_SERVER_POLICY_SCRIPT_INFO,
)
from apps.core.script_manage.data import JUMP_SERVER_POLICY_SCRIPT_INFO
from apps.core.script_manage.handlers import ScriptManageHandler
from apps.exceptions import ApiResultError
from apps.mock_data import api_mkd, common_unit
from apps.mock_data import utils as mock_data_utils
from apps.node_man import constants, models
from apps.node_man.models import GlobalSettings
from env.constants import GseVersion
from pipeline.component_framework.test import (
ComponentTestCase,
Expand Down Expand Up @@ -1183,7 +1179,6 @@ def init_mock_clients(self):

class WindowsActiveFirewallPolicyInDirectAreaTestCase(InstallWindowsWithScriptHooksTestCase):
def adjust_db(self):
GlobalSettings.objects.filter(key=GlobalSettings.KeyEnum.AGENT_INSTALL_SCRIPT_HOOK_CONTENT.value).delete()
sub_step_obj: models.SubscriptionStep = self.obj_factory.sub_step_objs[0]
sub_step_obj.params.update(
{
Expand Down Expand Up @@ -1226,41 +1221,6 @@ def test_batch_solution(self):
)


class ActiveFirewallAddConfigTestCase(WindowsActiveFirewallPolicyInDirectAreaTestCase):
def adjust_db(self):
super().adjust_db()
GlobalSettings.set_config(
GlobalSettings.KeyEnum.AGENT_INSTALL_SCRIPT_HOOK_CONTENT.value,
{IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO.name: "test"},
)

def test_batch_solution(self):
host, script_hook_objs, installation_tool, solution_parse_result = self.build_solution_result(
script_hooks=[{"name": "ieod_active_firewall_policy"}]
)

self.assertEqual(
constants.AgentWindowsDependencies.list_member_values() + ["setup_agent.bat"],
solution_parse_result["dependencies"],
)
self.assertEqual(
solution_parse_result["cmds"],
[
# 一:创建临时目录
f"mkdir {installation_tool.dest_dir}",
# 二:执行ieod_active_firewall_policy
"test",
# 三:执行安装脚本
f"{installation_tool.dest_dir}setup_agent.bat"
f" -O 48668 -E 58925 -A 58625 -V 58930 -B 10020 -S 60020 -Z 60030 -K 10030"
f' -e "127.0.0.1" -a "127.0.0.1" -k "127.0.0.1"'
f" -l http://127.0.0.1/download -r http://127.0.0.1/backend"
f" -i 0 -I {host.inner_ip} -T C:\\tmp\\ -p c:\\gse"
f" -c {solution_parse_result['params']['token']} -s {mock_data_utils.JOB_TASK_PIPELINE_ID} -N SERVER",
],
)


class WindowsActiveFirewallPolicyNotInDirectAreaTestCase(WindowsActiveFirewallPolicyInDirectAreaTestCase):
def adjust_db(self):
super().adjust_db()
Expand Down
2 changes: 2 additions & 0 deletions apps/core/script_manage/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from django.utils.translation import ugettext_lazy as _

import env
from apps.node_man import constants as node_man_constants

from ...node_man.constants import DEFAULT_CLOUD
Expand Down Expand Up @@ -40,6 +41,7 @@
filename="ieod_active_firewall_policy.bat",
path="script_manage_tmp/ieod_active_firewall_policy.bat",
description=_("IDC Windows 物理机安装策略开通"),
oneline=env.BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO,
support_os_list=[node_man_constants.OsType.WINDOWS],
support_cloud_id=DEFAULT_CLOUD,
)
Expand Down
5 changes: 5 additions & 0 deletions env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
"BKPAAS_SHARED_RES_URL",
"BKAPP_LEGACY_AUTH",
"BK_NOTICE_ENABLED",
# WINDOWS IEOD脚本内容
"BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO",
]

# ===============================================================================
Expand All @@ -86,6 +88,9 @@
key="BKAPP_SYNC_PROC_STATUS_TASK_INTERVAL", default=20 * 60, _type=int
)
BKAPP_SCRIPT_HOOKS = get_type_env(key="BKAPP_SCRIPT_HOOKS", default="", _type=str)
BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO = get_type_env(
key="BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO", default="", _type=str
)

# ===============================================================================
# 日志
Expand Down
1 change: 1 addition & 0 deletions support-files/kubernetes/helm/bk-nodeman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ externalRabbitMQ:
| `config.bkAppNavHelperUrl` | 导航栏技术支持地址 | `https://wpa1.qq.com/KziXGWJs?_type=wpa&qidian=true` |
| `config.bkAppSyncProcStatusTaskInterval` | 插件进程状态同步周期 | `20 * 60` |
| `config.bkAppScriptHooks` | Agent安装前置脚本 | `""` |
| `config.bkAppIEODActiveFirewallPolicyScriptInfo` | WINDOWS IEOD脚本内容 | `""` |

## 额外的环境变量

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,4 @@ data:
BKPAAS_SHARED_RES_URL: "{{ .Values.bkSharedResUrl }}"
BKAPP_LEGACY_AUTH: "{{ .Values.config.bkAppLegacyAuth }}"
BK_NOTICE_ENABLED: "{{ .Values.bkNotice.enabled }}"
BKAPP_IEOD_ACTIVE_FIREWALL_POLICY_SCRIPT_INFO: "{{ .Values.config.bkAppIEODActiveFirewallPolicyScriptInfo }}"
2 changes: 2 additions & 0 deletions support-files/kubernetes/helm/bk-nodeman/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ config:
bkAppSyncProcStatusTaskInterval: 1200
## Agent安装前置脚本
bkAppScriptHooks: ""
## WINDOWS IEOD脚本内容
bkAppIEODActiveFirewallPolicyScriptInfo: ""


## --------------------------------------
Expand Down

0 comments on commit b750713

Please sign in to comment.