From 5f904b26c5033fb60fbd8c7bf90890f8b4fffb08 Mon Sep 17 00:00:00 2001 From: Ryan Sundberg Date: Thu, 27 Sep 2018 10:50:09 -0700 Subject: [PATCH 1/2] Log unrecoverable peer group error as FATAL instead of ERROR --- src/onyx/peer/peer_group_manager.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/onyx/peer/peer_group_manager.clj b/src/onyx/peer/peer_group_manager.clj index c039d659a..c99862ae9 100644 --- a/src/onyx/peer/peer_group_manager.clj +++ b/src/onyx/peer/peer_group_manager.clj @@ -366,7 +366,7 @@ (action [:apply-log-entry]) (action [:monitor]))))))))) (catch Exception t - (error t (format "Unrecoverable error caught in PeerGroupManager loop. Exiting.")) + (fatal t (format "Unrecoverable error caught in PeerGroupManager loop. Exiting.")) (System/exit 1)))) (defrecord PeerGroupManager [peer-config onyx-vpeer-system-fn] From e370ae887c1093e1ed2762ac1b356dabf1e39c81 Mon Sep 17 00:00:00 2001 From: Ryan Sundberg Date: Thu, 27 Sep 2018 12:33:35 -0700 Subject: [PATCH 2/2] Allow differences in PATCH version to pass compatible version check --- src/onyx/peer/log_version.clj | 17 +++++++++++++++++ src/onyx/peer/log_version.cljc | 11 ----------- test/onyx/peer/log_version_test.clj | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 src/onyx/peer/log_version.clj delete mode 100644 src/onyx/peer/log_version.cljc create mode 100644 test/onyx/peer/log_version_test.clj diff --git a/src/onyx/peer/log_version.clj b/src/onyx/peer/log_version.clj new file mode 100644 index 000000000..51963393a --- /dev/null +++ b/src/onyx/peer/log_version.clj @@ -0,0 +1,17 @@ +(ns onyx.peer.log-version) + +(def version "0.13.6-SNAPSHOT") + +(defn parse-semver + [semantic-version] + (when (some? semantic-version) + (next (re-matches #"(\d+)\.(\d+)\.(\d+)\-?(.*)" semantic-version)))) + +(defn check-compatible-log-versions! [cluster-version] + (let [[major minor patch] (parse-semver version) + [cluster-major cluster-minor] (parse-semver cluster-version)] + (when (not= [major minor] [cluster-major cluster-minor]) + (throw (ex-info "Incompatible versions of the Onyx cluster coordination log. + A new, distinct, :onyx/tenancy-id should be supplied when upgrading or downgrading Onyx." + {:cluster-version cluster-version + :peer-version version}))))) diff --git a/src/onyx/peer/log_version.cljc b/src/onyx/peer/log_version.cljc deleted file mode 100644 index ea2fd3628..000000000 --- a/src/onyx/peer/log_version.cljc +++ /dev/null @@ -1,11 +0,0 @@ -(ns onyx.peer.log-version) - -(def version "0.13.6-SNAPSHOT") - -(defn check-compatible-log-versions! [cluster-version] - (when-not (or (re-find #"-" version) - (= version cluster-version)) - (throw (ex-info "Incompatible versions of the Onyx cluster coordination log. - A new, distinct, :onyx/tenancy-id should be supplied when upgrading or downgrading Onyx." - {:cluster-version cluster-version - :peer-version version})))) diff --git a/test/onyx/peer/log_version_test.clj b/test/onyx/peer/log_version_test.clj new file mode 100644 index 000000000..7e9b6ddd5 --- /dev/null +++ b/test/onyx/peer/log_version_test.clj @@ -0,0 +1,22 @@ +(ns onyx.peer.log-version-test + (:require [clojure.test :refer [deftest is testing]] + [onyx.test-helper :refer [load-config with-test-env]] + [onyx.peer.log-version :refer [version parse-semver check-compatible-log-versions!]])) + +(deftest version-test + (is (some? version)) + (is (some? (parse-semver version)))) + +(deftest parse-semver-test + (is (= ["1" "2" "3" ""] (parse-semver "1.2.3"))) + (is (= ["1" "2" "3" "alpha4"] (parse-semver "1.2.3-alpha4"))) + (is (nil? (parse-semver "1.2"))) + (is (nil? (parse-semver nil)))) + +(deftest check-compatible-versions-test + (is (thrown? clojure.lang.ExceptionInfo (check-compatible-log-versions! "0.1.0"))) + (is (thrown? clojure.lang.ExceptionInfo (check-compatible-log-versions! "0.99.0"))) + (is (nil? (check-compatible-log-versions! version))) + (let [[major minor] (parse-semver version) + future-version (str major "." minor ".99")] + (is (nil? (check-compatible-log-versions! future-version)))))