Skip to content

Commit

Permalink
do not show warning for expired location constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
Pederrr committed Sep 12, 2023
1 parent 34e10a2 commit de41961
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -17,13 +17,16 @@
properly ([rhbz#2227233])
- Improved error messages and documentation of `pcs resource move` command
([rhbz#2233763])
- Do not display warning in `pcs status` for expired constraints that were
created by moving resources ([rhbz#2111583])

[rhbz#2217850]: https://bugzilla.redhat.com/show_bug.cgi?id=2217850
[rhbz#2219388]: https://bugzilla.redhat.com/show_bug.cgi?id=2219388
[rhbz#2226778]: https://bugzilla.redhat.com/show_bug.cgi?id=2226778
[rhbz#2227233]: https://bugzilla.redhat.com/show_bug.cgi?id=2227233
[rhbz#2227234]: https://bugzilla.redhat.com/show_bug.cgi?id=2227234
[rhbz#2233763]: https://bugzilla.redhat.com/show_bug.cgi?id=2233763
[rhbz#2111583]: https://bugzilla.redhat.com/show_bug.cgi?id=2111583


## [0.10.17] - 2023-06-19
Expand Down
41 changes: 30 additions & 11 deletions pcs/lib/commands/status.py
Expand Up @@ -4,7 +4,6 @@
List,
Mapping,
NamedTuple,
cast,
)

from lxml.etree import _Element
Expand All @@ -22,20 +21,25 @@
format_list,
indent,
)
from pcs.common.types import CibRuleInEffectStatus
from pcs.lib.booth import status as booth_status
from pcs.lib.booth.env import BoothEnv
from pcs.lib.cib import (
nvpair,
stonith,
)
from pcs.lib.cib.rule import rule_element_to_dto
from pcs.lib.cib.rule.in_effect import get_rule_evaluator
from pcs.lib.cib.tools import (
get_constraints,
get_crm_config,
get_resources,
)
from pcs.lib.communication.nodes import CheckReachability
from pcs.lib.communication.tools import run as run_communication
from pcs.lib.env import LibraryEnvironment
from pcs.lib.errors import LibraryError
from pcs.lib.external import CommandRunner
from pcs.lib.node import get_existing_nodes_names
from pcs.lib.node_communication import NodeTargetLibFactory
from pcs.lib.pacemaker.live import (
Expand Down Expand Up @@ -136,7 +140,9 @@ def full_cluster_status_plaintext(
# check stonith configuration
warning_list = list(warning_list)
warning_list.extend(_stonith_warnings(cib, is_sbd_running))
warning_list.extend(_move_constraints_warnings(cib))
warning_list.extend(
_move_constraints_warnings(cib, runner, report_processor)
)
warning_list.extend(
_booth_authfile_warning(env.report_processor, env.get_booth_env(None))
)
Expand Down Expand Up @@ -227,18 +233,31 @@ def _stonith_warnings(cib: _Element, is_sbd_running: bool) -> List[str]:
return warning_list


def _move_constraints_warnings(cib: _Element) -> List[str]:
def _move_constraints_warnings(
cib: _Element, runner: CommandRunner, report_processor: ReportProcessor
) -> List[str]:
warning_list: List[str] = []
resource_id_list = cast(
List[str],
cib.xpath("//constraints/rsc_location[starts-with(@id, 'cli-')]/@rsc"),
)
if resource_id_list:
rule_evaluator = get_rule_evaluator(cib, runner, report_processor, True)
constraint_el = get_constraints(cib)

resource_ids = set()
for element in constraint_el.findall("./rsc_location"):
resource_id = element.get("rsc")
if resource_id and str(element.attrib["id"]).startswith("cli"):
rules = [
rule_element_to_dto(rule_evaluator, rule_el)
for rule_el in element.findall("./rule")
]
if not rules or not all(
rule.in_effect == CibRuleInEffectStatus.EXPIRED
for rule in rules
):
resource_ids.add(resource_id)

if resource_ids:
warning_list.append(
"Following resources have been moved and their move constraints "
"are still in place: {0}".format(
format_list(list(set(resource_id_list)))
)
"are still in place: {0}".format(format_list(list(resource_ids)))
)
warning_list.append(
"Run 'pcs constraint location' or 'pcs resource clear "
Expand Down

0 comments on commit de41961

Please sign in to comment.