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

Feature: tools: List common fencing resource instance attributes via crm_resource #3399

Merged
merged 58 commits into from
Apr 10, 2024

Conversation

nrwahl2
Copy link
Contributor

@nrwahl2 nrwahl2 commented Mar 25, 2024

Next step on T620. This allows us to use pcmk__daemon_metadata() in the fencer and deprecate the daemon metadata command.

The plan is to use a similar approach in crm_resource for the various kinds of resource meta-attributes. Their descriptions will have to be pulled from Pacemaker Explained since we don't have a nice template sitting in another C file :)

It might also be nice for crm_resource --list-options to accept the name of a resource and output all the meta-attributes that apply to it (for example, clone and primitive meta-attributes for a clone resource). But that's not strictly required, and it might get messy/counter-intuitive if we don't include instance attributes... or if we do.


Edit: went ahead and added primitive meta-attributes. I can break this up at any point, preferably somewhere after --list-options=fencing.

There are a lot of commits but most of them are trivial.

@nrwahl2 nrwahl2 force-pushed the nrwahl2-T620_new branch 5 times, most recently from 6ba3a1f to f9d25b6 Compare March 25, 2024 20:49
@nrwahl2 nrwahl2 marked this pull request as draft March 25, 2024 23:33
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 25, 2024

rebased on main

@nrwahl2 nrwahl2 force-pushed the nrwahl2-T620_new branch 2 times, most recently from aa7813c to c1f267a Compare March 26, 2024 10:13
@nrwahl2 nrwahl2 marked this pull request as ready for review March 26, 2024 10:13
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 26, 2024

Went ahead and added primitive meta-attributes. I can break this up at any point, preferably somewhere after --list-options=fencing.

There are a lot of commits but most of them are trivial.

@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 26, 2024

Added missing { NULL, } to the end of primitive_meta (thanks @clumens)

Copy link
Contributor

@kgaillot kgaillot left a comment

Choose a reason for hiding this comment

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

awesome

g_set_error(&error, PCMK__EXITC_ERROR, CRM_EX_USAGE,
"Invalid --list-options value '%s'. Allowed values: "
PCMK_VALUE_FENCING,
pcmk__s(options.opt_list, "(BUG: none)"));
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to do validation in an option callback when practical, so invalid arguments are handled consistently (by glib). In this case we could save the filter rather than the text in options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC this was another case where I was trying to allow invalid values as long as the LAST value was valid. I've got no problem changing it as you described. Will do.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think validation should take precedence over last-wins, since otherwise it could obscure an error (consider a script that incorrectly adds a value intended to be used as a default, then sometimes correctly adds a different value after it)

