cluster: STABLE3 - cman: Deprecate specifying config version to cman_tool

Lon Hohberger lon at fedoraproject.org
Thu Jul 22 18:52:54 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=84f906bf8ea3d3a5ae44e1ae8cbf6919672a6e62
Commit:        84f906bf8ea3d3a5ae44e1ae8cbf6919672a6e62
Parent:        668d3c667349e93f1e52e0a2be5e22385b9a1b76
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Thu Jul 22 14:44:17 2010 -0400
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Thu Jul 22 14:44:17 2010 -0400

cman: Deprecate specifying config version to cman_tool

Historically, updating the configuration file required
two discrete steps:

  1) send configuration to all nodes, and

  2) tell CMAN about the new configuration version

There has always been a possibility that an incorrect
version number could be sent to CMAN, causing it to have
a different version than the one in cluster.conf.

In the STABLE3 and later branches as of commit 75fb0324,
the necessity for specifying the version # has been
removed; users could instead just use '-r 0' to use the
configuration version in the current cluster.conf.

This patch deprecates specification of the configuration
version number from the cman_tool command line while
attempting to retain command-line tool compatibility.
That is, you may specify '-r123', but it will be ignored
and a warning will be printed.

Resolves: rhbz#617163

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 cman/cman_tool/main.c |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
index d8b08dd..a731323 100644
--- a/cman/cman_tool/main.c
+++ b/cman/cman_tool/main.c
@@ -10,7 +10,7 @@
 
 #define DEFAULT_CONFIG_MODULE "xmlconfig"
 
-#define OPTION_STRING		("m:n:v:e:2p:c:r:i:N:t:o:k:F:C:VAPwfqah?XD::Sd::")
+#define OPTION_STRING		("m:n:v:e:2p:c:i:N:t:o:k:F:C:VAPwfqah?XD::Sd::r::")
 #define OP_JOIN			1
 #define OP_LEAVE		2
 #define OP_EXPECTED		3
@@ -118,7 +118,7 @@ static void print_usage(int subcmd)
 
 	if (!subcmd || subcmd == OP_VERSION) {
 		printf("version\n");
-		printf("  -r <config>      A new config version to set on all members\n");
+		printf("  -r               Reload cluster.conf and update config version.\n");
 		printf("  -D <fail,warn,none> What to do about the config. Default (without -D) is to\n");
 		printf("                   validate the config. with -D no validation will be done. -Dwarn will print errors\n");
 		printf("                   but allow the operation to continue\n");
@@ -876,6 +876,7 @@ static void decode_arguments(int argc, char *argv[], commandline_t *comline)
 	int optchar, i;
 	int suboptchar;
 	int show_help = 0;
+	char buf[16];
 
 	while (cont) {
 		optchar = getopt(argc, argv, OPTION_STRING);
@@ -943,8 +944,13 @@ static void decode_arguments(int argc, char *argv[], commandline_t *comline)
 			break;
 
 		case 'r':
-			comline->config_version = get_int_arg(optchar, optarg);
+			comline->config_version = 0;
 			comline->config_version_opt = TRUE;
+			if (optarg) {
+				fprintf(stderr, "Warning: specifying a "
+					"version for the -r flag is "
+				        "deprecated and no longer used\n");
+			}
 			break;
 
 		case 'v':
@@ -1092,8 +1098,19 @@ static void decode_arguments(int argc, char *argv[], commandline_t *comline)
 			comline->remove = TRUE;
 		} else if (strcmp(argv[optind], "force") == 0) {
 			comline->force = TRUE;
-		} else
-			die("unknown option %s", argv[optind]);
+		} else {
+			snprintf(buf, sizeof(buf),
+				 "%d", atoi(argv[optind]));
+			if (!strcmp(buf, argv[optind]) &&
+			    (comline->config_version_opt == TRUE) &&
+			     comline->operation == OP_VERSION) {
+				fprintf(stderr, "Warning: specifying a "
+					"version for the -r flag is "
+				        "deprecated and no longer used\n");
+			} else {
+				die("unknown option %s", argv[optind]);
+			}
+		}
 
 		optind++;
 	}


More information about the cluster-commits mailing list