summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@verizonmedia.com>2019-10-28 12:39:39 +0100
committerGitHub <noreply@github.com>2019-10-28 12:39:39 +0100
commitd4ccb75352c9736c1340dcf82018287cb66715b0 (patch)
tree5417ead27a38e5d5e140d97f93fc24efb1298daa
parent95e30f1e88c7b7924ce625c1f603f66bbfe7af8a (diff)
parent0d922a3915981eca5038ea25a0f322b8359ff2c8 (diff)
Merge pull request #11131 from vespa-engine/vekterli/add-safe-mode-support-to-vespa-set-node-state-tool
Add "safe mode" flag support to vespa-set-node-state tool
-rw-r--r--vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm9
-rw-r--r--vespaclient/src/perl/lib/Yahoo/Vespa/ClusterController.pm7
2 files changed, 13 insertions, 3 deletions
diff --git a/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm b/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm
index 3767640b9dd..ffa70890934 100644
--- a/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm
+++ b/vespaclient/src/perl/lib/Yahoo/Vespa/Bin/SetNodeState.pm
@@ -22,6 +22,7 @@ our $wanted_state_description;
our $nodes_attempted_set;
our $success;
our $no_wait;
+our $safe_mode;
return 1;
@@ -63,6 +64,12 @@ EOS
setOptionHeader("Options related to operation visibility:");
setFlagOption(['n', 'no-wait'], \$no_wait, "Do not wait for node state "
. "changes to be visible in the cluster before returning.");
+ setFlagOption(['a', 'safe'], \$safe_mode, "Only carries out state changes "
+ . "if deemed safe by the cluster controller. For maintenance mode, "
+ . "will also set the distributor with the same distribution key "
+ . "to down atomically as part of the same state change. For up "
+ . "mode, transition is only allowed if the content node reports "
+ . "itself as up. Only supported for type storage.");
Yahoo::Vespa::ContentNodeSelection::registerCommandLineArguments();
Yahoo::Vespa::VespaModel::registerCommandLineArguments();
@@ -115,6 +122,6 @@ sub setNodeStateForNode {
my ($cluster, $type, $index) = (
$$info{'cluster'}, $$info{'type'}, $$info{'index'});
$success &&= setNodeUserState($cluster, $type, $index, $wanted_state,
- $wanted_state_description, $no_wait);
+ $wanted_state_description, $no_wait, $safe_mode);
++$nodes_attempted_set;
}
diff --git a/vespaclient/src/perl/lib/Yahoo/Vespa/ClusterController.pm b/vespaclient/src/perl/lib/Yahoo/Vespa/ClusterController.pm
index cac91885fb9..7b9cb7ee554 100644
--- a/vespaclient/src/perl/lib/Yahoo/Vespa/ClusterController.pm
+++ b/vespaclient/src/perl/lib/Yahoo/Vespa/ClusterController.pm
@@ -80,8 +80,8 @@ sub detectClusterController { # ()
enableAutomaticLineBreaks($oldVal);
}
}
-sub setNodeUserState { # (ClusterName, NodeType, Index, State, Reason, NoWait)
- my ($cluster, $service, $index, $state, $reason, $no_wait) = @_;
+sub setNodeUserState { # (ClusterName, NodeType, Index, State, Reason, NoWait, SafeMode)
+ my ($cluster, $service, $index, $state, $reason, $no_wait, $safe_mode) = @_;
my @params = ();
my @headers = (
'Content-Type' => 'application/json'
@@ -103,6 +103,9 @@ sub setNodeUserState { # (ClusterName, NodeType, Index, State, Reason, NoWait)
if ($no_wait) {
$request->{'response-wait'} = 'no-wait';
}
+ if ($safe_mode) {
+ $request->{'condition'} = 'safe';
+ }
my $content = Json::encode($request);
my $path = &getPathToNode($cluster, $service, $index);