!96 [sync] PR-95: fix error log when query host status

From: @openeuler-sync-bot 
Reviewed-by: @zhu-yuncheng 
Signed-off-by: @zhu-yuncheng
This commit is contained in:
openeuler-ci-bot 2023-12-25 02:34:58 +00:00 committed by Gitee
commit 1b686d7075
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,47 @@
From eaf05c0588e595d2f635c6bae867db5f15c3b034 Mon Sep 17 00:00:00 2001
From: rearcher <123781007@qq.com>
Date: Sun, 24 Dec 2023 21:01:19 +0800
Subject: [PATCH] fix log error
---
zeus/host_manager/view.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/zeus/host_manager/view.py b/zeus/host_manager/view.py
index 30d05a3..d13868c 100644
--- a/zeus/host_manager/view.py
+++ b/zeus/host_manager/view.py
@@ -139,6 +139,10 @@ class GetHostStatus(BaseResponse):
"""
status_code, host_infos = callback.get_host_ssh_info(params)
+ result_list = []
+ if len(host_infos) == 0:
+ return self.response(code=status_code, data=result_list)
+
multi_thread_handler = MultiThreadHandler(lambda p: self.get_host_status(p), host_infos, None)
multi_thread_handler.create_thread()
result_list = multi_thread_handler.get_result()
@@ -457,13 +461,16 @@ def verify_ssh_login_info(ssh_login_info: ClientConnectArgs) -> str:
)
client.close()
except socket.error as error:
- LOGGER.error(error)
+ LOGGER.info(f"Failed to connect to host %s: %s", ssh_login_info.host_ip, error)
return state.SSH_CONNECTION_ERROR
except SSHException as error:
- LOGGER.error(error)
+ LOGGER.info(f"Failed to connect to host %s: %s", ssh_login_info.host_ip, error)
+ return state.SSH_AUTHENTICATION_ERROR
+ except IndexError:
+ LOGGER.error(f"Failed to connect to host %s because the pkey of the host are missing", ssh_login_info.host_ip)
return state.SSH_AUTHENTICATION_ERROR
except Exception as error:
- LOGGER.error(error)
+ LOGGER.error(f"Failed to connect to host %s: %s", ssh_login_info.host_ip, error)
return state.SSH_CONNECTION_ERROR
return state.SUCCEED
--
Gitee

View File

@ -1,6 +1,6 @@
Name: aops-zeus Name: aops-zeus
Version: v1.4.0 Version: v1.4.0
Release: 4 Release: 5
Summary: A host and user manager service which is the foundation of aops. Summary: A host and user manager service which is the foundation of aops.
License: MulanPSL2 License: MulanPSL2
URL: https://gitee.com/openeuler/%{name} URL: https://gitee.com/openeuler/%{name}
@ -13,6 +13,7 @@ Patch0005: 0005-fix-apollo-TimedCorrectTask.patch
Patch0006: 0006-update-verification-method-for-adding-host.patch Patch0006: 0006-update-verification-method-for-adding-host.patch
Patch0007: 0007-update-verification-method-for-host-ip-field.patch Patch0007: 0007-update-verification-method-for-host-ip-field.patch
Patch0008: 0008-check-host-status-when-query-host-detail.patch Patch0008: 0008-check-host-status-when-query-host-detail.patch
Patch0009: 0009-fix-error-log-when-query-host-status.patch
BuildRequires: python3-setuptools BuildRequires: python3-setuptools
@ -53,6 +54,9 @@ cp -r database %{buildroot}/opt/aops/
%changelog %changelog
* Sun Dec 24 2023 luxuexian<luxuexian@huawei.com> - v1.4.0-5
- fix error log when query host status
* Thu Dec 21 2023 wenxin<wenxin32@foxmail.com> - v1.4.0-4 * Thu Dec 21 2023 wenxin<wenxin32@foxmail.com> - v1.4.0-4
- update verification method for host ip field - update verification method for host ip field
- check host status when query host detail - check host status when query host detail