From 773fce0c0b00fe2152e6a95b3929a55a7079af22 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Mon, 23 Dec 2024 13:00:47 +0300 Subject: [PATCH] - fix pcs dr status --- SOURCES/0001-fix-pcs-dr-status.patch | 139 +++++++++++++++++++++++++++ SPECS/pcs.spec | 9 +- 2 files changed, 147 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-fix-pcs-dr-status.patch diff --git a/SOURCES/0001-fix-pcs-dr-status.patch b/SOURCES/0001-fix-pcs-dr-status.patch new file mode 100644 index 0000000..f05bc1f --- /dev/null +++ b/SOURCES/0001-fix-pcs-dr-status.patch @@ -0,0 +1,139 @@ +From c645b64df8e433bb37ed8f8774b7c946e0c7c8ba Mon Sep 17 00:00:00 2001 +From: eabdullin +Date: Mon, 23 Dec 2024 12:55:43 +0300 +Subject: [PATCH] fix `pcs dr status` + +--- + pcs/common/reports/messages.py | 17 +++++++---------- + pcs/daemon/app/api_v1.py | 5 +++-- + pcs_test/smoke.sh.in | 14 +++++++------- + pcsd/capabilities.xml.in | 7 +++++++ + 4 files changed, 24 insertions(+), 19 deletions(-) + +diff --git a/pcs/common/reports/messages.py b/pcs/common/reports/messages.py +index ccf32a0..9a1543e 100644 +--- a/pcs/common/reports/messages.py ++++ b/pcs/common/reports/messages.py +@@ -260,7 +260,7 @@ def _stonith_watchdog_timeout_reason_to_str( + }.get(reason, reason) + + +-@dataclass(frozen=True, init=False) ++@dataclass(frozen=True) + class LegacyCommonMessage(ReportItemMessage): + """ + This class is used for legacy report transport protocol from +@@ -268,22 +268,19 @@ class LegacyCommonMessage(ReportItemMessage): + should be replaced with transporting DTOs of reports in the future. + """ + +- def __init__( +- self, code: types.MessageCode, info: Mapping[str, Any], message: str +- ) -> None: +- self.__code = code +- self.info = info +- self._message = message ++ legacy_code: types.MessageCode ++ legacy_info: Mapping[str, Any] ++ legacy_message: str + + @property + def message(self) -> str: +- return self._message ++ return self.legacy_message + + def to_dto(self) -> ReportItemMessageDto: + return ReportItemMessageDto( +- code=self.__code, ++ code=self.legacy_code, + message=self.message, +- payload=dict(self.info), ++ payload=dict(self.legacy_info), + ) + + +diff --git a/pcs/daemon/app/api_v1.py b/pcs/daemon/app/api_v1.py +index 8e8b880..5babad1 100644 +--- a/pcs/daemon/app/api_v1.py ++++ b/pcs/daemon/app/api_v1.py +@@ -101,6 +101,7 @@ API_V1_MAP: Mapping[str, str] = { + "sbd-enable-sbd/v1": "sbd.enable_sbd", + "scsi-unfence-node/v2": "scsi.unfence_node", + "scsi-unfence-node-mpath/v1": "scsi.unfence_node_mpath", ++ "status-full-cluster-status-plaintext/v1": "status.full_cluster_status_plaintext", + # deprecated, use resource-agent-get-agent-metadata/v1 instead + "stonith-agent-describe-agent/v1": "stonith_agent.describe_agent", + # deprecated, use resource-agent-get-agents-list/v1 instead +@@ -301,13 +302,13 @@ class LegacyApiV1Handler(_BaseApiV1Handler): + class ClusterStatusLegacyHandler(LegacyApiV1Handler): + @staticmethod + def _get_cmd() -> str: +- return "status.full_cluster_status_plaintext" ++ return "status-full-cluster-status-plaintext/v1" + + + class ClusterAddNodesLegacyHandler(LegacyApiV1Handler): + @staticmethod + def _get_cmd() -> str: +- return "cluster.add_nodes" ++ return "cluster-add-nodes/v1" + + + def get_routes(scheduler: Scheduler, auth_provider: AuthProvider) -> RoutesType: +diff --git a/pcs_test/smoke.sh.in b/pcs_test/smoke.sh.in +index a4b3ac7..bfbb427 100755 +--- a/pcs_test/smoke.sh.in ++++ b/pcs_test/smoke.sh.in +@@ -23,12 +23,6 @@ output_file=$(mktemp) + token_file=$(mktemp) + cookie_file=$(mktemp) + +-# Sanity check of API V0 +-token=$(python3 -c "import json; print(json.load(open('@LOCALSTATEDIR@/lib/pcsd/known-hosts'))['known_hosts']['localhost']['token']);") +-curl -kb "token=${token}" https://localhost:2224/remote/cluster_status_plaintext -d 'data_json={}' > "${output_file}" +-cat "${output_file}"; echo "" +-python3 -c "import json; import sys; json.load(open('${output_file}'))['status'] == 'exception' and (sys.exit(1))"; +- + dd if=/dev/urandom bs=32 count=1 status=none | base64 > "${token_file}" + custom_localhost_node_name="custom-node-name" + +@@ -71,6 +65,12 @@ curl --insecure --cookie ${cookie_file} --header "X-Requested-With: XMLHttpReque + cat "${output_file}"; echo "" + [ "$(cat ${output_file})" = "Update Successful" ] + ++# Sanity check of API V0 ++token=$(python3 -c "import json; print(json.load(open('@LOCALSTATEDIR@/lib/pcsd/known-hosts'))['known_hosts']['localhost']['token']);") ++curl -kb "token=${token}" https://localhost:2224/remote/cluster_status_plaintext -d 'data_json={}' > "${output_file}" ++cat "${output_file}"; echo "" ++python3 -c "import json; import sys; json.load(open('${output_file}'))['status'] != 'success' and (sys.exit(1))"; ++ + # Sanity check of API V1 + curl -kb "token=${token}" https://localhost:2224/api/v1/resource-agent-get-agents-list/v1 --data '{}' > "${output_file}" + cat "${output_file}"; echo "" +@@ -98,5 +98,5 @@ rm "${output_file}" + rm "${cookie_file}" + rm "${pcsd_settings_conf_path}" + pcs cluster destroy --force +-userdel -r testuser ++userdel -rf testuser + exit 0 +diff --git a/pcsd/capabilities.xml.in b/pcsd/capabilities.xml.in +index 99d5af3..b9c2856 100644 +--- a/pcsd/capabilities.xml.in ++++ b/pcsd/capabilities.xml.in +@@ -2661,6 +2661,13 @@ + daemon urls: pacemaker_node_status + + ++ ++ ++ Display status of the remote site cluster. ++ ++ daemon urls: /api/v1/status-full-cluster-status-plaintext/v1 ++ ++ + + + Query status of resources. +-- +2.39.5 (Apple Git-154) diff --git a/SPECS/pcs.spec b/SPECS/pcs.spec index 776d8c1..32a1fee 100644 --- a/SPECS/pcs.spec +++ b/SPECS/pcs.spec @@ -1,6 +1,6 @@ Name: pcs Version: 0.11.8 -Release: 1%{?dist} +Release: 1%{?dist}.1.alma.1 # https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/ # https://fedoraproject.org/wiki/Licensing:Main?rd=Licensing#Good_Licenses # GPL-2.0-only: pcs @@ -110,6 +110,10 @@ Source101: https://github.com/ClusterLabs/pcs-web-ui/releases/download/%{ui_comm # Patch0: bzNUMBER-01-name.patch Patch0: do-not-support-cluster-setup-with-udp-u-transport.patch +# Patches were taken from: +# https://github.com/ClusterLabs/pcs/pull/878 +Patch1: 0001-fix-pcs-dr-status.patch + # ui patches: >200 # Patch201: bzNUMBER-01-name.patch @@ -559,6 +563,9 @@ run_all_tests %license pyagentx_LICENSE.txt %changelog +* Mon Dec 23 2024 Eduard Abdullin - 0.11.8-1.el9_5.1.alma.1 +- fix pcs dr status + * Tue Jul 9 2024 Michal Pospisil - 0.11.8-1 - Updated pcs-web-ui to 0.1.20 - Rebased to the latest sources (see CHANGELOG.md)