Skip to content

Commit

Permalink
Add the 'nodemgr rejoin' command
Browse files Browse the repository at this point in the history
Can be used to re-merge a peer cluster-wide configuration when the local
node already known the secret.
  • Loading branch information
cvaroqui committed Jun 1, 2018
1 parent 0a00aaa commit f690d80
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 49 deletions.
21 changes: 14 additions & 7 deletions lib/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -4102,7 +4102,14 @@ def daemon_join(self):
raise ex.excError("--secret must be set")
if self.options.node is None:
raise ex.excError("--node must be set")
self._daemon_join(self.options.node, self.options.secret)

def daemon_rejoin(self):
if self.options.node is None:
raise ex.excError("--node must be set")
self._daemon_join(self.options.node, self.cluster_key)

def _daemon_join(self, joined, secret):
# freeze and remember the initial frozen state
initially_frozen = self.frozen()
if not initially_frozen:
Expand All @@ -4115,12 +4122,12 @@ def daemon_join(self):
self.config.add_section("cluster")
data = self.daemon_send(
{"action": "join"},
nodename=self.options.node,
nodename=joined,
cluster_name="join",
secret=self.options.secret,
secret=secret,
)
if data is None:
raise ex.excError("join node %s failed" % self.options.node)
raise ex.excError("join node %s failed" % joined)
data = data.get("data")
if data is None:
raise ex.excError("join failed: no data in response")
Expand Down Expand Up @@ -4149,7 +4156,7 @@ def daemon_join(self):
self.config.set("cluster", "name", cluster_name)
self.config.set("cluster", "id", cluster_id)
self.config.set("cluster", "nodes", " ".join(cluster_nodes))
self.config.set("cluster", "secret", self.options.secret)
self.config.set("cluster", "secret", secret)
if isinstance(dns, list) and len(dns) > 0:
self.config.set("cluster", "dns", " ".join(dns))
if isinstance(cluster_drpnodes, list) and len(cluster_drpnodes) > 0:
Expand Down Expand Up @@ -4222,18 +4229,18 @@ def daemon_join(self):
self.config.remove_section(section)

self.write_config()
self.log.info("join node %s", self.options.node)
self.log.info("join node %s", joined)

