Commit Graph

21 Commits

Author SHA1 Message Date
Felipe Reyes 8446b38347 Use get_property instead of get-property
hacluster uses the command "crm configure get-property <CMD>" to obtain
a property of the cluster, although "get-property" has been deprecated
in favor of "get_property", since crmsh-4.2.1 a warning is printed to
stdout[0] breaking the parsing.

    # crm configure get-property maintenance-mode 2>/dev/null
    WARNING: This command 'get-property' is deprecated, please use 'get_property'
    INFO: "get-property" is accepted as "get_property"
    true

[0] 86282af8e5

Change-Id: Id0ee9ab1873d14dcd1c960001cdeb8318f599ef5
Closes-Bug: #2008704
2023-02-27 11:02:28 -03:00
Corey Bryant a03b0b2a87 Only return hacluster nodes from list_nodes()
list_nodes() recently had some changes to run 'crm node show'
in jammy+ instead of 'crm node status'. The difference is that
'crm node show' returns the pacemaker-remote nodes in addition
 to the hacluster nodes. This change limits the nodes returned
by list_nodes() to the hacluster nodes (ie. the nodes that
have a node ID).

Closes-Bug: #1995295
Change-Id: Ia405d4270f56c949f79167f8b75c1304b598b918
2022-11-01 15:40:09 +01:00
Corey Bryant f73ca4d52f Update 'crm node show' parsing to trim ': member'
The command 'crm node show' is used on jammy to retrieve the list of
nodes defined in a cluster. The output for nodes includes ': member'
which breaks ensuing commands that are using list_nodes() output.

For example:
juju-3f6cb6-zaza-4135aa8b2509-8.project.serverstack: member

This change trims everything including and after the ':' from the
output.

Closes-Bug: #1994160
Change-Id: I54a4f854f3e293503ec97d99a49b6dc51ee50c87
2022-10-25 19:16:55 +00:00
Felipe Reyes 4e53bea076 Fix 'crm node show' parsing to get list of nodes.
The command 'crm node show' is used on jammy to retrieve the list of
nodes defined in a cluster, although this command also includes the
properties set on a node (e.g. standby=off) which breaks the current
logic parsing.

This change uses a regular expresion to filter out all the lines from
the output that don't start with a non-white character (^\S+).

Change-Id: I3e00daa1b877a7faae1370f08b2d9c5bd7795c5f
Closes-Bug: #1987685
Related-Bug: #1972022
2022-08-25 12:13:33 -04:00
Hervé Beraud e195794f39 Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Note that https://github.com/openstack/charms.openstack is used during tests
and he need `mock`, unfortunatelly it doesn't declare `mock` in its
requirements so it retrieve mock from other charm project (cross dependency).
So we depend on charms.openstack first and when
Ib1ed5b598a52375e29e247db9ab4786df5b6d142 will be merged then CI
will pass without errors.

Depends-On: Ib1ed5b598a52375e29e247db9ab4786df5b6d142
Change-Id: I631d32e1a330bcd17b53ee873833e8434023958f
2021-12-15 10:32:40 +00:00
Robert Gildein 64e696ae74 Improved action to display the cluster status
The `state` action will provide details about the health of the cluster.
This action has one parameter to display the history of the cluster status,
which is false by default.

Closes-Bug: #1717831
Change-Id: Iaf6e4a75a36491eab8e6802a6f437e5f410ed29e
2021-03-16 14:12:48 +01:00
Alvaro Uria 457f88eda6 Adjust quorum after node removal
Add an `update-ring` action for that purpose.
Also print more on various pacemaker failures.
Also removed some dead code.

Func-Test-PR: https://github.com/openstack-charmers/zaza-openstack-tests/pull/369
Change-Id: I35c0c9ce67fd459b9c3099346705d43d76bbdfe4
Closes-Bug: #1400481
Related-Bug: #1874719
Co-Authored-By: Aurelien Lourot <aurelien.lourot@canonical.com>
Co-Authored-By: Felipe Reyes <felipe.reyes@canonical.com>
2021-03-11 17:24:01 +01:00
Jarred Wilson 33c10cff26 Mock the sqlite3 kvstore
This patch replaces the sqlite3 kvstore implementation provided by charmhelpers. Patches the kvstore used in pcmk for both the test_pcmk and the test_hacluster_hooks tests.

closes-bug: #1908282

Change-Id: I3320735314f0b03aecec6635ef82ddd44eecaff1
2021-01-13 15:20:46 -05:00
Liam Young 527fd2c704 Spread pacemaker remote resources across cluster.
Use location directives to spread pacemaker remote resources across
cluster. This is to prevent multiple resources being taken down in
the event of a single node failure. This would usually not be a
problem but if the node is being queried by masakari host
monitors at the time the node goes down then the query can hang.

