Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Compatible onyx tenancy log across patch versions #876

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/onyx/peer/log_version.clj
Original file line number Diff line number Diff line change
@@ -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})))))
11 changes: 0 additions & 11 deletions src/onyx/peer/log_version.cljc

This file was deleted.

2 changes: 1 addition & 1 deletion src/onyx/peer/peer_group_manager.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
22 changes: 22 additions & 0 deletions test/onyx/peer/log_version_test.clj
Original file line number Diff line number Diff line change
@@ -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)))))