问题现象
通过 OCP Web 界面或者 OCP 开放出来的 RESTful AP 接口来升级或重装 OCP Agent 时遇到报错:
错误信息操作 OCP-Agent 失败,错误信息:Unexpected error: reload config properties err: load config properties from path /home/admin/ocp_agent/conf/config_properties, err:read config files from dir:/home/admin/ocp_agent/conf/config_properties, err:open /home/admin/ocp_agent/conf/config_properties: no such file or directory

反复重试依旧无效,将这一步标记成功后,后续的步骤还是会继续报错。
问题原因
报错的直接原因是对应主机上 OCP Agent 相关的目录文件缺失了:
[root@ob64 ~]# ls /home/admin/ocp_agent/conf/config_properties
ls: cannot access '/home/admin/ocp_agent/conf/config_properties': No such file or directory
[root@ob64 ~]#
[root@ob64 ~]# ls /home/admin/ocp_agent/conf
ls: cannot access '/home/admin/ocp_agent/conf': No such file or directory
[root@ob64 ~]#
[root@ob64 ~]# ls /home/admin/ocp_agent
log snapshots
[root@ob64 ~]#
正常环境上的目录结构如下:
[root@ob64 ~]# ls -ltr /home/admin/ocp_agent
total 8
drwxr-xr-x 2 root root 6 Aug 15 11:32 tmp
drwxr-xr-x 2 root root 6 Aug 15 11:32 backup
drwxr-xr-x 2 root root 106 Sep 22 13:24 bin
drwxr-xr-x 8 root root 257 Sep 22 13:24 site-packages
drwxr-xr-x 2 root root 60 Sep 22 13:24 pkg_store
drwxr-xr-x 2 root root 294 Sep 22 13:24 log
drwxr-xr-x 2 root root 201 Sep 22 13:24 run
drwxr-xr-x 8 root root 322 Sep 22 13:24 conf
drwxr-xr-x 2 root root 4096 Sep 22 13:24 position_store
drwxr-xr-x 2 root root 199 Sep 22 13:26 task_store
drwxr-xr-x 6 root root 4096 Sep 22 13:26 snapshots
[root@ob64 ~]# ls -ltr /home/admin/ocp_agent/conf
total 20
-rw-r--r-- 1 root root 302 Aug 15 11:32 monagent.yaml
-rw-r--r-- 1 root root 454 Aug 15 11:32 mgragent.yaml
-rw-r--r-- 1 root root 1101 Aug 15 11:32 agentd.yaml
-rw-r--r-- 1 root root 652 Aug 15 11:32 agentctl.yaml
drwxr-xr-x 2 root root 76 Sep 22 13:24 shell_templates
drwxr-xr-x 2 root root 213 Sep 22 13:24 scripts
drwxr-xr-x 2 root root 4096 Sep 22 13:24 module_config
drwxr-xr-x 4 root root 64 Sep 22 13:24 2025-09-22T13:24:33.4177+08:00
drwxr-xr-x 2 root root 243 Sep 22 13:24 config_properties
drwxr-xr-x 4 root root 64 Sep 22 13:24 2025-09-22T13:24:41.2191+08:00
[root@ob64 ~]# ls -ltr /home/admin/ocp_agent/conf/config_properties/
total 104
-rw-r--r-- 1 root root 765 Aug 15 11:32 log.yaml
-rw-r--r-- 1 root root 917 Aug 15 11:32 common_meta.yaml
-rw-r--r-- 1 root root 591 Sep 22 13:24 basic_auth.yaml
-rw-r--r-- 1 root root 1454 Sep 22 13:24 mgragent_pipeline.yaml
-rw-r--r-- 1 root root 237 Sep 22 13:24 default_config.yaml
-rw-r--r-- 1 root root 2736 Sep 22 13:24 ob_logcleaner.yaml
-rw-r--r-- 1 root root 43050 Sep 22 13:24 monagent_pipeline.yaml
-rw-r--r-- 1 root root 34747 Sep 22 13:24 ob_logtailer.yaml
问题的风险及影响
OCP Agent 重装或升级失败。
适用版本
OCP 所有版本。
解决方法
重装 OCP Agent 时,如果当前主机上的 ocp_mgragent 进程正在运行,OCP 会尝试将对应的重装命令下发给 ocp_mgragent 进程来执行:
[root@ob64 ~]# ps -ef | grep ocp
root 28059 1 0 Sep03 ? 01:27:01 /home/admin/ocp_agent/bin/ocp_mgragent
root 28060 1 20 Sep03 ? 3-21:43:20 /home/admin/ocp_agent/bin/ocp_monagent
root 2085752 2044109 0 11:52 pts/0 00:00:00 grep --color=auto ocp
如果对应的 ocp_mgragent 进程不存在,则会通过 ssh+主机凭据的方式远程登录到对应的主机上执行直接重装 OCP Agent 的脚本。 因此这边可以先回滚失败的任务,同时将所有存活的 OCP Agent 进程都手动 Kill 掉,再执行重装任务,让 OCP 通过 ssh 的方式来重装 OCP Agent,就可以成功了:
[root@ob64 ~]# ps -ef | grep ocp
root 28059 1 0 Sep03 ? 01:27:17 /home/admin/ocp_agent/bin/ocp_mgragent
root 28060 1 20 Sep03 ? 3-22:03:44 /home/admin/ocp_agent/bin/ocp_monagent
root 2214033 2044109 0 13:23 pts/0 00:00:00 grep --color=auto ocp
[root@ob64 ~]#
[root@ob64 ~]# kill -9 28059 28060
[root@ob64 ~]#
[root@ob64 ~]# ps -ef | grep ocp
root 2214367 2044109 0 13:23 pts/0 00:00:00 grep --color=auto ocp

规避方式
无。