From fffcecc73b1ad3e6cba5721322835a9e1dcc4b74 Mon Sep 17 00:00:00 2001 From: irfan sharif Date: Wed, 22 Jul 2020 19:29:01 -0400 Subject: [PATCH] cockroachdb: no-longer rely on auto-init When starting CockroachDB nodes, always include join flags. In order to actually initialize the cluster, rely on an explicit `cockroach init`. Previously any node started without explicit join flags was tasked with bootstrapping the cluster. This was deprecated behavior, and was removed in https://github.com/cockroachdb/cockroach/pull/51245. Touches https://github.com/cockroachdb/cockroach/issues/49360 Touches https://github.com/cockroachdb/cockroach/issues/51052 Fixes https://github.com/cockroachdb/cockroach/issues/51050 Fixes https://github.com/cockroachdb/cockroach/issues/51725 Fixes https://github.com/cockroachdb/cockroach/issues/51726 Fixes https://github.com/cockroachdb/cockroach/issues/51727 Fixes https://github.com/cockroachdb/cockroach/issues/51728 Fixes https://github.com/cockroachdb/cockroach/issues/51729 Fixes https://github.com/cockroachdb/cockroach/issues/51730 Fixes https://github.com/cockroachdb/cockroach/issues/51731 Fixes https://github.com/cockroachdb/cockroach/issues/51732 Fixes https://github.com/cockroachdb/cockroach/issues/51733 Fixes https://github.com/cockroachdb/cockroach/issues/51734 Fixes https://github.com/cockroachdb/cockroach/issues/51735 Fixes https://github.com/cockroachdb/cockroach/issues/51736 Fixes https://github.com/cockroachdb/cockroach/issues/51737 Fixes https://github.com/cockroachdb/cockroach/issues/51740 Fixes https://github.com/cockroachdb/cockroach/issues/51741 Fixes https://github.com/cockroachdb/cockroach/issues/51742 Fixes https://github.com/cockroachdb/cockroach/issues/51743 Fixes https://github.com/cockroachdb/cockroach/issues/51744 Fixes https://github.com/cockroachdb/cockroach/issues/51745 Fixes https://github.com/cockroachdb/cockroach/issues/51746 Fixes https://github.com/cockroachdb/cockroach/issues/51747 Fixes https://github.com/cockroachdb/cockroach/issues/51748 Fixes https://github.com/cockroachdb/cockroach/issues/51749 Fixes https://github.com/cockroachdb/cockroach/issues/51750 Fixes https://github.com/cockroachdb/cockroach/issues/51751 Fixes https://github.com/cockroachdb/cockroach/issues/51752 Fixes https://github.com/cockroachdb/cockroach/issues/51753 Fixes https://github.com/cockroachdb/cockroach/issues/51754 Fixes https://github.com/cockroachdb/cockroach/issues/51755 Fixes https://github.com/cockroachdb/cockroach/issues/51756 Fixes https://github.com/cockroachdb/cockroach/issues/51758 --- cockroachdb/src/jepsen/cockroach.clj | 4 +++ cockroachdb/src/jepsen/cockroach/auto.clj | 43 ++++++++++++++++++----- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/cockroachdb/src/jepsen/cockroach.clj b/cockroachdb/src/jepsen/cockroach.clj index d8437df5d..a619a365c 100644 --- a/cockroachdb/src/jepsen/cockroach.clj +++ b/cockroachdb/src/jepsen/cockroach.clj @@ -70,6 +70,10 @@ (auto/start! test node) (Thread/sleep 5000)) ; Give it time to join + (when (= node (jepsen/primary test)) + (auto/init! node) + (Thread/sleep 5000)) + (jepsen/synchronize test) (when (= node (jepsen/primary test)) (auto/set-replication-zone! "default" diff --git a/cockroachdb/src/jepsen/cockroach/auto.clj b/cockroachdb/src/jepsen/cockroach/auto.clj index 36d4fed0b..0d2e7874a 100644 --- a/cockroachdb/src/jepsen/cockroach/auto.clj +++ b/cockroachdb/src/jepsen/cockroach/auto.clj @@ -57,6 +57,13 @@ ] (if insecure [:--insecure] []))) +;; Extra command-line arguments to give to `cockroach init` +(def cockroach-init-arguments + (concat [:init + ;; ... other arguments here ... + ] + (if insecure [:--insecure] []))) + (defn control-addr "Address of the Jepsen control node, as seen by the local node. Used to filter packet captures." @@ -162,16 +169,21 @@ extra-args [:--logtostderr :>> errlog (c/lit "2>&1")])) -(defn runcmd - "The command to run cockroach for a given test" - [test node joining?] - (let [join (if joining? - [(->> (:nodes test) +(defn cockroach-init-cmdline + "Construct the command line to initialize a CockroachDB cluster." + [] + (concat + [(c/expand-path cockroach)] + cockroach-init-arguments)) + +(defn startcmd + "The command to start cockroach for a given test" + [test node] + (let [join [(->> (:nodes test) (remove #{node}) (map name) (str/join ",") - (str "--join="))] - [])] + (str "--join="))]] (wrap-env [(str "COCKROACH_LINEARIZABLE=" (if (:linearizable test) "true" "false")) (str "COCKROACH_MAX_OFFSET=" "250ms")] @@ -186,11 +198,24 @@ (catch RuntimeException e ""))) (info node "Cockroach already running.") (do (info node "Starting CockroachDB...") - (c/trace (c/exec (runcmd test node - (not= node (jepsen/primary test))))) + (c/trace (c/exec (startcmd test node))) (info node "Cockroach started")))) :started) +(defn initcmd + "The command to initialize cockroach for a given test" + [] + (cockroach-init-cmdline)) + +(defn init! + "Initialize cockroachdb cluster" + [node] + (c/sudo cockroach-user + (do (info node "Initializing CockroachDB...") + (c/trace (c/exec (initcmd))) + (info node "Cockroach initialized"))) + :initialized) + (defn kill! "Kills cockroach on node." [test node]