Skip to content

Commit

Permalink
API: libcrmcommon: drop crm_config_error global variable
Browse files Browse the repository at this point in the history
Make internal, rename to pcmk__config_has_error, and type as bool instead of
gboolean.
  • Loading branch information
kgaillot committed Jul 29, 2024
1 parent 81f9ddc commit a266f6f
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion daemons/schedulerd/schedulerd_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ handle_pecalc_request(pcmk__request_t *request)

// Get appropriate index into series[] array
if (pcmk_is_set(scheduler->flags, pcmk__sched_processing_error)
|| crm_config_error) {
|| pcmk__config_has_error) {
series_id = 0;
} else if (pcmk_is_set(scheduler->flags, pcmk__sched_processing_warning)
|| crm_config_warning) {
Expand Down
7 changes: 0 additions & 7 deletions include/crm/common/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@ extern unsigned int crm_log_level;
//! \deprecated Do not use
extern unsigned int crm_trace_nonlog;

/*! \deprecated Pacemaker library functions set this when a configuration
* error is found, which turns on extra messages at the end of
* processing. It should not be used directly and will be removed
* from the public C API in a future release.
*/
extern gboolean crm_config_error;

/*! \deprecated Pacemaker library functions set this when a configuration
* warning is found, which turns on extra messages at the end of
* processing. It should not be used directly and will be removed
Expand Down
7 changes: 6 additions & 1 deletion include/crm/common/logging_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,19 @@ extern void *pcmk__config_warning_context;
void pcmk__set_config_error_handler(pcmk__config_error_func error_handler, void *error_context);
void pcmk__set_config_warning_handler(pcmk__config_warning_func warning_handler, void *warning_context);

/* Pacemaker library functions set this when a configuration error is found,
* which turns on extra messages at the end of processing.
*/
extern bool pcmk__config_has_error;

/*!
* \internal
* \brief Log an error and make crm_verify return failure status
*
* \param[in] fmt... printf(3)-style format string and arguments
*/
#define pcmk__config_err(fmt...) do { \
crm_config_error = TRUE; \
pcmk__config_has_error = true; \
if (pcmk__config_error_handler == NULL) { \
crm_err(fmt); \
} else { \
Expand Down
2 changes: 1 addition & 1 deletion lib/common/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

CRM_TRACE_INIT_DATA(common);

gboolean crm_config_error = FALSE;
bool pcmk__config_has_error = false;
gboolean crm_config_warning = FALSE;
char *crm_system_name = NULL;

Expand Down
4 changes: 2 additions & 2 deletions lib/pacemaker/pcmk_graph_producer.c
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ pcmk__log_transition_summary(const pcmk_scheduler_t *scheduler,
const char *filename)
{
if (pcmk_is_set(scheduler->flags, pcmk__sched_processing_error)
|| crm_config_error) {
|| pcmk__config_has_error) {
crm_err("Calculated transition %d (with errors)%s%s",
transition_id,
(filename == NULL)? "" : ", saving inputs in ",
Expand All @@ -973,7 +973,7 @@ pcmk__log_transition_summary(const pcmk_scheduler_t *scheduler,
(filename == NULL)? "" : ", saving inputs in ",
(filename == NULL)? "" : filename);
}
if (crm_config_error) {
if (pcmk__config_has_error) {
crm_notice("Configuration errors found during scheduler processing,"
" please run \"crm_verify -L\" to identify issues");
}
Expand Down
9 changes: 5 additions & 4 deletions lib/pacemaker/pcmk_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,22 @@ pcmk__verify(pcmk_scheduler_t *scheduler, pcmk__output_t *out,

if (!pcmk__validate_xml(*cib_object, NULL,
(xmlRelaxNGValidityErrorFunc) out->err, out)) {
crm_config_error = TRUE;
pcmk__config_has_error = true;
rc = pcmk_rc_schema_validation;
goto verify_done;
}

rc = pcmk_update_configured_schema(cib_object, false);
if (rc != pcmk_rc_ok) {
crm_config_error = TRUE;
pcmk__config_has_error = true;
out->err(out, "The cluster will NOT be able to use this configuration.\n"
"Please manually update the configuration to conform to the %s syntax.",
pcmk__highest_schema_name());
goto verify_done;
}

/* Process the configuration to set crm_config_error/crm_config_warning.
/* Process the configuration to set pcmk__config_has_error and
* crm_config_warning.
*
* @TODO Some parts of the configuration are unpacked only when needed (for
* example, action configuration), so we aren't necessarily checking those.
Expand All @@ -106,7 +107,7 @@ pcmk__verify(pcmk_scheduler_t *scheduler, pcmk__output_t *out,
}

verify_done:
if (crm_config_error) {
if (pcmk__config_has_error) {
rc = pcmk_rc_schema_validation;
pcmk__config_err("CIB did not pass schema validation");
} else if (crm_config_warning) {
Expand Down
2 changes: 1 addition & 1 deletion tools/crm_verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ main(int argc, char **argv)
rc = pcmk__verify(scheduler, out, &cib_object);

if (rc == pcmk_rc_schema_validation) {
if (crm_config_error) {
if (pcmk__config_has_error) {
failure_type = "Errors found during check: ";
} else if (crm_config_warning) {
failure_type = "Warnings found during check: ";
Expand Down

0 comments on commit a266f6f

Please sign in to comment.