Skip to content

Commit

Permalink
sprintfix: Agent 额外配置目录配置路径调整 (closed TencentBlueKing#1756)
Browse files Browse the repository at this point in the history
  • Loading branch information
CohleRustW committed Sep 19, 2023
1 parent c57f129 commit 565fa6f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions apps/backend/agent/solution_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from apps.core.script_manage.base import ScriptHook
from apps.node_man import constants, models
from apps.utils import basic
from apps.utils.files import PathHandler


class ExecutionSolutionStepContent:
Expand Down Expand Up @@ -103,10 +104,11 @@ def choose_script_file(cls, host: models.Host, is_execute_on_target: bool) -> st

@staticmethod
def get_gse_extra_config_dir(os_type: str):
extra_config_sub_dir: str = "user_conf"
if os_type.upper() == constants.OsType.WINDOWS:
return settings.GSE_ENVIRON_WIN_DIR
return PathHandler(os_type).join(settings.GSE_ENVIRON_WIN_DIR, extra_config_sub_dir)
else:
return settings.GSE_ENVIRON_DIR
return PathHandler(os_type).join(settings.GSE_ENVIRON_DIR, extra_config_sub_dir)


class BaseExecutionSolutionMaker(metaclass=abc.ABCMeta):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def test_batch_solution(self):
self.assertEqual(
solution_parse_result["cmds"],
[
f"mkdir {mock_data_utils.GSE_ENVIRON_WIN_DIR}",
f"mkdir {mock_data_utils.GSE_ENVIRON_WIN_DIR}\\user_conf",
f"mkdir {installation_tool.dest_dir}",
# f"{installation_tool.dest_dir}curl.exe http://127.0.0.1/download/setup_agent.bat"
# f" -o {installation_tool.dest_dir}setup_agent.bat -sSfg",
Expand Down Expand Up @@ -774,7 +774,7 @@ def test_shell_solution(self):
self.assertEqual(
solution_parse_result["cmds"],
[
f"mkdir -p {mock_data_utils.GSE_ENVIRON_DIR}",
f"mkdir -p {mock_data_utils.GSE_ENVIRON_DIR}/user_conf",
f"mkdir -p {installation_tool.dest_dir}",
f"mkdir -p {self.CUSTOM_DATAIPC_DIR}",
f"curl http://127.0.0.1/download/agent_tools/agent2/setup_agent.sh "
Expand Down
4 changes: 2 additions & 2 deletions apps/mock_data/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

JOB_TASK_PIPELINE_ID = "1ae89ce9deec319bbd8727a0c4b2ca82"

GSE_ENVIRON_DIR = "/etc/sysconfig/gse/bk_test/user_conf"
GSE_ENVIRON_DIR = "/etc/sysconfig/gse/bk_test"

GSE_ENVIRON_WIN_DIR = "C:\\\\Windows\\\\System32\\\\config\\\\gse\\\\bk_test\\\\user_conf"
GSE_ENVIRON_WIN_DIR = "C:\\\\Windows\\\\System32\\\\config\\\\gse\\\\bk_test"


class MockReturnType(EnhanceEnum):
Expand Down
4 changes: 2 additions & 2 deletions docs/solution/how-to-install-agent2.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ config:
gseVersion: V2
bkAppBkGseApiGateway: { { BKAPP_BK_GSE_APIGATEWAY } }
gseEnablePushEnvironFile: true
gseEnvironDir: /etc/sysconfig/gse/{{ ENV }}/user_conf
gseEnvironWinDir: C:\\Windows\\System32\\config\\gse\\{{ ENV }}\\user_conf
gseEnvironDir: /etc/sysconfig/gse/{{ ENV }}
gseEnvironWinDir: C:\\Windows\\System32\\config\\gse\\{{ ENV }}
```
环境变量说明请参考:[bk-nodman 系统配置](https://github.com/TencentBlueKing/bk-nodeman/blob/v2.3.x/support-files/kubernetes/helm/bk-nodeman/README.md#bk-nodeman-%E7%B3%BB%E7%BB%9F%E9%85%8D%E7%BD%AE)
Expand Down
4 changes: 2 additions & 2 deletions env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@
GSE_ENABLE_PUSH_ENVIRON_FILE = get_type_env(key="GSE_ENABLE_PUSH_ENVIRON_FILE", default=False, _type=bool)

# GSE 环境变量目录
GSE_ENVIRON_DIR = get_type_env(key="GSE_ENVIRON_DIR", default="/etc/sysconfig/gse/bk/user_conf", _type=str)
GSE_ENVIRON_DIR = get_type_env(key="GSE_ENVIRON_DIR", default="/etc/sysconfig/gse/bk", _type=str)

# GSE 环境变量目录(Windows)
GSE_ENVIRON_WIN_DIR = get_type_env(
key="GSE_ENVIRON_WIN_DIR", default="C:\\\\Windows\\\\System32\\\\config\\\\gse\\\\bk\\\\user_conf", _type=str
key="GSE_ENVIRON_WIN_DIR", default="C:\\\\Windows\\\\System32\\\\config\\\\gse\\\\bk", _type=str
)

# ===============================================================================
Expand Down
4 changes: 2 additions & 2 deletions support-files/kubernetes/helm/bk-nodeman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ externalRabbitMQ:
| `config.gseVersion` | 蓝鲸管控平台版本,默认为 `V1`,可选:`V1` `V2` | `V1` |
| `config.gseCertPath` | GSE 本地证书路径,渲染时为空默认取 `/data/bk{{ .Values.config.bkAppRunEnv }}/cert` | `""` |
| `config.gseEnablePushEnvironFile` | 是否启用推送 GSE 环境变量文件,如果启用,将在 Agent `安装`/`重装`/`重载配置`/`灰度` 操作成功后,进行如下操作:<br />Windows:推送 `environ.sh` & `environ.bat` 到目标机器的 `GSE_ENVIRON_WIN_DIR` 路径<br />Linux:推送 `environ.sh` 到目标机器的 `GSE_ENVIRON_DIR` 路径 | `false` |
| `config.gseEnvironDir` | GSE 环境变量目录 | `/etc/sysconfig/gse/bk/user_conf` |
| `config.gseEnvironWinDir` | GSE 环境变量目录(Windows) | `C:\\Windows\\System32\\config\\gse\\ bk\\user_conf` |
| `config.gseEnvironDir` | GSE 环境变量目录 | `/etc/sysconfig/gse/bk` |
| `config.gseEnvironWinDir` | GSE 环境变量目录(Windows) | `C:\\Windows\\System32\\config\\gse\\bk` |
| `config.gseEnableSvrDisCovery` | 蓝鲸管控平台 Agent,AgentXXDir 仅在初次部署有效,后续可以在页面「全局配置」维护。是否启用 GSE 服务探测,默认为 `true` | `true` |
| `config.bkAppGseZkHost` | 蓝鲸管控平台 Agent,zk hosts 信息,host:port,多个 hosts 以 `,` 分隔<br />⚠️ ZK hosts 将作为 Agent 配置,需要保证 Agent 可访问,所以不能使用 k8s service 信息 进行配置<br />如果 zk 通过 k8s 部署,建议通过 NodePort 等方式暴露服务,使用 NodeIP:NodePort 进行配置 | `127.0.0.1:2181` |
| `config.bkAppGseZkAuth` | 蓝鲸管控平台 Agent,ZK 认证信息,用户名:密码 | `bkzk:zkpass` |
Expand Down
4 changes: 2 additions & 2 deletions support-files/kubernetes/helm/bk-nodeman/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ config:
## Linux:推送 `environ.sh` 到目标机器的 `GSE_ENVIRON_DIR` 路径
gseEnablePushEnvironFile: false
## GSE 环境变量目录
gseEnvironDir: "/etc/sysconfig/gse/bk/user_conf"
gseEnvironDir: "/etc/sysconfig/gse/bk"
## GSE 环境变量目录(Windows)
gseEnvironWinDir: "C:\\\\Windows\\\\System32\\\\config\\\\gse\\\\bk\\\\user_conf"
gseEnvironWinDir: "C:\\\\Windows\\\\System32\\\\config\\\\gse\\\\bk"
## 是否启用 GSE 服务探测,为 `true` 将定期更新默认接入点的 gse svr 信息
gseEnableSvrDisCovery: true
## ZK hosts 信息,host:port,多个 hosts 以 `,` 分隔
Expand Down

0 comments on commit 565fa6f

Please sign in to comment.