From ab260d3c3004a59f1c20c41e2b386529793a50aa Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Jan 22 2021 12:12:38 +0000 Subject: Fix: libpacemaker: Don't show an empty locations list. --- diff --git a/cts/cli/regression.tools.exp b/cts/cli/regression.tools.exp index 98c8f23..f5de14d 100644 --- a/cts/cli/regression.tools.exp +++ b/cts/cli/regression.tools.exp @@ -3472,20 +3472,16 @@ Removing constraint: cli-prefer-dummy * Passed: crm_diff - Create an XML patchset =#=#=#= Begin test: Check locations and constraints for prim1 =#=#=#= prim1: - * Locations: =#=#=#= End test: Check locations and constraints for prim1 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim1 =#=#=#= Begin test: Recursively check locations and constraints for prim1 =#=#=#= prim1: - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim1 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim1 =#=#=#= Begin test: Check locations and constraints for prim1 in XML =#=#=#= - - - + @@ -3494,9 +3490,7 @@ prim1: =#=#=#= Begin test: Recursively check locations and constraints for prim1 in XML =#=#=#= - - - + @@ -3508,7 +3502,6 @@ prim2: * Node cluster01 (score=INFINITY, id=prim2-on-cluster1) Colocations: * prim3 (score=INFINITY, id=colocation-prim2-prim3-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim2 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim2 =#=#=#= Begin test: Recursively check locations and constraints for prim2 =#=#=#= @@ -3517,20 +3510,18 @@ prim2: * Node cluster01 (score=INFINITY, id=prim2-on-cluster1) Colocations: * prim3 (score=INFINITY, id=colocation-prim2-prim3-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim2 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim2 =#=#=#= Begin test: Check locations and constraints for prim2 in XML =#=#=#= - + - + - @@ -3541,13 +3532,12 @@ Colocations: - + - + - @@ -3560,7 +3550,6 @@ Colocations: * Locations: * Node cluster01 (score=INFINITY, id=prim2-on-cluster1) prim3: - * Locations: Colocations: * prim4 (score=INFINITY, id=colocation-prim3-prim4-INFINITY) * Locations: @@ -3573,7 +3562,6 @@ Colocations: * Locations: * Node cluster01 (score=INFINITY, id=prim2-on-cluster1) prim3: - * Locations: Colocations: * prim4 (score=INFINITY, id=colocation-prim3-prim4-INFINITY) * Locations: @@ -3585,18 +3573,16 @@ Colocations: - + - + - - - + - + - + @@ -3608,18 +3594,16 @@ Colocations: - + - + - - - + - + - + @@ -3629,29 +3613,23 @@ Colocations: =#=#=#= Begin test: Check locations and constraints for prim4 =#=#=#= Colocations: * prim10 (score=INFINITY, id=colocation-prim10-prim4-INFINITY) - * Locations: * prim3 (score=INFINITY, id=colocation-prim3-prim4-INFINITY) - * Locations: prim4: * Locations: * Node cluster02 (score=INFINITY, id=prim4-on-cluster2) Colocations: * prim5 (score=INFINITY, id=colocation-prim4-prim5-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim4 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim4 =#=#=#= Begin test: Recursively check locations and constraints for prim4 =#=#=#= Colocations: * prim10 (score=INFINITY, id=colocation-prim10-prim4-INFINITY) - * Locations: * prim3 (score=INFINITY, id=colocation-prim3-prim4-INFINITY) - * Locations: prim4: * Locations: * Node cluster02 (score=INFINITY, id=prim4-on-cluster2) Colocations: * prim5 (score=INFINITY, id=colocation-prim4-prim5-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim4 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim4 =#=#=#= Begin test: Check locations and constraints for prim4 in XML =#=#=#= @@ -3659,18 +3637,15 @@ Colocations: - - - + - + - @@ -3682,18 +3657,15 @@ Colocations: - - - + - + - @@ -3706,7 +3678,6 @@ Colocations: * Locations: * Node cluster02 (score=INFINITY, id=prim4-on-cluster2) prim5: - * Locations: =#=#=#= End test: Check locations and constraints for prim5 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim5 =#=#=#= Begin test: Recursively check locations and constraints for prim5 =#=#=#= @@ -3715,7 +3686,6 @@ Colocations: * Locations: * Node cluster02 (score=INFINITY, id=prim4-on-cluster2) prim5: - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim5 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim5 =#=#=#= Begin test: Check locations and constraints for prim5 in XML =#=#=#= @@ -3723,13 +3693,11 @@ prim5: - + - + - - - + @@ -3740,13 +3708,11 @@ prim5: - + - + - - - + @@ -3768,9 +3734,9 @@ prim6: - + - + @@ -3781,9 +3747,9 @@ prim6: - + - + @@ -3792,29 +3758,22 @@ prim6: * Passed: crm_resource - Recursively check locations and constraints for prim6 in XML =#=#=#= Begin test: Check locations and constraints for prim7 =#=#=#= prim7: - * Locations: Colocations: * group (score=INFINITY, id=colocation-prim7-group-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim7 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim7 =#=#=#= Begin test: Recursively check locations and constraints for prim7 =#=#=#= prim7: - * Locations: Colocations: * group (score=INFINITY, id=colocation-prim7-group-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim7 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim7 =#=#=#= Begin test: Check locations and constraints for prim7 in XML =#=#=#= - - - + - @@ -3824,12 +3783,9 @@ Colocations: =#=#=#= Begin test: Recursively check locations and constraints for prim7 in XML =#=#=#= - - - + - @@ -3838,29 +3794,22 @@ Colocations: * Passed: crm_resource - Recursively check locations and constraints for prim7 in XML =#=#=#= Begin test: Check locations and constraints for prim8 =#=#=#= prim8: - * Locations: Colocations: * gr2 (score=INFINITY, id=colocation-prim8-gr2-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim8 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim8 =#=#=#= Begin test: Recursively check locations and constraints for prim8 =#=#=#= prim8: - * Locations: Colocations: * gr2 (score=INFINITY, id=colocation-prim8-gr2-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim8 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim8 =#=#=#= Begin test: Check locations and constraints for prim8 in XML =#=#=#= - - - + - @@ -3870,12 +3819,9 @@ Colocations: =#=#=#= Begin test: Recursively check locations and constraints for prim8 in XML =#=#=#= - - - + - @@ -3884,29 +3830,22 @@ Colocations: * Passed: crm_resource - Recursively check locations and constraints for prim8 in XML =#=#=#= Begin test: Check locations and constraints for prim9 =#=#=#= prim9: - * Locations: Colocations: * clone (score=INFINITY, id=colocation-prim9-clone-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim9 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim9 =#=#=#= Begin test: Recursively check locations and constraints for prim9 =#=#=#= prim9: - * Locations: Colocations: * clone (score=INFINITY, id=colocation-prim9-clone-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim9 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim9 =#=#=#= Begin test: Check locations and constraints for prim9 in XML =#=#=#= - - - + - @@ -3916,12 +3855,9 @@ Colocations: =#=#=#= Begin test: Recursively check locations and constraints for prim9 in XML =#=#=#= - - - + - @@ -3930,7 +3866,6 @@ Colocations: * Passed: crm_resource - Recursively check locations and constraints for prim9 in XML =#=#=#= Begin test: Check locations and constraints for prim10 =#=#=#= prim10: - * Locations: Colocations: * prim4 (score=INFINITY, id=colocation-prim10-prim4-INFINITY) * Locations: @@ -3939,7 +3874,6 @@ Colocations: * Passed: crm_resource - Check locations and constraints for prim10 =#=#=#= Begin test: Recursively check locations and constraints for prim10 =#=#=#= prim10: - * Locations: Colocations: * prim4 (score=INFINITY, id=colocation-prim10-prim4-INFINITY) * Locations: @@ -3949,14 +3883,12 @@ Colocations: =#=#=#= Begin test: Check locations and constraints for prim10 in XML =#=#=#= - - - + - + - + @@ -3966,14 +3898,12 @@ Colocations: =#=#=#= Begin test: Recursively check locations and constraints for prim10 in XML =#=#=#= - - - + - + - + @@ -3983,23 +3913,17 @@ Colocations: =#=#=#= Begin test: Check locations and constraints for prim11 =#=#=#= Colocations: * prim13 (score=INFINITY, id=colocation-prim13-prim11-INFINITY) - * Locations: prim11: - * Locations: Colocations: * prim12 (score=INFINITY, id=colocation-prim11-prim12-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim11 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim11 =#=#=#= Begin test: Recursively check locations and constraints for prim11 =#=#=#= Colocations: * prim13 (score=INFINITY, id=colocation-prim13-prim11-INFINITY) - * Locations: prim11: - * Locations: Colocations: * prim12 (score=INFINITY, id=colocation-prim11-prim12-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim11 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim11 =#=#=#= Begin test: Check locations and constraints for prim11 in XML =#=#=#= @@ -4007,14 +3931,10 @@ Colocations: - - - - + - @@ -4026,14 +3946,10 @@ Colocations: - - - - + - @@ -4043,23 +3959,17 @@ Colocations: =#=#=#= Begin test: Check locations and constraints for prim12 =#=#=#= Colocations: * prim11 (score=INFINITY, id=colocation-prim11-prim12-INFINITY) - * Locations: prim12: - * Locations: Colocations: * prim13 (score=INFINITY, id=colocation-prim12-prim13-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim12 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim12 =#=#=#= Begin test: Recursively check locations and constraints for prim12 =#=#=#= Colocations: * prim11 (score=INFINITY, id=colocation-prim11-prim12-INFINITY) - * Locations: prim12: - * Locations: Colocations: * prim13 (score=INFINITY, id=colocation-prim12-prim13-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim12 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim12 =#=#=#= Begin test: Check locations and constraints for prim12 in XML =#=#=#= @@ -4067,14 +3977,10 @@ Colocations: - - - - + - @@ -4086,14 +3992,10 @@ Colocations: - - - - + - @@ -4103,23 +4005,17 @@ Colocations: =#=#=#= Begin test: Check locations and constraints for prim13 =#=#=#= Colocations: * prim12 (score=INFINITY, id=colocation-prim12-prim13-INFINITY) - * Locations: prim13: - * Locations: Colocations: * prim11 (score=INFINITY, id=colocation-prim13-prim11-INFINITY) - * Locations: =#=#=#= End test: Check locations and constraints for prim13 - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for prim13 =#=#=#= Begin test: Recursively check locations and constraints for prim13 =#=#=#= Colocations: * prim12 (score=INFINITY, id=colocation-prim12-prim13-INFINITY) - * Locations: prim13: - * Locations: Colocations: * prim11 (score=INFINITY, id=colocation-prim13-prim11-INFINITY) - * Locations: =#=#=#= End test: Recursively check locations and constraints for prim13 - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for prim13 =#=#=#= Begin test: Check locations and constraints for prim13 in XML =#=#=#= @@ -4127,14 +4023,10 @@ Colocations: - - - - + - @@ -4146,14 +4038,10 @@ Colocations: - - - - + - @@ -4163,17 +4051,13 @@ Colocations: =#=#=#= Begin test: Check locations and constraints for group =#=#=#= Colocations: * prim7 (score=INFINITY, id=colocation-prim7-group-INFINITY) - * Locations: group: - * Locations: =#=#=#= End test: Check locations and constraints for group - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for group =#=#=#= Begin test: Recursively check locations and constraints for group =#=#=#= Colocations: * prim7 (score=INFINITY, id=colocation-prim7-group-INFINITY) - * Locations: group: - * Locations: =#=#=#= End test: Recursively check locations and constraints for group - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for group =#=#=#= Begin test: Check locations and constraints for group in XML =#=#=#= @@ -4181,11 +4065,8 @@ group: - - - - + @@ -4196,11 +4077,8 @@ group: - - - - + @@ -4209,17 +4087,13 @@ group: =#=#=#= Begin test: Check locations and constraints for clone =#=#=#= Colocations: * prim9 (score=INFINITY, id=colocation-prim9-clone-INFINITY) - * Locations: clone: - * Locations: =#=#=#= End test: Check locations and constraints for clone - OK (0) =#=#=#= * Passed: crm_resource - Check locations and constraints for clone =#=#=#= Begin test: Recursively check locations and constraints for clone =#=#=#= Colocations: * prim9 (score=INFINITY, id=colocation-prim9-clone-INFINITY) - * Locations: clone: - * Locations: =#=#=#= End test: Recursively check locations and constraints for clone - OK (0) =#=#=#= * Passed: crm_resource - Recursively check locations and constraints for clone =#=#=#= Begin test: Check locations and constraints for clone in XML =#=#=#= @@ -4227,11 +4101,8 @@ clone: - - - - + @@ -4242,11 +4113,8 @@ clone: - - - - + diff --git a/lib/pacemaker/pcmk_output.c b/lib/pacemaker/pcmk_output.c index 78171d7..aab6876 100644 --- a/lib/pacemaker/pcmk_output.c +++ b/lib/pacemaker/pcmk_output.c @@ -244,8 +244,7 @@ static int locations_list(pcmk__output_t *out, va_list args) { GList *lpc = NULL; GList *list = rsc->rsc_location; - - out->begin_list(out, NULL, NULL, "Locations"); + int rc = pcmk_rc_no_output; for (lpc = list; lpc != NULL; lpc = lpc->next) { pe__location_t *cons = lpc->data; @@ -256,15 +255,15 @@ static int locations_list(pcmk__output_t *out, va_list args) { pe_node_t *node = (pe_node_t *) lpc2->data; char *score = score2char(node->weight); + PCMK__OUTPUT_LIST_HEADER(out, FALSE, rc, "Locations"); out->list_item(out, NULL, "Node %s (score=%s, id=%s)", node->details->uname, score, cons->id); free(score); } } - out->end_list(out); - - return pcmk_rc_ok; + PCMK__OUTPUT_LIST_FOOTER(out, rc); + return rc; } PCMK__OUTPUT_ARGS("locations-list", "pe_resource_t *") @@ -273,8 +272,7 @@ static int locations_list_xml(pcmk__output_t *out, va_list args) { GList *lpc = NULL; GList *list = rsc->rsc_location; - - pcmk__output_xml_create_parent(out, "locations", NULL); + int rc = pcmk_rc_no_output; for (lpc = list; lpc != NULL; lpc = lpc->next) { pe__location_t *cons = lpc->data; @@ -285,6 +283,8 @@ static int locations_list_xml(pcmk__output_t *out, va_list args) { pe_node_t *node = (pe_node_t *) lpc2->data; char *score = score2char(node->weight); + PCMK__OUTPUT_LIST_HEADER(out, FALSE, rc, "locations"); + pcmk__output_create_xml_node(out, "location", "host", node->details->uname, "id", cons->id, @@ -294,9 +294,8 @@ static int locations_list_xml(pcmk__output_t *out, va_list args) { } } - pcmk__output_xml_pop_parent(out); - - return pcmk_rc_ok; + PCMK__OUTPUT_LIST_FOOTER(out, rc); + return rc; } PCMK__OUTPUT_ARGS("stacks-constraints", "pe_resource_t *", "pe_working_set_t *", "gboolean")