Blame SOURCES/bz2180697-01-fix-pcs-config-checkpoint-diff.patch

cae71c
From d1a658601487175ec70054e56ade116f3dbcecf6 Mon Sep 17 00:00:00 2001
cae71c
From: Miroslav Lisik <mlisik@redhat.com>
cae71c
Date: Mon, 6 Mar 2023 15:42:35 +0100
cae71c
Subject: [PATCH 1/2] fix `pcs config checkpoint diff` command
cae71c
cae71c
---
cae71c
 CHANGELOG.md                  | 26 --------------------------
cae71c
 pcs/cli/common/lib_wrapper.py | 15 +--------------
cae71c
 pcs/config.py                 |  3 +++
cae71c
 3 files changed, 4 insertions(+), 40 deletions(-)
cae71c
cae71c
diff --git a/CHANGELOG.md b/CHANGELOG.md
cae71c
index 0945d727..7d3d606b 100644
cae71c
--- a/CHANGELOG.md
cae71c
+++ b/CHANGELOG.md
cae71c
@@ -1,31 +1,5 @@
cae71c
 # Change Log
cae71c
 
cae71c
-## [Unreleased]
cae71c
-
cae71c
-### Added
cae71c
-- Warning to `pcs resource|stonith update` commands about not using agent
cae71c
-  self-validation feature when the resource is already misconfigured
cae71c
-  ([rhbz#2151524])
cae71c
-
cae71c
-### Fixed
cae71c
-- Graceful stopping pcsd service using `systemctl stop pcsd` command
cae71c
-- Displaying bool and integer values in `pcs resource config` command
cae71c
-  ([rhbz#2151164], [ghissue#604])
cae71c
-- Allow time values in stonith-watchdog-time property ([rhbz#2158790])
cae71c
-
cae71c
-### Changed
cae71c
-- Resource/stonith agent self-validation of instance attributes is now
cae71c
-  disabled by default, as many agents do not work with it properly.
cae71c
-  Use flag '--agent-validation' to enable it in supported commands.
cae71c
-  ([rhbz#2159454])
cae71c
-
cae71c
-[ghissue#604]: https://github.com/ClusterLabs/pcs/issues/604
cae71c
-[rhbz#2151164]: https://bugzilla.redhat.com/show_bug.cgi?id=2151164
cae71c
-[rhbz#2151524]: https://bugzilla.redhat.com/show_bug.cgi?id=2151524
cae71c
-[rhbz#2159454]: https://bugzilla.redhat.com/show_bug.cgi?id=2159454
cae71c
-[rhbz#2158790]: https://bugzilla.redhat.com/show_bug.cgi?id=2158790
cae71c
-
cae71c
-
cae71c
 ## [0.11.4] - 2022-11-21
cae71c
 
cae71c
 ### Security
cae71c
diff --git a/pcs/cli/common/lib_wrapper.py b/pcs/cli/common/lib_wrapper.py
cae71c
index 217bfe3e..e6411e3c 100644
cae71c
--- a/pcs/cli/common/lib_wrapper.py
cae71c
+++ b/pcs/cli/common/lib_wrapper.py
cae71c
@@ -1,9 +1,5 @@
cae71c
 import logging
cae71c
 from collections import namedtuple
cae71c
-from typing import (
cae71c
-    Any,
cae71c
-    Dict,
cae71c
-)
cae71c
 
cae71c
 from pcs import settings
cae71c
 from pcs.cli.common import middleware
cae71c
@@ -36,9 +32,6 @@ from pcs.lib.commands.constraint import order as constraint_order
cae71c
 from pcs.lib.commands.constraint import ticket as constraint_ticket
cae71c
 from pcs.lib.env import LibraryEnvironment
cae71c
 
cae71c
-# Note: not properly typed
cae71c
-_CACHE: Dict[Any, Any] = {}
cae71c
-
cae71c
 
cae71c
 def wrapper(dictionary):
cae71c
     return namedtuple("wrapper", dictionary.keys())(**dictionary)
cae71c
@@ -106,12 +99,6 @@ def bind_all(env, run_with_middleware, dictionary):
cae71c
     )
cae71c
 
cae71c
 
cae71c
-def get_module(env, middleware_factory, name):
cae71c
-    if name not in _CACHE:
cae71c
-        _CACHE[name] = load_module(env, middleware_factory, name)
cae71c
-    return _CACHE[name]
cae71c
-
cae71c
-
cae71c
 def load_module(env, middleware_factory, name):
cae71c
     # pylint: disable=too-many-return-statements, too-many-branches
cae71c
     if name == "acl":
cae71c
@@ -544,4 +531,4 @@ class Library:
cae71c
         self.middleware_factory = middleware_factory
cae71c
 
cae71c
     def __getattr__(self, name):
cae71c
-        return get_module(self.env, self.middleware_factory, name)
cae71c
+        return load_module(self.env, self.middleware_factory, name)
cae71c
diff --git a/pcs/config.py b/pcs/config.py
cae71c
index e0d179f0..6da1151b 100644
cae71c
--- a/pcs/config.py
cae71c
+++ b/pcs/config.py
cae71c
@@ -691,6 +691,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
cae71c
     orig_usefile = utils.usefile
cae71c
     orig_filename = utils.filename
cae71c
     orig_middleware = lib.middleware_factory
cae71c
+    orig_env = lib.env
cae71c
     # configure old code to read the CIB from a file
cae71c
     utils.usefile = True
cae71c
     utils.filename = os.path.join(
cae71c
@@ -700,6 +701,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
cae71c
     lib.middleware_factory = orig_middleware._replace(
cae71c
         cib=middleware.cib(utils.filename, utils.touch_cib_file)
cae71c
     )
cae71c
+    lib.env = utils.get_cli_env()
cae71c
     # export the CIB to text
cae71c
     result = False, []
cae71c
     if os.path.isfile(utils.filename):
cae71c
@@ -708,6 +710,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
cae71c
     utils.usefile = orig_usefile
cae71c
     utils.filename = orig_filename
cae71c
     lib.middleware_factory = orig_middleware
cae71c
+    lib.env = orig_env
cae71c
     return result
cae71c
 
cae71c
 
cae71c
-- 
cae71c
2.39.2
cae71c