fix pcs config checkpoint diff command

(cherry picked from commit ec69f74b0e38aa76c657b03f9bd084eab87df8dd)
This commit is contained in:
bizhiyuan 2023-08-31 04:42:22 +08:00 committed by openeuler-sync-bot
parent ec6229b91d
commit 6e497eb43d
2 changed files with 112 additions and 1 deletions

View File

@ -0,0 +1,106 @@
From 81cefe083678b88ca475c0d3f0eea962ed3a5035 Mon Sep 17 00:00:00 2001
From: bizhiyuan <bizhiyuan@kylinos.cn>
Date: Thu, 31 Aug 2023 04:25:52 +0800
Subject: [PATCH] fix pcs config checkpoint diff command
---
CHANGELOG.md | 5 ++++-
pcs/cli/common/lib_wrapper.py | 13 +------------
pcs/config.py | 3 +++
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9741670..7949064 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,9 @@
- Multiple improvements of `pcs resource move` command ([rhbz#1996062])
- Pcs no longer creates Pacemaker-1.x CIB when `-f` is used, so running `pcs
cluster cib-upgrade` manually is not needed ([rhbz#2022463])
+- Fix displaying differences between configuration checkpoints in
+ `pcs config checkpoint diff` command ([rhbz#2175881])
+
[ghissue#441]: https://github.com/ClusterLabs/pcs/issues/441
[ghpull#431]: https://github.com/ClusterLabs/pcs/pull/431
@@ -24,7 +27,7 @@
[rhbz#2028902]: https://bugzilla.redhat.com/show_bug.cgi?id=2028902
[rhbz#2033248]: https://bugzilla.redhat.com/show_bug.cgi?id=2033248
[rhbz#2036633]: https://bugzilla.redhat.com/show_bug.cgi?id=2036633
-
+[rhbz#2175881]: https://bugzilla.redhat.com/show_bug.cgi?id=2175881
## [0.11.1] - 2021-11-30
diff --git a/pcs/cli/common/lib_wrapper.py b/pcs/cli/common/lib_wrapper.py
index 6600497..c6c9dba 100644
--- a/pcs/cli/common/lib_wrapper.py
+++ b/pcs/cli/common/lib_wrapper.py
@@ -1,6 +1,5 @@
import logging
from collections import namedtuple
-from typing import Dict, Any
from pcs.cli.common import middleware
from pcs.lib.commands import (
@@ -34,10 +33,6 @@ from pcs.lib.commands.constraint import (
from pcs.lib.env import LibraryEnvironment
-# Note: not properly typed
-_CACHE: Dict[Any, Any] = {}
-
-
def wrapper(dictionary):
return namedtuple("wrapper", dictionary.keys())(**dictionary)
@@ -104,12 +99,6 @@ def bind_all(env, run_with_middleware, dictionary):
)
-def get_module(env, middleware_factory, name):
- if name not in _CACHE:
- _CACHE[name] = load_module(env, middleware_factory, name)
- return _CACHE[name]
-
-
def load_module(env, middleware_factory, name):
# pylint: disable=too-many-return-statements, too-many-branches
if name == "acl":
@@ -518,4 +507,4 @@ class Library:
self.middleware_factory = middleware_factory
def __getattr__(self, name):
- return get_module(self.env, self.middleware_factory, name)
+ return load_module(self.env, self.middleware_factory, name)
diff --git a/pcs/config.py b/pcs/config.py
index 32f6a50..83884ec 100644
--- a/pcs/config.py
+++ b/pcs/config.py
@@ -678,6 +678,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
orig_usefile = utils.usefile
orig_filename = utils.filename
orig_middleware = lib.middleware_factory
+ orig_env = lib.env
# configure old code to read the CIB from a file
utils.usefile = True
utils.filename = os.path.join(
@@ -687,6 +688,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
lib.middleware_factory = orig_middleware._replace(
cib=middleware.cib(utils.filename, utils.touch_cib_file)
)
+ lib.env = utils.get_cli_env()
# export the CIB to text
result = False, []
if os.path.isfile(utils.filename):
@@ -695,6 +697,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
utils.usefile = orig_usefile
utils.filename = orig_filename
lib.middleware_factory = orig_middleware
+ lib.env = orig_env
return result
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: pcs
Version: 0.11.2
Release: 3
Release: 4
License: GPLv2 and BSD-2-Clause and ASL 2.0 and MIT
URL: https://github.com/ClusterLabs/pcs
Summary: Pacemaker Configuration System
@ -42,6 +42,8 @@ Patch2: bz2093935-01-Python-3.11-related-fixes.patch
Patch3: Support-for-openEuler.patch
Patch4: Adjust-regex-to-support-json-2.6.3-error.patch
Patch5: Fix-typing-in-resource_agent-package.patch
Patch6: fix-pcs-config-checkpoint-diff-command.patch
# git for patches
BuildRequires: git-core
BuildRequires: make
@ -404,6 +406,9 @@ run_all_tests
%license pyagentx_LICENSE.txt
%changelog
* Thu Aug 31 2023 bizhiyuan <bizhiyuan@kylinos.cn> - 0.11.2-4
- Fix pcs config checkpoint diff command
* Wed Aug 23 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 0.11.2-3
- Fix typing in resource_agent package