xml/api/crm_attribute-2.37.rng Outdated Show resolved Hide resolved
lib/common/options.c Show resolved Hide resolved
lib/common/options.c Show resolved Hide resolved
@@ -20,6 +20,10 @@ extern "C" {
* \ingroup core
*/

// String equivalents of enum rsc_role_e

#define PCMK_ROLE_STOPPED "Stopped"
Copy link
Contributor

Choose a reason for hiding this comment

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

I left these internal since external code can use pcmk_role_text(v) to get them. However they can be used in the CIB, so I suppose this makes sense.

Copy link
Contributor Author

@nrwahl2 nrwahl2 Apr 5, 2024

Choose a reason for hiding this comment

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

That was my thinking. It's not required -- we could rely on pcmk_role_text(), and use literal strings in the option metadata -- but this has been our usual approach for strings used in the CIB.

What I really dislike is having these string constants split across public and internal header files. But I don't want to expose unknown and the legacy ones.

N_("Number of seconds after a failed action for this resource before "
"acting as if the failure had not occurred, and potentially "
"allowing the resource back to the node on which it failed. "
"A value of 0 indicates that this feature is disabled."),
Copy link
Contributor

Choose a reason for hiding this comment

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

We really need to update all these descriptions ... someday

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. For the most part, I copied from Pacemaker Explained, sometimes updating if I noticed obvious errors.

@@ -472,6 +472,7 @@ static GOptionEntry query_entries[] = {
{ "list-options", 0, G_OPTION_FLAG_NONE, G_OPTION_ARG_CALLBACK, command_cb,
"List all available options of the given type\n"
INDENT "Allowed values:\n"
INDENT PCMK__VALUE_PRIMITIVE "(primitive resource meta-attributes), "
INDENT PCMK_VALUE_FENCING " (parameters common to all fencing resources)",
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason just primitive is internal?

Copy link
Contributor Author

@nrwahl2 nrwahl2 Apr 5, 2024

Choose a reason for hiding this comment

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

Yep! PCMK_VALUE_FENCING already existed as a public constant for the "requires" meta-attribute. We don't need PCMK__VALUE_PRIMITIVE for anything public yet.

Though we could use it for resource variant. I've got a personal TODO note for resource variant strings... whether they should have their own constants (PCMK_VALUE or a new PCMK_<something_else>), or just use the existing PCMK_XE constants in all contexts.

@nrwahl2 nrwahl2 marked this pull request as draft April 5, 2024 09:22
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
@nrwahl2 nrwahl2 force-pushed the nrwahl2-T620_new branch from 1fc5e3b to 8057c95 Compare April 5, 2024 09:23
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Apr 5, 2024

rebased on main

nrwahl2 added 9 commits April 8, 2024 15:58
Nothing uses this yet

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Nothing uses this yet. It's not necessary for filtering the options in
the fencing_params array. However, it will be useful for telling
pcmk__daemon_metadata() which option list to use and for storing the
option list as an enum in crm_resource.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
This lists all the parameters that are common to all fencing resources
as an OCF-like metadata XML string.

Bump the CRM_FEATURE_SET.

Ref T620

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
nrwahl2 added 23 commits April 8, 2024 16:53
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Not used yet

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Not used yet

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
This lists all the meta-attributes applicable to a primitive resource as
an OCF-like metadata XML string.

Bump the CRM_FEATURE_SET.

Ref T620

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Ref T620

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Fix formatting of stop_start and note that promote/demote are affected
by is-managed/maintenance.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
Unused since 73a5d63.

Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
@nrwahl2 nrwahl2 marked this pull request as ready for review April 9, 2024 00:00
@nrwahl2 nrwahl2 force-pushed the nrwahl2-T620_new branch from 8057c95 to 6056905 Compare April 9, 2024 00:00
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Apr 9, 2024

retest this please

@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Apr 9, 2024

@kgaillot There's a race condition in CI right now. Fabio would like Chrissie to look at the logs before we merge this PR (which clears the logs). She's out today, so we need to hold off.

@nrwahl2 nrwahl2 merged commit fc69389 into ClusterLabs:main Apr 10, 2024
1 check passed
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Apr 18, 2024
… 1168817

https://build.opensuse.org/request/show/1168817
by user yan_gao + anag+factory
- Update to version 2.1.7+20240411.81041cf0b:
- libcrmcommon: Avoid use-after-free in mark_xml_changes()
- libcrmcommon: Mark parents dirty in pcmk__mark_xml_created()

- Update to version 2.1.7+20240410.ae4b38ab5:
- scheduler: deprecate Nagios and Upstart resources even if built with --enable-compat-2.0 (gh#ClusterLabs/pacemaker#3417)

- Update to version 2.1.7+20240410.74b7a09c5:
- tools: New crm_resource --list-options=primitive option (gh#ClusterLabs/pacemaker#3399)
- libcrmcommon: Use PCMK_VALUE_VERSION as option type (gh#ClusterLabs/pacemaker#3399)
- libcrmcommon: Use PCMK_VALUE_TIMEOUT as option type (gh#ClusterLabs/pacemaker#3399)
- libcrmcommon: Use PCMK_VALUE_SCORE as option type (gh#ClusterLabs/pacemaker#3399)
- libcrmcommon: Use PCMK_VALUE_NONNEGATIVE_INTEGER as opt type (gh#Clu
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.

2 participants