Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix location constraint bug 1791791 #562

Closed
wants to merge 0 commits into from

Conversation

daaitudian
Copy link
Contributor

@daaitudian daaitudian commented Sep 22, 2022

Hi:
In this Pr, I made some fixes for the #235

@knet-ci-bot
Copy link

Can one of the admins verify this patch?

@tomjelinek
Copy link
Member

test this please

Copy link
Member

@tomjelinek tomjelinek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We appreciate the effort you put into this patch. However, we cannot accept it in its current form.

report_list = []
if node not in existing_nodes:
if warn :
return False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This function returns a list of ReportItem objects. It must never return False.
  • Instead of calling a function and passing it an argument to tell the function to do nothing, it is better not to call the function at all.
  • The function doesn't seem to be called with warn parameter anywhere. What's the parameter purpose than?

@@ -1195,6 +1197,19 @@ def location_rule(lib, argv, modifiers):
"resource-discovery": None,
},
)

if options["node"] == None or not options["node"]:
warn("There's no actual 'location' specified in this constraint, you can specify it by node. ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a misunderstanding of how location constraints with rules work.

There is no node option. The node is specified by the rule itself. For example, rule node_size gte 42 applies to all nodes which have the value of their attribute node_size greater than or equal to 42.

If, however, there are only date expression in the rule, like shown in #235, then the rule applies to all nodes and is therefore pointless in a location constraint.

You can check pcs.lib.cib.rule.tools to see how to analyze a rule to figure out if it contains node expressions. The module, however, is part of pcs library, new architecture, and is not compatible with the rule parser used in location constraints.

pcs/rule.py Outdated
if dom_element.hasAttribute("node"):
dom_element.removeAttribute("node")
#if dom_element.hasAttribute("node"):
# dom_element.removeAttribute("node")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is the point of this change.

pcs/rule.py Outdated
@@ -22,7 +22,7 @@ def parse_argv(argv, extra_options=None):
"""
Commandline options: no options
"""
options = {"id": None, "role": None, "score": None, "score-attribute": None}
options = {"id": None, "role": None, "node":None, "score": None, "score-attribute": None}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what is the point of this change. As explained in the other comment, there is no node option in location constraints.

@daaitudian
Copy link
Contributor Author

Thank for your reply. When I see this issue, I thought it was mean to add a [node] option for rule command to make sure the specific resource can run in the node under the rule.
Since [node] option is not required in this command, so how would you like to fix this issue?

@tomjelinek
Copy link
Member

how would you like to fix this issue?

The correct way is to analyze the constraint rule and check if it contains any node expressions (defined, not_defined, lt, gt, lte, gte, eq, ne). If it doesn't, print a warning. The check cannot be implemented simply, e.g. "lt" in rule. It needs to understand the rule structure to avoid cases when lt is used in a date expression or not as an operator.

@daaitudian
Copy link
Contributor Author

Ok, thanks for your explanation. I will modify it later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants