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

cd5b9a
From ce48dbe8b410b2dc4f3159e22c243c1d8824cba0 Mon Sep 17 00:00:00 2001
cd5b9a
From: Miroslav Lisik <mlisik@redhat.com>
cd5b9a
Date: Thu, 16 Mar 2023 11:32:40 +0100
cd5b9a
Subject: [PATCH 1/2] fix `pcs config checkpoint diff` command
cd5b9a
cd5b9a
---
cd5b9a
 pcs/cli/common/lib_wrapper.py | 15 +--------------
cd5b9a
 pcs/config.py                 |  3 +++
cd5b9a
 2 files changed, 4 insertions(+), 14 deletions(-)
cd5b9a
cd5b9a
diff --git a/pcs/cli/common/lib_wrapper.py b/pcs/cli/common/lib_wrapper.py
cd5b9a
index 0643a808..b17f43b1 100644
cd5b9a
--- a/pcs/cli/common/lib_wrapper.py
cd5b9a
+++ b/pcs/cli/common/lib_wrapper.py
cd5b9a
@@ -1,9 +1,5 @@
cd5b9a
 import logging
cd5b9a
 from collections import namedtuple
cd5b9a
-from typing import (
cd5b9a
-    Any,
cd5b9a
-    Dict,
cd5b9a
-)
cd5b9a
 
cd5b9a
 from pcs import settings
cd5b9a
 from pcs.cli.common import middleware
cd5b9a
@@ -36,9 +32,6 @@ from pcs.lib.commands.constraint import order as constraint_order
cd5b9a
 from pcs.lib.commands.constraint import ticket as constraint_ticket
cd5b9a
 from pcs.lib.env import LibraryEnvironment
cd5b9a
 
cd5b9a
-# Note: not properly typed
cd5b9a
-_CACHE: Dict[Any, Any] = {}
cd5b9a
-
cd5b9a
 
cd5b9a
 def wrapper(dictionary):
cd5b9a
     return namedtuple("wrapper", dictionary.keys())(**dictionary)
cd5b9a
@@ -106,12 +99,6 @@ def bind_all(env, run_with_middleware, dictionary):
cd5b9a
     )
cd5b9a
 
cd5b9a
 
cd5b9a
-def get_module(env, middleware_factory, name):
cd5b9a
-    if name not in _CACHE:
cd5b9a
-        _CACHE[name] = load_module(env, middleware_factory, name)
cd5b9a
-    return _CACHE[name]
cd5b9a
-
cd5b9a
-
cd5b9a
 def load_module(env, middleware_factory, name):
cd5b9a
     # pylint: disable=too-many-return-statements, too-many-branches
cd5b9a
     if name == "acl":
cd5b9a
@@ -541,4 +528,4 @@ class Library:
cd5b9a
         self.middleware_factory = middleware_factory
cd5b9a
 
cd5b9a
     def __getattr__(self, name):
cd5b9a
-        return get_module(self.env, self.middleware_factory, name)
cd5b9a
+        return load_module(self.env, self.middleware_factory, name)
cd5b9a
diff --git a/pcs/config.py b/pcs/config.py
cd5b9a
index 6c90c13f..25007d26 100644
cd5b9a
--- a/pcs/config.py
cd5b9a
+++ b/pcs/config.py
cd5b9a
@@ -711,6 +711,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
cd5b9a
     orig_usefile = utils.usefile
cd5b9a
     orig_filename = utils.filename
cd5b9a
     orig_middleware = lib.middleware_factory
cd5b9a
+    orig_env = lib.env
cd5b9a
     # configure old code to read the CIB from a file
cd5b9a
     utils.usefile = True
cd5b9a
     utils.filename = os.path.join(
cd5b9a
@@ -720,6 +721,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
cd5b9a
     lib.middleware_factory = orig_middleware._replace(
cd5b9a
         cib=middleware.cib(utils.filename, utils.touch_cib_file)
cd5b9a
     )
cd5b9a
+    lib.env = utils.get_cli_env()
cd5b9a
     # export the CIB to text
cd5b9a
     result = False, []
cd5b9a
     if os.path.isfile(utils.filename):
cd5b9a
@@ -728,6 +730,7 @@ def _checkpoint_to_lines(lib, checkpoint_number):
cd5b9a
     utils.usefile = orig_usefile
cd5b9a
     utils.filename = orig_filename
cd5b9a
     lib.middleware_factory = orig_middleware
cd5b9a
+    lib.env = orig_env
cd5b9a
     return result
cd5b9a
 
cd5b9a
 
cd5b9a
-- 
cd5b9a
2.39.2
cd5b9a