cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Lon Hohberger <lhh@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] rgmanager: Add 'disabled' configuration option [RHEL6]
Date: Mon,  1 Aug 2011 16:39:51 -0400	[thread overview]
Message-ID: <1312231192-24939-1-git-send-email-lhh@redhat.com> (raw)

The option turns off rgmanager, which will shut down if
running and cause rgmanager to refuse to start if
starting up.

Resolves: rhbz#723925

Signed-off-by: Lon Hohberger <lhh@redhat.com>
---
 rgmanager/src/daemons/main.c |   51 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 50 insertions(+), 1 deletions(-)

diff --git a/rgmanager/src/daemons/main.c b/rgmanager/src/daemons/main.c
index 46ddf18..4e12c68 100644
--- a/rgmanager/src/daemons/main.c
+++ b/rgmanager/src/daemons/main.c
@@ -749,6 +749,14 @@ event_loop(msgctx_t *localctx, msgctx_t *clusterctx)
 	if (need_reconfigure) {
 		need_reconfigure = 0;
 		configure_rgmanager(-1, 0, NULL);
+
+		/*
+		 * A shutdown during reconfiguration would slow down
+		 * the exit request, so it's pointless to run the
+		 * deltas at this point
+		 */
+		if (shutdown_pending)
+			return 0;
 		config_event_q();
 		return 0;
 	}
@@ -782,7 +790,6 @@ cleanup(msgctx_t *clusterctx)
 }
 
 
-
 static void
 statedump(int __attribute__ ((unused)) sig)
 {
@@ -790,6 +797,36 @@ statedump(int __attribute__ ((unused)) sig)
 }
 
 
+static int
+rgmanager_disabled(int ccsfd)
+{
+	char *v;
+	int disabled = 0;
+	int internal;
+
+	if (ccsfd < 0) {
+		internal = 1;
+		ccsfd = ccs_force_connect(NULL, 0);
+		if (ccsfd < 0)
+			return -1;
+	}
+
+	if (ccs_get(ccsfd, "/cluster/rm/@disabled", &v) == 0) {
+		if (atoi(v) == 1) {
+			disabled = 1;
+			shutdown_pending = 1;
+			logt_print(LOG_NOTICE, "Resource Group Manager Disabled\n");
+		}
+		free(v);
+	}
+
+	if (internal)
+		ccs_disconnect(ccsfd);
+
+	return disabled;
+}
+
+
 /*
  * Configure logging based on data in cluster.conf
  */
@@ -810,6 +847,8 @@ configure_rgmanager(int ccsfd, int dbg, int *token_secs)
 
 	setup_logging(ccsfd);
 
+	rgmanager_disabled(ccsfd);
+
 	if (token_secs && ccs_get(ccsfd, "/cluster/totem/@token", &v) == 0) {
 		tmp = atoi(v);
 		if (tmp >= 1000) {
@@ -982,6 +1021,13 @@ main(int argc, char **argv)
 		debug = 1;
 	}
 
+	/* If we're disabled in the configuration, don't fork */
+	if (rgmanager_disabled(-1) > 0) {
+		fprintf(stderr,
+			"rgmanager disabled in configuration; not starting\n");
+		return 2;
+	}
+
 	if (!foreground && (geteuid() == 0)) {
 		daemon_init(argv[0]);
 		if (wd && !debug && !watchdog_init())
@@ -1040,6 +1086,9 @@ main(int argc, char **argv)
 	 */
 	xmlInitParser();
 	configure_rgmanager(-1, debug, &cluster_timeout);
+	if (shutdown_pending == 1)
+		goto out_ls;
+
 	logt_print(LOG_NOTICE, "Resource Group Manager Starting\n");
 
 	if (rgm_dbus_notify && rgm_dbus_init() != 0) {
-- 
1.7.3.4



             reply	other threads:[~2011-08-01 20:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-01 20:39 Lon Hohberger [this message]
2011-08-01 20:39 ` [Cluster-devel] [PATCH] config: Add 'disabled' flag to rm element [RHEL6] Lon Hohberger
2011-08-02  6:57 ` [Cluster-devel] [PATCH] rgmanager: Add 'disabled' configuration option [RHEL6] Fabio M. Di Nitto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1312231192-24939-1-git-send-email-lhh@redhat.com \
    --to=lhh@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).