# join other nodes
errors = 0
for nodename in cluster_nodes:
if nodename in (rcEnv.nodename, self.options.node):
if nodename in (rcEnv.nodename, joined):
continue
data = self.daemon_send(
{"action": "join"},
nodename=nodename,
cluster_name="join",
secret=self.options.secret,
secret=secret,
)
if data is None:
self.log.error("join node %s failed", nodename)
Expand Down
76 changes: 41 additions & 35 deletions lib/nodemgr_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,50 +569,56 @@
"Node daemon management": {
"daemon_blacklist_status": {
"msg": "Show the content of the daemon senders blacklist.",
},
},
"daemon_blacklist_clear": {
"msg": "Empty the content of the daemon senders blacklist.",
},
},
"daemon_restart": {
"msg": "Restart the daemon.",
},
},
"daemon_running": {
"msg": "Return with code 0 if the daemon is running, else return "
"with code 1",
},
},
"daemon_shutdown": {
"msg": "Stop all local services instances then stop the daemon.",
},
},
"daemon_status": {
"msg": "Display the daemon status.",
"options": [
OPT.node,
],
},
},
"daemon_start": {
"msg": "Start the daemon or a daemon thread pointed by :opt:`--thread-id`.",
"options": DAEMON_OPTS + [
OPT.thr_id,
],
},
},
"daemon_stop": {
"msg": "Stop the daemon or a daemon thread pointed by :opt:`--thread-id`.",
"options": DAEMON_OPTS + [
OPT.thr_id,
],
},
},
"daemon_join": {
"msg": "Join the cluster of the node specified by :opt:`--node <node>`, authenticating with :opt:`--secret <secret>`.",
"options": [
OPT.node,
OPT.secret,
],
},
},
"daemon_rejoin": {
"msg": "Rejoin the cluster of the node specified by :opt:`--node <node>`, authenticating with the already known secret. This will re-merge the remote node cluster-wide configurations in the local node configuration file.",
"options": [
OPT.node,
],
},
"daemon_leave": {
"msg": "Inform peer nodes we leave the cluster. Make sure the "
"left nodes are no longer in the services nodes list "
"before leaving, so the other nodes won't takeover.",
},
},
},
"Push data to the collector": {
"pushasset": {
Expand All @@ -621,7 +627,7 @@
OPT.sync,
OPT.cron,
],
},
},
"pushstats": {
"msg": "Push performance metrics to collector. By default pushed "
"stats interval begins yesterday at the beginning of the "
Expand All @@ -635,164 +641,164 @@
OPT.stats_dir,
OPT.cron,
],
},
},
"pushdisks": {
"msg": "Push disks usage information to the collector.",
"options": [
OPT.cron,
],
},
},
"pushpkg": {
"msg": "Push package/version list to the collector.",
"options": [
OPT.cron,
],
},
},
"pushpatch": {
"msg": "Push patch/version list to the collector.",
"options": [
OPT.cron,
],
},
},
"pushsym": {
"msg": "Push symmetrix configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
OPT.symcli_db_file,
],
},
},
"pushemcvnx": {
"msg": "Push EMC CX/VNX configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushcentera": {
"msg": "Push EMC Centera configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushnetapp": {
"msg": "Push Netapp configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pusheva": {
"msg": "Push HP EVA configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushnecism": {
"msg": "Push NEC ISM configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushhds": {
"msg": "Push HDS configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushdcs": {
"msg": "Push Datacore configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushfreenas": {
"msg": "Push FreeNAS configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushxtremio": {
"msg": "Push XtremIO configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushibmsvc": {
"msg": "Push IBM SVC configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushhp3par": {
"msg": "Push HP 3par configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushibmds": {
"msg": "Push IBM DS configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushvioserver": {
"msg": "Push IBM VIO server configurations to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushgcedisks": {
"msg": "Push Google Compute Engine disks configurations to the "
"collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushbrocade": {
"msg": "Push Brocade switch configuration to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"pushnsr": {
"msg": "Push EMC Networker index to the collector.",
"options": [
OPT.cron,
OPT.opt_object,
],
},
},
"sysreport": {
"msg": "Push system report to the collector for archiving and "
"diff analysis.",
"options": [
OPT.cron,
],
},
},
"checks": {
"msg": "Run node health checks. Push results to collector.",
"options": [
OPT.cron,
],
},
},
},
"Misc": {
"prkey": {
"msg": "Show the scsi3 persistent reservation key of this node.",
},
},
},
"Compliance": {
"compliance_auto": {
Expand Down
15 changes: 8 additions & 7 deletions usr/share/bash_completion.d/opensvc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ nodemgr_collector_show="actions tags"
nodemgr_compliance="attach auto check detach env fix fixable list show"
nodemgr_compliance_list="module moduleset ruleset"
nodemgr_compliance_show="moduleset ruleset status"
nodemgr_daemon="blacklist join leave restart running shutdown start status stop"
nodemgr_daemon="blacklist join leave rejoin restart running shutdown start status stop"
nodemgr_daemon_blacklist="clear status"
nodemgr_dequeue="actions"
nodemgr_edit="authconfig config"
Expand Down Expand Up @@ -250,16 +250,17 @@ nodemgr_collector_list_nodes="--color --debug --format -h --help"
nodemgr_collector_ack_action="--author --color --comment --debug --format -h --help"
nodemgr_collector_alerts="--color --debug --format -h --help"
nodemgr_collector_asset="--color --debug --format -h --help"
nodemgr_daemon_join="--color --debug --format --node --secret -h --help"
nodemgr_daemon_blacklist_clear="--color --debug --format -h --help"
nodemgr_daemon_restart="--color --debug --format -h --help"
nodemgr_daemon_start="--color --debug --format --local --node --thread-id -h --help"
nodemgr_daemon_shutdown="--color --debug --format -h --help"
nodemgr_daemon_stop="--color --debug --format --local --node --thread-id -h --help"
nodemgr_daemon_status="--color --debug --format --node -h --help"
nodemgr_daemon_running="--color --debug --format -h --help"
nodemgr_daemon_status="--color --debug --format --node -h --help"
nodemgr_daemon_leave="--color --debug --format -h --help"
nodemgr_daemon_blacklist_clear="--color --debug --format -h --help"
nodemgr_daemon_join="--color --debug --format --node --secret -h --help"
nodemgr_daemon_rejoin="--color --debug --format --node -h --help"
nodemgr_daemon_blacklist_status="--color --debug --format -h --help"
nodemgr_daemon_shutdown="--color --debug --format -h --help"
nodemgr_daemon_restart="--color --debug --format -h --help"
nodemgr_daemon_start="--color --debug --format --local --node --thread-id -h --help"

opts_with_arg=( "--add" "--api" "--app" "--author" "--backlog" "--begin" "--broadcast" "--color" "--comment" "--config" "--dev" "--downto" "--duration" "--end" "--env" "--format" "--hba" "--id" "--impersonate" "--index" "--kw" "--like" "--lun" "--mac" "--message" "--module" "--moduleset" "--node" "--object" "--param" "--password" "--port" "--remove" "--resource" "--rid" "--ruleset" "--ruleset-date" "--secret" "--service" "--slave" "--stats-dir" "--status" "--subsets" "--symcli-db-file" "--tag" "--tags" "--target" "--template" "--thread-id" "--time" "--to" "--upto" "--user" "--value" "--waitlock" "-s" )

Expand Down
27 changes: 27 additions & 0 deletions usr/share/man/man1/nodemgr.1
Original file line number Diff line number Diff line change
Expand Up @@ -2197,6 +2197,33 @@ Specify a data formatter. Possible values are json, csv or table.
.B -h, --help
Show this help message and exit

.RE
\fBnodemgr daemon rejoin\fP
.RS

Rejoin the cluster of the node specified by :opt:`--node <node>`, authenticating with the already known secret. This will re-merge the remote node cluster-wide configurations in the local node configuration file.


.TP
.B --node=NODE
The node to send a request to. If not specified the local node is targeted.
.TP
.B --color=COLOR
Colorize output. Possible values are:

* auto: guess based on tty presence
* always|yes: always colorize
* never|no: never colorize
.TP
.B --debug
Increase stream log verbosity up to the debug level.
.TP
.B --format=FORMAT
Specify a data formatter. Possible values are json, csv or table.
.TP
.B -h, --help
Show this help message and exit

.RE
\fBnodemgr daemon restart\fP
.RS
Expand Down

0 comments on commit f690d80

Please sign in to comment.