Change-Id: Ib8a667d0d82ef3dcd4da27e62460b4f0ce32ee43
Partial-Bug: #1889094
Depends-On: Ic45dbdd9d8581f25549580c7e98a8d6e0bf8c3e7
2020-09-08 11:35:25 +00:00
David Ames 9364440075 Make the workgroup status more robust
The current charm does not indicated to the end user when a specific
resource is not running. Neither does it indicate when a node is offline
or stopped.

Validate that configured resources are actually running and let the end
user know if they are not.

Closes-Bug: #1834263

Change-Id: I1171e71ae3b015b4b838b7ecf0de18eb10d7c8f2
2019-06-25 23:26:10 +00:00
Liam Young 6e3cec799f Use XML to get node list
The current list_nodes command tries to parse the output of
"crm node list" to get a list of nodes. But the output is messy if
remote nodes are present so use "crm node status" to get properly
formatted XML which can be reliably parsed.

Change-Id: Iea7ef3dca194e7440dc2cde2624d07e990006685
2019-04-03 10:49:22 +00:00
Alex Kavanagh 02b406b6f3 Convert charm to Python 3
Change-Id: Ib7cc06b3b42f26f725a9ea79f09189cc72952d29
2019-03-14 12:40:07 +00:00
Felipe Reyes 639dadb141 Support update parameters of a resource
This patch implements support to update parameters of an already
existing resource using "crm configure load update FILE"

The parameters of a resource are hashed using md5 and stored in the kv
store, when the checksum doesn't match the resource is updated,
otherwise discarded.

Change-Id: I5735eaa1309c57e3620b0a6f68ffe13ec8165592
Closes-Bug: 1753432
2019-02-13 18:16:35 -03:00
Chris MacNaughton (icey) b20a87517d Revert "Support update parameters of a resource"
This reverts commit 02d83b2e4e.

Change-Id: I47db2d4ad1672827e7e5667e9fe9f8b3737b8906
2018-09-05 15:42:47 +00:00
Chris MacNaughton (icey) 8bdb2c402a Revert "Use crm configure show xml to find defined resources"
This reverts commit 1fdeb0b3e0.

Change-Id: Iade3bbc06262c9234a87826e5a8e1f43535f74c6
2018-09-05 14:02:59 +00:00
Felipe Reyes 1fdeb0b3e0 Use crm configure show xml to find defined resources
Using the xml output provided by "crm configure" and parsing it to look
for nodes that match the xpath ".//*[@id='$NAME']". The test case added
uses the xml generated when ceph-radosgw has dns-ha enabled which
creates a groups of hostnames that cross references resources making the
previous approach give false positives.

Change-Id: If1c3584c889e7e101f15ed5ba6de89c687667754
Closes-Bug: 1789915
2018-09-03 22:23:49 -03:00
Felipe Reyes 02d83b2e4e Support update parameters of a resource
This patch implements support to update parameters of an already
existing resource using "crm configure load update FILE"

Change-Id: I22730091d674145db4a1187b0904d9f88d9d8c6d
Partial-Bug: #1753432
2018-06-07 08:59:04 -04:00
Felipe Reyes e95488afa0 Add maintenance-mode configuration option
This config option allows syadmins to set pacemaker in maintenance mode
which will stop monitoring on the configured resources, so services
can be stopped/restarted and pacemaker won't start them again or
migrating resources (e.g. virtual IPs).

Change-Id: I232a043e6d9d45f2cf833d4f7c4d89b079f258bb
Partial-Bug: 1698926
2017-08-16 17:44:44 +00:00
David Ames fda5176bd5 Fix pacemaker down crm infinite loop
On corosync restart, corosync may take longer than a minute to come
up. The systemd start script times out too soon. Then pacemaker which
is dependent on corosync is immediatly started and fails as corosync
is still in the process of starting.

Subsequently the charm would run crm node list to validate pacemaker.
This would become an infinite loop.

This change adds longer timeout values for systemd scripts and adds
better error handling and communication to the end user.

Change-Id: I7c3d018a03fddfb1f6bfd91fd7aeed4b13879e45
Partial-Bug: #1654403
2017-01-24 10:55:29 -08:00
James Page e1fb837f79 Re-license charm as Apache-2.0
All contributions to this charm where made under Canonical
copyright; switch to Apache-2.0 license as agreed so we
can move forward with official project status.

This charm does include files from a few other projects
which we can't re-license - leave those as is for now.

Change-Id: I4d0ec0cceed05ef6b6153148c8b9fc9333189b77
2016-06-28 12:12:40 +01:00
Felipe Reyes 5587834633 Check the output of 'crm resource status' to determine if service is running 2015-03-18 00:29:05 -03:00