Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 918398 Details for
Bug 1115608
Colocating Sets of Resources: 'setoptions' is invalid
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
proposed fix
0001-Fixed-constraint-resources-set.patch (text/plain), 18.80 KB, created by
Tomas Jelinek
on 2014-07-16 12:54:47 UTC
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Tomas Jelinek
Created:
2014-07-16 12:54:47 UTC
Size:
18.80 KB
patch
obsolete
>From 0ddb91f0607324926c7ef839c9ae85fa21d5d739 Mon Sep 17 00:00:00 2001 >From: Tomas Jelinek <tojeline@redhat.com> >Date: Tue, 15 Jul 2014 16:31:35 +0200 >Subject: [PATCH] Fixed constraint resources set > >* fixed documentation >* fixed set id creation >* added options validation >--- > pcs/constraint.py | 33 ++++++++++++++- > pcs/pcs.8 | 8 ++-- > pcs/test/test_constraints.py | 98 ++++++++++++++++++++++++++++++++++++++------ > pcs/usage.py | 15 +++++-- > 4 files changed, 133 insertions(+), 21 deletions(-) > >diff --git a/pcs/constraint.py b/pcs/constraint.py >index 7a40d9c..4f0a0d7 100644 >--- a/pcs/constraint.py >+++ b/pcs/constraint.py >@@ -250,9 +250,24 @@ def colocation_set(argv): > rsc_colocation = ET.SubElement(constraints,"rsc_colocation") > rsc_colocation.set("id", utils.find_unique_id(cib,colocation_id)) > rsc_colocation.set("score","INFINITY") >+ score_options = ("score", "score-attribute", "score-attribute-mangle") >+ score_specified = False > for opt in setoptions: > if opt.find("=") != -1: > name,value = opt.split("=") >+ if name not in score_options: >+ utils.err( >+ "invalid option '%s', allowed options are: %s" >+ % (name, ", ".join(score_options)) >+ ) >+ if score_specified: >+ utils.err("you cannot specify multiple score options") >+ score_specified = True >+ if name == "score" and not utils.is_score(value): >+ utils.err( >+ "invalid score '%s', use integer or INFINITY or -INFINITY" >+ % value >+ ) > rsc_colocation.set(name,value) > set_add_resource_sets(rsc_colocation, current_set, cib) > utils.replace_cib_configuration(cib) >@@ -337,6 +352,12 @@ def set_args_into_array(argv): > return current_set > > def set_add_resource_sets(elem, sets, cib): >+ allowed_options = { >+ "sequential": ("true", "false"), >+ "require-all": ("true", "false"), >+ "action" : ("start", "promote", "demote", "stop"), >+ "role" : ("Stopped", "Started", "Master", "Slave"), >+ } > > for o_set in sets: > set_id = "pcs_rsc_set" >@@ -344,12 +365,22 @@ def set_add_resource_sets(elem, sets, cib): > for opts in o_set: > if opts.find("=") != -1: > key,val = opts.split("=") >+ if key not in allowed_options: >+ utils.err( >+ "invalid option '%s', allowed options are: %s" >+ % (key, ", ".join(allowed_options.keys())) >+ ) >+ if val not in allowed_options[key]: >+ utils.err( >+ "invalid value '%s' of option '%s', allowed values are: %s" >+ % (val, key, ", ".join(allowed_options[key])) >+ ) > res_set.set(key,val) > else: > se = ET.SubElement(res_set,"resource_ref") > se.set("id",opts) > set_id = set_id + "_" + opts >- res_set.set("id", utils.find_unique_id(cib,set_id)) >+ res_set.set("id", utils.find_unique_id(cib,set_id)) > > def order_set(argv): > current_set = set_args_into_array(argv) >diff --git a/pcs/pcs.8 b/pcs/pcs.8 >index d59f093..fa48f0e 100644 >--- a/pcs/pcs.8 >+++ b/pcs/pcs.8 >@@ -387,8 +387,8 @@ List all current ordering constraints (if \fB\-\-full\fR is specified show the i > order [action] <resource id> then [action] <resource id> [options] > Add an ordering constraint specifying actions (start, stop, promote, demote) and if no action is specified the default action will be start. Available options are kind=Optional/Mandatory/Serialize and symmetrical=true/false > .TP >-order set <resource1> <resource2> [resourceN]... [options] [set <resourceX> <resourceY> ...] >-Create an ordered set of resources. >+order set <resource1> <resource2> [resourceN]... [options] [set <resourceX> <resourceY> ... [options]] >+Create an ordered set of resources. Available options are sequential=true/false, require-all=true/false, action=start/promote/demote/stop and role=Stopped/Started/Master/Slave. > .TP > order remove <resource1> [resourceN]... > Remove resource from any ordering constraint >@@ -399,8 +399,8 @@ List all current colocation constraints (if \fB\-\-full\fR is specified show the > colocation add [master|slave] <source resource id> with [master|slave] <target resource id> [score] [options] > Request <source resource> to run on the same node where pacemaker has determined <target resource> should run. Positive values of score mean the resources should be run on the same node, negative values mean the resources should not be run on the same node. Specifying 'INFINITY' (or '\-INFINITY') for the score force <source resource> to run (or not run) with <target resource>. (score defaults to "INFINITY") A role can be master or slave (if no role is specified, it defaults to 'started'). > .TP >-colocation set <resource1> <resource2> [resourceN]... [setoptions] ... [set <resourceX> <resourceY> ...] [setoptions <name>=<value>...] >-Create a colocation constraint with a resource set >+colocation set <resource1> <resource2> [resourceN]... [options] [set <resourceX> <resourceY> ... [options]] [setoptions [constraint_options]] >+Create a colocation constraint with a resource set. Available options are sequential=true/false, require-all=true/false, action=start/promote/demote/stop and role=Stopped/Started/Master/Slave. Available constraint_options are score, score-attribute and score-attribute-mangle. > .TP > colocation remove <source resource id> <target resource id> > Remove colocation constraints with <source resource> >diff --git a/pcs/test/test_constraints.py b/pcs/test/test_constraints.py >index 2062eb8..ed0bd29 100644 >--- a/pcs/test/test_constraints.py >+++ b/pcs/test/test_constraints.py >@@ -278,7 +278,7 @@ class ConstraintTest(unittest.TestCase): > output, returnVal = pcs(temp_cib, line) > assert returnVal == 0 and output == "" > >- o, r = pcs(temp_cib, "constraint colocation set D5 D6 D7 sequential=false set D8 D9 sequential=true setoptions score=INFINITY ") >+ o, r = pcs(temp_cib, "constraint colocation set D5 D6 D7 sequential=false require-all=true set D8 D9 sequential=true require-all=false action=start role=Stopped setoptions score=INFINITY ") > ac(o,"") > assert r == 0 > >@@ -286,12 +286,18 @@ class ConstraintTest(unittest.TestCase): > assert r == 0 > ac(o,"") > >- o, r = pcs(temp_cib, "constraint colocation set D5 D6 set D7 D8 set D8 D9") >+ o, r = pcs(temp_cib, "constraint colocation set D5 D6 action=stop role=Started set D7 D8 action=promote role=Slave set D8 D9 action=demote role=Master") > assert r == 0 > ac(o,"") > > o, r = pcs(temp_cib, "constraint colocation --full") >- ac(o,"Colocation Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set_D5_D6_D7-1) set D8 D9 sequential=true (id:pcs_rsc_set_D8_D9-1) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_D7_set_D8_D9)\n set D5 D6 (id:pcs_rsc_set_D5_D6) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6)\n set D5 D6 (id:pcs_rsc_set_D5_D6-1) set D7 D8 (id:pcs_rsc_set_D7_D8) set D8 D9 (id:pcs_rsc_set_D8_D9) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_set_D7_D8_set_D8_D9)\n") >+ ac(o, """\ >+Colocation Constraints: >+ Resource Sets: >+ set D5 D6 D7 sequential=false require-all=true (id:pcs_rsc_set_D5_D6_D7) set D8 D9 action=start role=Stopped sequential=true require-all=false (id:pcs_rsc_set_D8_D9) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_D7_set_D8_D9) >+ set D5 D6 (id:pcs_rsc_set_D5_D6) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6) >+ set D5 D6 action=stop role=Started (id:pcs_rsc_set_D5_D6-1) set D7 D8 action=promote role=Slave (id:pcs_rsc_set_D7_D8) set D8 D9 action=demote role=Master (id:pcs_rsc_set_D8_D9-1) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_set_D7_D8_set_D8_D9) >+""") > assert r == 0 > > o, r = pcs(temp_cib, "constraint remove pcs_rsc_colocation_D5_D6") >@@ -299,15 +305,20 @@ class ConstraintTest(unittest.TestCase): > assert r == 0 > > o, r = pcs(temp_cib, "constraint colocation --full") >- ac(o,"Colocation Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set_D5_D6_D7-1) set D8 D9 sequential=true (id:pcs_rsc_set_D8_D9-1) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_D7_set_D8_D9)\n set D5 D6 (id:pcs_rsc_set_D5_D6-1) set D7 D8 (id:pcs_rsc_set_D7_D8) set D8 D9 (id:pcs_rsc_set_D8_D9) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_set_D7_D8_set_D8_D9)\n") >+ ac(o, """\ >+Colocation Constraints: >+ Resource Sets: >+ set D5 D6 D7 sequential=false require-all=true (id:pcs_rsc_set_D5_D6_D7) set D8 D9 action=start role=Stopped sequential=true require-all=false (id:pcs_rsc_set_D8_D9) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_D7_set_D8_D9) >+ set D5 D6 action=stop role=Started (id:pcs_rsc_set_D5_D6-1) set D7 D8 action=promote role=Slave (id:pcs_rsc_set_D7_D8) set D8 D9 action=demote role=Master (id:pcs_rsc_set_D8_D9-1) setoptions score=INFINITY (id:pcs_rsc_colocation_D5_D6_set_D7_D8_set_D8_D9) >+""") > assert r == 0 > > o, r = pcs(temp_cib, "resource delete D5") >- ac(o,"Removing D5 from set pcs_rsc_set_D5_D6_D7-1\nRemoving D5 from set pcs_rsc_set_D5_D6-1\nDeleting Resource - D5\n") >+ ac(o,"Removing D5 from set pcs_rsc_set_D5_D6_D7\nRemoving D5 from set pcs_rsc_set_D5_D6-1\nDeleting Resource - D5\n") > assert r == 0 > > o, r = pcs(temp_cib, "resource delete D6") >- ac(o,"Removing D6 from set pcs_rsc_set_D5_D6_D7-1\nRemoving D6 from set pcs_rsc_set_D5_D6-1\nRemoving set pcs_rsc_set_D5_D6-1\nDeleting Resource - D6\n") >+ ac(o,"Removing D6 from set pcs_rsc_set_D5_D6_D7\nRemoving D6 from set pcs_rsc_set_D5_D6-1\nRemoving set pcs_rsc_set_D5_D6-1\nDeleting Resource - D6\n") > assert r == 0 > > o, r = pcs(temp_cib, "constraint ref D7") >@@ -318,6 +329,38 @@ class ConstraintTest(unittest.TestCase): > ac(o,"Resource: D8\n pcs_rsc_colocation_D5_D6_D7_set_D8_D9\n pcs_rsc_colocation_D5_D6_set_D7_D8_set_D8_D9\n") > assert r == 0 > >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 sequential=foo") >+ ac(output, "Error: invalid value 'foo' of option 'sequential', allowed values are: true, false\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 require-all=foo") >+ ac(output, "Error: invalid value 'foo' of option 'require-all', allowed values are: true, false\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 role=foo") >+ ac(output, "Error: invalid value 'foo' of option 'role', allowed values are: Stopped, Started, Master, Slave\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 action=foo") >+ ac(output, "Error: invalid value 'foo' of option 'action', allowed values are: start, promote, demote, stop\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 foo=bar") >+ ac(output, "Error: invalid option 'foo', allowed options are: action, role, sequential, require-all\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 setoptions foo=bar") >+ ac(output, "Error: invalid option 'foo', allowed options are: score, score-attribute, score-attribute-mangle\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 setoptions score=foo") >+ ac(output, "Error: invalid score 'foo', use integer or INFINITY or -INFINITY\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint colocation set D1 D2 setoptions score=100 score-attribute=foo") >+ ac(output, "Error: you cannot specify multiple score options\n") >+ self.assertEquals(1, retValue) >+ > def testOrderSetsRemoval(self): > o,r = pcs("resource create T0 Dummy") > ac(o,"") >@@ -402,7 +445,7 @@ class ConstraintTest(unittest.TestCase): > output, returnVal = pcs(temp_cib, line) > assert returnVal == 0 and output == "" > >- o, r = pcs(temp_cib, "constraint order set D5 D6 D7 sequential=false set D8 D9 sequential=true") >+ o, r = pcs(temp_cib, "constraint order set D5 D6 D7 sequential=false require-all=true set D8 D9 sequential=true require-all=false action=start role=Stopped") > ac(o,"") > assert r == 0 > >@@ -410,13 +453,19 @@ class ConstraintTest(unittest.TestCase): > assert r == 0 > ac(o,"") > >- o, r = pcs(temp_cib, "constraint order set D5 D6 set D7 D8 set D8 D9") >+ o, r = pcs(temp_cib, "constraint order set D5 D6 action=stop role=Started set D7 D8 action=promote role=Slave set D8 D9 action=demote role=Master") > assert r == 0 > ac(o,"") > > o, r = pcs(temp_cib, "constraint order --full") > assert r == 0 >- ac(o,"Ordering Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set_D5_D6_D7-1) set D8 D9 sequential=true (id:pcs_rsc_set_D8_D9-1) (id:pcs_rsc_order_D5_D6_D7_set_D8_D9)\n set D5 D6 (id:pcs_rsc_set_D5_D6) (id:pcs_rsc_order_D5_D6)\n set D5 D6 (id:pcs_rsc_set_D5_D6-1) set D7 D8 (id:pcs_rsc_set_D7_D8) set D8 D9 (id:pcs_rsc_set_D8_D9) (id:pcs_rsc_order_D5_D6_set_D7_D8_set_D8_D9)\n") >+ ac(o,"""\ >+Ordering Constraints: >+ Resource Sets: >+ set D5 D6 D7 sequential=false require-all=true (id:pcs_rsc_set_D5_D6_D7) set D8 D9 action=start role=Stopped sequential=true require-all=false (id:pcs_rsc_set_D8_D9) (id:pcs_rsc_order_D5_D6_D7_set_D8_D9) >+ set D5 D6 (id:pcs_rsc_set_D5_D6) (id:pcs_rsc_order_D5_D6) >+ set D5 D6 action=stop role=Started (id:pcs_rsc_set_D5_D6-1) set D7 D8 action=promote role=Slave (id:pcs_rsc_set_D7_D8) set D8 D9 action=demote role=Master (id:pcs_rsc_set_D8_D9-1) (id:pcs_rsc_order_D5_D6_set_D7_D8_set_D8_D9) >+""") > > o, r = pcs(temp_cib, "constraint remove pcs_rsc_order_D5_D6") > assert r == 0 >@@ -424,16 +473,41 @@ class ConstraintTest(unittest.TestCase): > > o, r = pcs(temp_cib, "constraint order --full") > assert r == 0 >- ac(o,"Ordering Constraints:\n Resource Sets:\n set D5 D6 D7 sequential=false (id:pcs_rsc_set_D5_D6_D7-1) set D8 D9 sequential=true (id:pcs_rsc_set_D8_D9-1) (id:pcs_rsc_order_D5_D6_D7_set_D8_D9)\n set D5 D6 (id:pcs_rsc_set_D5_D6-1) set D7 D8 (id:pcs_rsc_set_D7_D8) set D8 D9 (id:pcs_rsc_set_D8_D9) (id:pcs_rsc_order_D5_D6_set_D7_D8_set_D8_D9)\n") >+ ac(o,"""\ >+Ordering Constraints: >+ Resource Sets: >+ set D5 D6 D7 sequential=false require-all=true (id:pcs_rsc_set_D5_D6_D7) set D8 D9 action=start role=Stopped sequential=true require-all=false (id:pcs_rsc_set_D8_D9) (id:pcs_rsc_order_D5_D6_D7_set_D8_D9) >+ set D5 D6 action=stop role=Started (id:pcs_rsc_set_D5_D6-1) set D7 D8 action=promote role=Slave (id:pcs_rsc_set_D7_D8) set D8 D9 action=demote role=Master (id:pcs_rsc_set_D8_D9-1) (id:pcs_rsc_order_D5_D6_set_D7_D8_set_D8_D9) >+""") > > o, r = pcs(temp_cib, "resource delete D5") >- ac(o,"Removing D5 from set pcs_rsc_set_D5_D6_D7-1\nRemoving D5 from set pcs_rsc_set_D5_D6-1\nDeleting Resource - D5\n") >+ ac(o,"Removing D5 from set pcs_rsc_set_D5_D6_D7\nRemoving D5 from set pcs_rsc_set_D5_D6-1\nDeleting Resource - D5\n") > assert r == 0 > > o, r = pcs(temp_cib, "resource delete D6") >- ac(o,"Removing D6 from set pcs_rsc_set_D5_D6_D7-1\nRemoving D6 from set pcs_rsc_set_D5_D6-1\nRemoving set pcs_rsc_set_D5_D6-1\nDeleting Resource - D6\n") >+ ac(o,"Removing D6 from set pcs_rsc_set_D5_D6_D7\nRemoving D6 from set pcs_rsc_set_D5_D6-1\nRemoving set pcs_rsc_set_D5_D6-1\nDeleting Resource - D6\n") > assert r == 0 > >+ output, retValue = pcs(temp_cib, "constraint order set D1 D2 sequential=foo") >+ ac(output, "Error: invalid value 'foo' of option 'sequential', allowed values are: true, false\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint order set D1 D2 require-all=foo") >+ ac(output, "Error: invalid value 'foo' of option 'require-all', allowed values are: true, false\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint order set D1 D2 role=foo") >+ ac(output, "Error: invalid value 'foo' of option 'role', allowed values are: Stopped, Started, Master, Slave\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint order set D1 D2 action=foo") >+ ac(output, "Error: invalid value 'foo' of option 'action', allowed values are: start, promote, demote, stop\n") >+ self.assertEquals(1, retValue) >+ >+ output, retValue = pcs(temp_cib, "constraint order set D1 D2 foo=bar") >+ ac(output, "Error: invalid option 'foo', allowed options are: action, role, sequential, require-all\n") >+ self.assertEquals(1, retValue) >+ > def testLocationConstraintRule(self): > o, r = pcs(temp_cib, "constraint location D1 prefers rh7-1") > assert r == 0 and o == "", o >diff --git a/pcs/usage.py b/pcs/usage.py >index d96bf7e..0bfd210 100644 >--- a/pcs/usage.py >+++ b/pcs/usage.py >@@ -776,8 +776,10 @@ Commands: > symmetrical=true/false > > order set <resource1> <resource2> [resourceN]... [options] [set >- <resourceX> <resourceY> ...] >+ <resourceX> <resourceY> ... [options]] > Create an ordered set of resources. >+ Available options are sequential=true/false, require-all=true/false, >+ action=start/promote/demote/stop and role=Stopped/Started/Master/Slave. > > order remove <resource1> [resourceN]... > Remove resource from any ordering constraint >@@ -797,9 +799,14 @@ Commands: > A role can be master or slave (if no role is specified, it defaults to > 'started'). > >- colocation set <resource1> <resource2> [resourceN]... [setoptions] ... >- [set <resourceX> <resourceY> ...] [setoptions <name>=<value>...] >- Create a colocation constraint with a resource set >+ colocation set <resource1> <resource2> [resourceN]... [options] >+ [set <resourceX> <resourceY> ... [options]] >+ [setoptions [constraint_options]] >+ Create a colocation constraint with a resource set. >+ Available options are sequential=true/false, require-all=true/false, >+ action=start/promote/demote/stop and role=Stopped/Started/Master/Slave. >+ Available constraint_options are score, score-attribute and >+ score-attribute-mangle. > > colocation remove <source resource id> <target resource id> > Remove colocation constraints with <source resource> >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1115608
: 918398