Skip to content

Commit

Permalink
API: libcrmcommon: Add PCMK_SCHEDULER_INPUT_DIR defined constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
clumens committed Aug 20, 2024
1 parent 649e3f0 commit 3031286
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 29 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -815,10 +815,10 @@ AC_DEFINE_UNQUOTED([CRM_BLACKBOX_DIR], ["$CRM_BLACKBOX_DIR"],
[Where to keep blackbox dumps])
AC_SUBST(CRM_BLACKBOX_DIR)

PE_STATE_DIR="${localstatedir}/lib/pacemaker/pengine"
AC_DEFINE_UNQUOTED([PE_STATE_DIR], ["$PE_STATE_DIR"],
PCMK_SCHEDULER_INPUT_DIR="${localstatedir}/lib/pacemaker/pengine"
AC_DEFINE_UNQUOTED([PCMK_SCHEDULER_INPUT_DIR], ["$PCMK_SCHEDULER_INPUT_DIR"],
[Where to keep scheduler outputs])
AC_SUBST(PE_STATE_DIR)
AC_SUBST(PCMK_SCHEDULER_INPUT_DIR)

CRM_CONFIG_DIR="${localstatedir}/lib/pacemaker/cib"
AC_DEFINE_UNQUOTED([CRM_CONFIG_DIR], ["$CRM_CONFIG_DIR"],
Expand Down
4 changes: 2 additions & 2 deletions daemons/controld/controld_schedulerd.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ save_cib_contents(xmlNode *msg, int call_id, int rc, xmlNode *output,
CRM_CHECK(id != NULL, return);

if (rc == pcmk_ok) {
char *filename = crm_strdup_printf(PE_STATE_DIR "/pe-core-%s.bz2", id);
char *filename = crm_strdup_printf(PCMK_SCHEDULER_INPUT_DIR "/pe-core-%s.bz2", id);

if (pcmk__xml_write_file(output, filename, true) != pcmk_rc_ok) {
crm_err("Could not save Cluster Information Base to %s after scheduler crash",
Expand Down Expand Up @@ -90,7 +90,7 @@ handle_disconnect(void)
char *uuid_str = crm_generate_uuid();

crm_crit("Lost connection to the scheduler "
QB_XS " CIB will be saved to " PE_STATE_DIR "/pe-core-%s.bz2",
QB_XS " CIB will be saved to " PCMK_SCHEDULER_INPUT_DIR "/pe-core-%s.bz2",
uuid_str);

/*
Expand Down
6 changes: 3 additions & 3 deletions daemons/controld/pacemaker-controld.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ main(int argc, char **argv)
old_instance = NULL;
}

if (pcmk__daemon_can_write(PE_STATE_DIR, NULL) == FALSE) {
if (pcmk__daemon_can_write(PCMK_SCHEDULER_INPUT_DIR, NULL) == FALSE) {
exit_code = CRM_EX_FATAL;
crm_err("Terminating due to bad permissions on " PE_STATE_DIR);
crm_err("Terminating due to bad permissions on " PCMK_SCHEDULER_INPUT_DIR);
g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
"Bad permissions on " PE_STATE_DIR
"Bad permissions on " PCMK_SCHEDULER_INPUT_DIR
" (see logs for details)");
goto done;

Expand Down
2 changes: 1 addition & 1 deletion daemons/pacemakerd/pacemakerd.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ create_pcmk_dirs(void)
PCMK__PERSISTENT_DATA_DIR, // core/blackbox/scheduler/CIB files
CRM_CORE_DIR, // core files
CRM_BLACKBOX_DIR, // blackbox dumps
PE_STATE_DIR, // scheduler inputs
PCMK_SCHEDULER_INPUT_DIR, // scheduler inputs
CRM_CONFIG_DIR, // the Cluster Information Base (CIB)
// Don't build PCMK__OCF_TMP_DIR the executor will do it
NULL
Expand Down
6 changes: 3 additions & 3 deletions daemons/schedulerd/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ pacemaker_schedulerd_SOURCES += schedulerd_messages.c

.PHONY: install-exec-local
install-exec-local:
$(INSTALL) -d -m 750 $(DESTDIR)/$(PE_STATE_DIR)
-chown $(CRM_DAEMON_USER):$(CRM_DAEMON_GROUP) $(DESTDIR)/$(PE_STATE_DIR)
$(INSTALL) -d -m 750 $(DESTDIR)/$(PCMK_SCHEDULER_INPUT_DIR)
-chown $(CRM_DAEMON_USER):$(CRM_DAEMON_GROUP) $(DESTDIR)/$(PCMK_SCHEDULER_INPUT_DIR)

.PHONY: uninstall-local
uninstall-local:
-rmdir $(DESTDIR)/$(PE_STATE_DIR)
-rmdir $(DESTDIR)/$(PCMK_SCHEDULER_INPUT_DIR)

CLEANFILES = $(man7_MANS)
7 changes: 4 additions & 3 deletions daemons/schedulerd/pacemaker-schedulerd.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ main(int argc, char **argv)
crm_log_init(NULL, LOG_INFO, TRUE, FALSE, argc, argv, FALSE);
crm_notice("Starting Pacemaker scheduler");

if (pcmk__daemon_can_write(PE_STATE_DIR, NULL) == FALSE) {
crm_err("Terminating due to bad permissions on " PE_STATE_DIR);
if (pcmk__daemon_can_write(PCMK_SCHEDULER_INPUT_DIR, NULL) == FALSE) {
crm_err("Terminating due to bad permissions on " PCMK_SCHEDULER_INPUT_DIR);
exit_code = CRM_EX_FATAL;
g_set_error(&error, PCMK__EXITC_ERROR, exit_code,
"ERROR: Bad permissions on %s (see logs for details)", PE_STATE_DIR);
"ERROR: Bad permissions on %s (see logs for details)",
PCMK_SCHEDULER_INPUT_DIR);
goto done;
}

Expand Down
6 changes: 3 additions & 3 deletions daemons/schedulerd/schedulerd_messages.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ handle_pecalc_request(pcmk__request_t *request)
series_wrap = series[series_id].wrap;
}

if (pcmk__read_series_sequence(PE_STATE_DIR, series[series_id].name,
if (pcmk__read_series_sequence(PCMK_SCHEDULER_INPUT_DIR, series[series_id].name,
&seq) != pcmk_rc_ok) {
// @TODO maybe handle errors better ...
seq = 0;
Expand All @@ -138,7 +138,7 @@ handle_pecalc_request(pcmk__request_t *request)

} else if (!is_repoke) { // Input changed, save to disk
free(filename);
filename = pcmk__series_filename(PE_STATE_DIR,
filename = pcmk__series_filename(PCMK_SCHEDULER_INPUT_DIR,
series[series_id].name, seq, true);
}

Expand All @@ -157,7 +157,7 @@ handle_pecalc_request(pcmk__request_t *request)
crm_xml_add_ll(xml_data, PCMK_XA_EXECUTION_DATE,
(long long) execution_date);
pcmk__xml_write_file(xml_data, filename, true);
pcmk__write_series_sequence(PE_STATE_DIR, series[series_id].name,
pcmk__write_series_sequence(PCMK_SCHEDULER_INPUT_DIR, series[series_id].name,
++seq, series_wrap);
}

Expand Down
2 changes: 1 addition & 1 deletion include/crm_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#undef CRM_CONFIG_DIR

/* Where to keep scheduler outputs */
#undef PE_STATE_DIR
#undef PCMK_SCHEDULER_INPUT_DIR

// NOTE: sbd (as of at least 1.5.2) uses this
/* Location to store core files produced by Pacemaker daemons */
Expand Down
2 changes: 1 addition & 1 deletion lib/pacemaker-pe_status.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sub=pe_status
libdir=@libdir@
includedir=@includedir@/@PACKAGE_TARNAME@

penginedir=@PE_STATE_DIR@
penginedir=@PCMK_SCHEDULER_INPUT_DIR@

Name: lib${sub}
URL: @PACKAGE_URL@
Expand Down
2 changes: 1 addition & 1 deletion lib/pacemaker.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ features=@PCMK_FEATURES@
# Duplicates from other .pc files, since those may eventually go away
configdir=@CRM_CONFIG_DIR@
schemadir=@PCMK_SCHEMA_DIR@
penginedir=@PE_STATE_DIR@
penginedir=@PCMK_SCHEDULER_INPUT_DIR@
ocfdir=@OCF_RA_INSTALL_DIR@

Name: lib${sub}
Expand Down
12 changes: 6 additions & 6 deletions tools/report.collector.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Originally based on hb_report
# Copyright 2007 Dejan Muhamedagic <[email protected]>
# Later changes copyright 2010-2018 the Pacemaker project contributors
# Later changes copyright 2010-2024 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
Expand Down Expand Up @@ -400,13 +400,13 @@ getbacktraces() {
}

getpeinputs() {
if [ -n "$PE_STATE_DIR" ]; then
if [ -n "$PCMK_SCHEDULER_INPUT_DIR" ]; then
flist=$(
find_files "$PE_STATE_DIR" "$1" "$2" | sed "s,`dirname $PE_STATE_DIR`/,,g"
find_files "$PCMK_SCHEDULER_INPUT_DIR" "$1" "$2" | sed "s,`dirname $PCMK_SCHEDULER_INPUT_DIR`/,,g"
)
if [ "$flist" ]; then
(cd $(dirname "$PE_STATE_DIR") && tar cf - $flist) | (cd "$3" && tar xf -)
debug "found `echo $flist | wc -w` scheduler input files in $PE_STATE_DIR"
(cd $(dirname "$PCMK_SCHEDULER_INPUT_DIR") && tar cf - $flist) | (cd "$3" && tar xf -)
debug "found `echo $flist | wc -w` scheduler input files in $PCMK_SCHEDULER_INPUT_DIR"
fi
fi
}
Expand Down Expand Up @@ -662,7 +662,7 @@ get_logfiles() {

essential_files() {
cat<<EOF
d $PE_STATE_DIR 0750 hacluster haclient
d $PCMK_SCHEDULER_INPUT_DIR 0750 hacluster haclient
d $CRM_CONFIG_DIR 0750 hacluster haclient
d $CRM_STATE_DIR 0750 hacluster haclient
EOF
Expand Down
4 changes: 2 additions & 2 deletions tools/report.common.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Originally based on hb_report
# Copyright 2007 Dejan Muhamedagic <[email protected]>
# Later changes copyright 2010-2022 the Pacemaker project contributors
# Later changes copyright 2010-2024 the Pacemaker project contributors
#
# The version control history for this file may have further details.
#
Expand Down Expand Up @@ -279,7 +279,7 @@ detect_host() {
BLACKBOX_DIR=$config_root/blackbox
debug "Pacemaker blackboxes (if any) located in: $BLACKBOX_DIR"

PE_STATE_DIR=$(detect_pe_dir "$config_root")
PCMK_SCHEDULER_INPUT_DIR=$(detect_pe_dir "$config_root")

CRM_CORE_DIRS=""
for d in $config_root/cores $local_state_dir/lib/corosync; do
Expand Down

0 comments on commit 3031286

Please sign in to comment.