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

Best practices for a few scheduler functions #3779

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

kgaillot
Copy link
Contributor

No description provided.

…_time()

Move from libpe_status to libcrmcommon, rename to
pcmk__scheduler_epoch_time(), add a doxygen block, and improve log
messages and formatting.
We currently have pe_reset_working_data(), cleanup_calculations(), and
set_working_set_defaults() for partially freeing and restoring defaults
in scheduler data.

The distinction is confusing, and this is the first step to
rationalizing it: the new function sets nonzero default values in
scheduler data, without freeing or nulling/zeroing anything, so it can
be used in both existing and replacement functions.
... from libpe_status to libcrmcommon. Also rename with a pcmk prefix,
add doxygen blocks, and improve variable names.

There are no unit tests because the relevant struct is
source-file-scoped, and the APIs aren't complex enough to make it worth
exposing.
... as a convenience wrapper around the resource free() method, suitable
for use as a GList free function.
... in libpe_status with a new pcmk__free_node() in libcrmcommon that
can be used as a GList iterator.
... in libpe_status with a new pcmk__free_action_relation() in
libcrmcommon that can be used as a GList iterator
... in libpe_status with a new pcmk__free_location() in
libcrmcommon that can be used as a GList iterator
... in libpe_status with a new pcmk__free_action() in
libcrmcommon that can be used as a GList iterator
This is the equivalent of pe_reset_working_set(), except for freeing and
zeroing members individually rather than zeroing the whole object.
It is fully equivalent to pcmk_reset_scheduler()
cleanup_calculations() is equivalent to pcmk_reset_scheduler() except
for not freeing ordering, location, or colocation constraints. However
it logged an assertion if location or ordering constraints were
non-NULL, and it called set_working_set_defaults() which would NULL the
constraint members without freeing them.

Therefore we can simply replace calls with pcmk_reset_scheduler().
There's no reason to ever zero constraints without freeing them.
The function zeroed out the scheduler object without freeing members,
which makes no sense, so simply replace calls with
pcmk_reset_scheduler(), which does a free-and-zero.
... and use it internally instead of pe_new_working_set()
... and use it internally instead of pe_free_working_set()
... as pcmk__update_recheck_time(). The only code changes are the name
and checking for NULL arguments.
@kgaillot
Copy link
Contributor Author

@nrwahl2 , here's my last best practices PR for review when you get a chance

@nrwahl2
Copy link
Contributor

nrwahl2 commented Dec 23, 2024

:'(

#if PCMK__CONCURRENT_FENCING_DEFAULT_TRUE
pcmk__set_scheduler_flags(scheduler,
pcmk__sched_symmetric_cluster
|pcmk__sched_concurrent_fencing
Copy link
Contributor

Choose a reason for hiding this comment

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

could just guard this one line, unless you think this is more readable

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