diff --git a/daemons/pacemakerd/pacemakerd.c b/daemons/pacemakerd/pacemakerd.c index ac308e7..0f459c0 100644 --- a/daemons/pacemakerd/pacemakerd.c +++ b/daemons/pacemakerd/pacemakerd.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -344,7 +345,7 @@ start_child(pcmk_child_t * child) // Drop root group access if not needed if (!need_root_group && (setgid(gid) < 0)) { - crm_perror(LOG_ERR, "Could not set group to %d", gid); + crm_warn("Could not set group to %d: %s", gid, strerror(errno)); } /* Initialize supplementary groups to only those always granted to @@ -356,7 +357,8 @@ start_child(pcmk_child_t * child) } if (uid && setuid(uid) < 0) { - crm_perror(LOG_ERR, "Could not set user to %d (%s)", uid, child->uid); + crm_warn("Could not set user to %s (id %d): %s", + child->uid, uid, strerror(errno)); } pcmk__close_fds_in_child(true); @@ -370,7 +372,7 @@ start_child(pcmk_child_t * child) } else { (void)execvp(child->command, opts_default); } - crm_perror(LOG_ERR, "FATAL: Cannot exec %s", child->command); + crm_crit("Could not execute %s: %s", child->command, strerror(errno)); crm_exit(CRM_EX_FATAL); } return TRUE; /* never reached */ @@ -527,8 +529,7 @@ pcmk_ipc_dispatch(qb_ipcs_connection_t * qbc, void *data, size_t size) task = crm_element_value(msg, F_CRM_TASK); if (crm_str_eq(task, CRM_OP_QUIT, TRUE)) { - /* Time to quit */ - crm_notice("Shutting down in response to ticket %s (%s)", + crm_notice("Shutting down in response to IPC request %s from %s", crm_element_value(msg, F_CRM_REFERENCE), crm_element_value(msg, F_CRM_ORIGIN)); pcmk_shutdown(15); @@ -982,7 +983,8 @@ remove_core_file_limit(void) int rc = getrlimit(RLIMIT_CORE, &cores); if (rc < 0) { - crm_perror(LOG_ERR, "Cannot determine current maximum core size."); + crm_warn("Cannot determine current maximum core file size: %s", + strerror(errno)); return; } @@ -996,10 +998,8 @@ remove_core_file_limit(void) rc = setrlimit(RLIMIT_CORE, &cores); if (rc < 0) { - crm_perror(LOG_ERR, - "Core file generation will remain disabled." - " Core files are an important diagnostic tool, so" - " please consider enabling them by default."); + crm_warn("Cannot raise system limit on core file size " + "(consider doing so manually)"); } } @@ -1108,7 +1108,6 @@ main(int argc, char **argv) crm_ipc_destroy(old_instance); if (mcp_read_config() == FALSE) { - crm_notice("Could not obtain corosync config data, exiting"); crm_exit(CRM_EX_UNAVAILABLE); } @@ -1169,7 +1168,6 @@ main(int argc, char **argv) /* Allows us to block shutdown */ if (!cluster_connect_cfg()) { - crm_err("Couldn't connect to Corosync's CFG service"); crm_exit(CRM_EX_PROTOCOL); } diff --git a/daemons/pacemakerd/pcmkd_corosync.c b/daemons/pacemakerd/pcmkd_corosync.c index 156f965..6f19803 100644 --- a/daemons/pacemakerd/pcmkd_corosync.c +++ b/daemons/pacemakerd/pcmkd_corosync.c @@ -28,7 +28,6 @@ #include /* PCMK__SPECIAL_PID* */ -enum cluster_type_e stack = pcmk_cluster_unknown; static corosync_cfg_handle_t cfg_handle; /* =::=::=::= CFG - Shutdown stuff =::=::=::= */ @@ -63,9 +62,8 @@ pcmk_cfg_dispatch(gpointer user_data) static void cfg_connection_destroy(gpointer user_data) { - crm_err("Connection destroyed"); + crm_err("Lost connection to Corosync"); cfg_handle = 0; - pcmk_shutdown(SIGTERM); } @@ -85,7 +83,7 @@ cluster_disconnect_cfg(void) code; \ if(rc == CS_ERR_TRY_AGAIN || rc == CS_ERR_QUEUE_FULL) { \ counter++; \ - crm_debug("Retrying operation after %ds", counter); \ + crm_debug("Retrying Corosync operation after %ds", counter); \ sleep(counter); \ } else { \ break; \ @@ -110,41 +108,42 @@ cluster_connect_cfg(void) cs_repeat(retries, 30, rc = corosync_cfg_initialize(&cfg_handle, &cfg_callbacks)); if (rc != CS_OK) { - crm_err("corosync cfg init: %s (%d)", cs_strerror(rc), rc); + crm_crit("Could not connect to Corosync CFG: %s " CRM_XS " rc=%d", + cs_strerror(rc), rc); return FALSE; } rc = corosync_cfg_fd_get(cfg_handle, &fd); if (rc != CS_OK) { - crm_err("corosync cfg fd_get: %s (%d)", cs_strerror(rc), rc); + crm_crit("Could not get Corosync CFG descriptor: %s " CRM_XS " rc=%d", + cs_strerror(rc), rc); goto bail; } /* CFG provider run as root (in given user namespace, anyway)? */ if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid, &found_uid, &found_gid))) { - crm_err("CFG provider is not authentic:" - " process %lld (uid: %lld, gid: %lld)", - (long long) PCMK__SPECIAL_PID_AS_0(found_pid), - (long long) found_uid, (long long) found_gid); + crm_crit("Rejecting Corosync CFG provider because process %lld " + "is running as uid %lld gid %lld, not root", + (long long) PCMK__SPECIAL_PID_AS_0(found_pid), + (long long) found_uid, (long long) found_gid); goto bail; } else if (rv < 0) { - crm_err("Could not verify authenticity of CFG provider: %s (%d)", - strerror(-rv), -rv); + crm_crit("Could not authenticate Corosync CFG provider: %s " + CRM_XS " rc=%d", strerror(-rv), -rv); goto bail; } retries = 0; cs_repeat(retries, 30, rc = corosync_cfg_local_get(cfg_handle, &nodeid)); - if (rc != CS_OK) { - crm_err("corosync cfg local_get error %d", rc); + crm_crit("Could not get local node ID from Corosync: %s " + CRM_XS " rc=%d", cs_strerror(rc), rc); goto bail; } + crm_debug("Corosync reports local node ID is %lu", (unsigned long) nodeid); - crm_debug("Our nodeid: %lu", (unsigned long) nodeid); mainloop_add_fd("corosync-cfg", G_PRIORITY_DEFAULT, fd, &cfg_handle, &cfg_fd_callbacks); - return TRUE; bail: @@ -184,14 +183,15 @@ mcp_read_config(void) gid_t found_gid = 0; pid_t found_pid = 0; int rv; + enum cluster_type_e stack; // There can be only one possibility do { rc = cmap_initialize(&local_handle); if (rc != CS_OK) { retries++; - printf("cmap connection setup failed: %s. Retrying in %ds\n", cs_strerror(rc), retries); - crm_info("cmap connection setup failed: %s. Retrying in %ds", cs_strerror(rc), retries); + crm_info("Could not connect to Corosync CMAP: %s (retrying in %ds) " + CRM_XS " rc=%d", cs_strerror(rc), retries, rc); sleep(retries); } else { @@ -201,15 +201,15 @@ mcp_read_config(void) } while (retries < 5); if (rc != CS_OK) { - printf("Could not connect to Cluster Configuration Database API, error %d\n", rc); - crm_warn("Could not connect to Cluster Configuration Database API, error %d", rc); + crm_crit("Could not connect to Corosync CMAP: %s " + CRM_XS " rc=%d", cs_strerror(rc), rc); return FALSE; } rc = cmap_fd_get(local_handle, &fd); if (rc != CS_OK) { - crm_err("Could not obtain the CMAP API connection: %s (%d)", - cs_strerror(rc), rc); + crm_crit("Could not get Corosync CMAP descriptor: %s " CRM_XS " rc=%d", + cs_strerror(rc), rc); cmap_finalize(local_handle); return FALSE; } @@ -217,38 +217,33 @@ mcp_read_config(void) /* CMAP provider run as root (in given user namespace, anyway)? */ if (!(rv = crm_ipc_is_authentic_process(fd, (uid_t) 0,(gid_t) 0, &found_pid, &found_uid, &found_gid))) { - crm_err("CMAP provider is not authentic:" - " process %lld (uid: %lld, gid: %lld)", - (long long) PCMK__SPECIAL_PID_AS_0(found_pid), - (long long) found_uid, (long long) found_gid); + crm_crit("Rejecting Corosync CMAP provider because process %lld " + "is running as uid %lld gid %lld, not root", + (long long) PCMK__SPECIAL_PID_AS_0(found_pid), + (long long) found_uid, (long long) found_gid); cmap_finalize(local_handle); return FALSE; } else if (rv < 0) { - crm_err("Could not verify authenticity of CMAP provider: %s (%d)", - strerror(-rv), -rv); + crm_crit("Could not authenticate Corosync CMAP provider: %s " + CRM_XS " rc=%d", strerror(-rv), -rv); cmap_finalize(local_handle); return FALSE; } stack = get_cluster_type(); - crm_info("Reading configure for stack: %s", name_for_cluster_type(stack)); - - /* =::=::= Should we be here =::=::= */ - if (stack == pcmk_cluster_corosync) { - pcmk__set_env_option("cluster_type", "corosync"); - pcmk__set_env_option("quorum_type", "corosync"); - - } else { - crm_err("Unsupported stack type: %s", name_for_cluster_type(stack)); + if (stack != pcmk_cluster_corosync) { + crm_crit("Expected corosync stack but detected %s " CRM_XS " stack=%d", + name_for_cluster_type(stack), stack); return FALSE; } - /* =::=::= Logging =::=::= */ - if (pcmk__env_option("debug")) { - /* Syslog logging is already setup by crm_log_init() */ + crm_info("Reading configuration for %s stack", + name_for_cluster_type(stack)); + pcmk__set_env_option("cluster_type", "corosync"); + pcmk__set_env_option("quorum_type", "corosync"); - } else { - /* Check corosync */ + // If debug logging is not configured, check whether corosync has it + if (pcmk__env_option("debug") == NULL) { char *debug_enabled = NULL; get_config_opt(config, local_handle, "logging.debug", &debug_enabled, "off"); @@ -269,7 +264,7 @@ mcp_read_config(void) if(local_handle){ gid_t gid = 0; if (pcmk_daemon_user(NULL, &gid) < 0) { - crm_warn("Could not authorize group with corosync " CRM_XS + crm_warn("Could not authorize group with Corosync " CRM_XS " No group found for user %s", CRM_DAEMON_USER); } else { @@ -277,8 +272,8 @@ mcp_read_config(void) snprintf(key, PATH_MAX, "uidgid.gid.%u", gid); rc = cmap_set_uint8(local_handle, key, 1); if (rc != CS_OK) { - crm_warn("Could not authorize group with corosync "CRM_XS - " group=%u rc=%d (%s)", gid, rc, ais_error2text(rc)); + crm_warn("Could not authorize group with Corosync: %s " CRM_XS + " group=%u rc=%d", ais_error2text(rc), gid, rc); } } }