-
Notifications
You must be signed in to change notification settings - Fork 349
Refactor: controller: Drop some unused symbols and start some best practices #3979
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
base: main
Are you sure you want to change the base?
Conversation
b644bc3 to
e2701e0
Compare
|
At this point, having added more commits, we'll want to do a cts-lab run. We can break the PR into pieces, however. |
Why don't you break all the "Drop..." commits out into their own PR first. |
08958c2 to
5dd0678
Compare
|
Updated to tackle all the |
* Make function static. * Use uint8_t for log_type. * Assert pointer is non-NULL before dereferencing. * Use pcmk__is_set(). Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
No code changes aside from moving functions around. Signed-off-by: Reid Wahl <[email protected]>
...and scheduler IPC handlers. Signed-off-by: Reid Wahl <[email protected]>
This one is slightly more complex than other recent ones. * Use pcmk__is_set() instead of bitwise-and. * Drop some elses after early returns. * Drop a redundant "action & A_TE_START" check before checking cur_state. We would have returned already if that flag were not set. * Wait to register the TE UUID until after checking error conditions; register it only if our TE start is a success. * Drop the init_ok variable and use early returns instead. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
And add a FIXME comment about some confusing, likely incorrect behavior. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
For convenience Signed-off-by: Reid Wahl <[email protected]>
All callers pass NULL. Signed-off-by: Reid Wahl <[email protected]>
The user_name argument was already ignored. Signed-off-by: Reid Wahl <[email protected]>
* Give update_dc_expected() a name that is clearer, albeit longer. * Declare static variable first_join first, within the narrowest scope possible. * Use bool/true/false instead of gboolean/TRUE/FALSE. * Drop was_nack variable. * Rename tmp1 variable to more meaningful "state". * Handle NULL variables with pcmk__s(). * Create join_confirm immediately before setting its join id attribute. * Declare start_state variable within the narrowest scope possible. * Compare pointers explicitly against NULL. * !AM_I_DC instead of AM_I_DC == FALSE. * Use register_fsa_input_before(). Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
No code changes. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Note that the "or wanting to shut down" comment was made obsolete by commit 0e4db7b in 2006. Signed-off-by: Reid Wahl <[email protected]>
Surprisingly, this seems to have never been set, even though it's been checked and cleared since at least 2004. Even as of 12c39ec, which added a new check for R_STARTING, nothing was setting it. This allows a couple of functions to be simplified. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
I think this is all we can do before functionizing pieces of do_dc_join_filter_offer(). This adds some parentheses, uses bool instaed of gboolean, avoids comparing against FALSE, moves some assignments to just before the variable is used, reorders declarations in accordance with the order of use, renames ack_nack_bool to accept, etc. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Also touch do_cl_join_announce() since nothing needs to change within the body. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
And remove some nesting. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Previously, we relied on a msg_data variable being declared. I found this very non-intuitive. We often created such a variable just as a dummy so that the macro would work. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
5dd0678 to
73678b7
Compare
| } else if (pcmk__is_set(controld_globals.fsa_input_register, | ||
| R_TE_CONNECTED)) { | ||
| } | ||
| if (pcmk__is_set(controld_globals.fsa_input_register, R_TE_CONNECTED)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Picky, but I'd like to see spaces between all these if blocks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I normally do too. This is kind of my one exception: related if {... early return; } if {... early return; } blocks. I feel like the braces add enough space for good readability as long as there aren't comments.
Either way, I'm not picky about it and don't mind adding the lines.
| crm_debug("Registering Signal Handlers"); | ||
| mainloop_add_signal(SIGTERM, crm_shutdown); | ||
| mainloop_add_signal(SIGPIPE, sigpipe_ignore); | ||
| mainloop_add_signal(SIGPIPE, NULL); // Ignore SIGPIPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also modify the doxygen on mainloop_add_signal to reference that the dispatch param can be NULL.
|
|
||
| if (!pcmk__str_eq(op, CRM_OP_JOIN_ACKNAK, pcmk__str_casei)) { | ||
| crm_trace("Ignoring op=%s message", op); | ||
| if (!pcmk__str_eq(op, CRM_OP_JOIN_ACKNAK, pcmk__str_none)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how consistent we are with this:
clumens@spire ~/src/pacemaker main|…❯ k CRM_OP_ | grep pcmk__str_eq | grep -c pcmk__str_casei
11
clumens@spire ~/src/pacemaker main|…❯ k CRM_OP_ | grep pcmk__str_eq | grep -c pcmk__str_none
14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think when we moved from safe_str_eq(), we used pcmk__str_casei for safety (since there were so ungodly many changes, and we haven't updated them all yet.
| return; | ||
| } | ||
|
|
||
| if (!AM_I_DC && controld_is_local_node(welcome_from)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to see the spaces preserved on these blocks too.
| register_fsa_error(I_ERROR); | ||
| return; | ||
| } | ||
| if (controld_globals.dc_name == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise with blank lines here too.
| { | ||
| crm_debug("Ensuring DC, quorum and node attributes are up-to-date"); | ||
| crm_update_quorum(pcmk__cluster_has_quorum(), TRUE); | ||
| crm_debug("Ensuring DC, quorum, and node attributes are up to date"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long live the oxford comma.
| return 1; | ||
| } | ||
|
|
||
| return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in the commit message - "instaed" instead of "instead". Heh.
|
|
||
| } else { // Should always be PCMK__XE_GENERATION_TUPLE | ||
| CRM_LOG_ASSERT(false); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be inverted:
if (!pcmk__xe_is(generation, PCMK__XE_GENERATION_TUPLE)) {
CRM_LOG_ASSERT(false);
}
for (int i = ...) {
}
| pcmk__plural_s(count_welcomed)); | ||
| crmd_join_phase_log(LOG_DEBUG); | ||
| /* crmd_fsa_stall(FALSE); Needed? */ | ||
| // crmd_fsa_stall(false); Needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been commented out since its introduction in 0b84e7e. Again, it apparently hasn't caused any problems that we know of, so I don't think we need to keep it around.
| crm_notice("Not invoking the TE because we are not the DC"); | ||
| return; | ||
| } | ||
| if (pcmk__is_set(action, A_TE_INVOKE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likewise with blank lines in this function.
My short-term goal (not done yet) is to get rid of
ha_msg_input_tand move its two members directly intofsa_data_t. This will require some more fiddling withregister_fsa_error{,_adv},register_fsa_input{,_adv}, and related functions/macros. That's the main reason that I started working on best practices for thedo_X()functions at the end of this PR. I want to make it easier to reason about all thismsg_datanonsense.(For context, some of the controller's macros require a variable named
msg_datato exist, even if it's aNULLdummy variable.)