From d1a658601487175ec70054e56ade116f3dbcecf6 Mon Sep 17 00:00:00 2001 From: Miroslav Lisik Date: Mon, 6 Mar 2023 15:42:35 +0100 Subject: [PATCH 1/2] fix `pcs config checkpoint diff` command --- CHANGELOG.md | 26 -------------------------- pcs/cli/common/lib_wrapper.py | 15 +-------------- pcs/config.py | 3 +++ 3 files changed, 4 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0945d727..7d3d606b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,31 +1,5 @@ # Change Log -## [Unreleased] - -### Added -- Warning to `pcs resource|stonith update` commands about not using agent - self-validation feature when the resource is already misconfigured - ([rhbz#2151524]) - -### Fixed -- Graceful stopping pcsd service using `systemctl stop pcsd` command -- Displaying bool and integer values in `pcs resource config` command - ([rhbz#2151164], [ghissue#604]) -- Allow time values in stonith-watchdog-time property ([rhbz#2158790]) - -### Changed -- Resource/stonith agent self-validation of instance attributes is now - disabled by default, as many agents do not work with it properly. - Use flag '--agent-validation' to enable it in supported commands. - ([rhbz#2159454]) - -[ghissue#604]: https://github.com/ClusterLabs/pcs/issues/604 -[rhbz#2151164]: https://bugzilla.redhat.com/show_bug.cgi?id=2151164 -[rhbz#2151524]: https://bugzilla.redhat.com/show_bug.cgi?id=2151524 -[rhbz#2159454]: https://bugzilla.redhat.com/show_bug.cgi?id=2159454 -[rhbz#2158790]: https://bugzilla.redhat.com/show_bug.cgi?id=2158790 - - ## [0.11.4] - 2022-11-21 ### Security diff --git a/pcs/cli/common/lib_wrapper.py b/pcs/cli/common/lib_wrapper.py index 217bfe3e..e6411e3c 100644 --- a/pcs/cli/common/lib_wrapper.py +++ b/pcs/cli/common/lib_wrapper.py @@ -1,9 +1,5 @@ import logging from collections import namedtuple -from typing import ( - Any, - Dict, -) from pcs import settings from pcs.cli.common import middleware @@ -36,9 +32,6 @@ from pcs.lib.commands.constraint import order as constraint_order from pcs.lib.commands.constraint import ticket as constraint_ticket from pcs.lib.env import LibraryEnvironment -# Note: not properly typed -_CACHE: Dict[Any, Any] = {} - def wrapper(dictionary): return namedtuple("wrapper", dictionary.keys())(**dictionary) @@ -106,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": @@ -544,4 +531,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 e0d179f0..6da1151b 100644 --- a/pcs/config.py +++ b/pcs/config.py @@ -691,6 +691,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( @@ -700,6 +701,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): @@ -708,6 +710,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.39.2