From caa1752206eb095249a10a304aa41d4e3890d2f8 Mon Sep 17 00:00:00 2001 From: Patrik Nordwall Date: Mon, 15 Apr 2019 16:58:32 +0200 Subject: [PATCH] Support disable of join compat config check, #26719 --- .../src/main/resources/reference.conf | 4 +++ .../scala/akka/cluster/ClusterSettings.scala | 11 +++++++- .../cluster/JoinConfigCompatCheckerSpec.scala | 28 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/akka-cluster/src/main/resources/reference.conf b/akka-cluster/src/main/resources/reference.conf index 3cb0fe8e2d..c384d6e1ea 100644 --- a/akka-cluster/src/main/resources/reference.conf +++ b/akka-cluster/src/main/resources/reference.conf @@ -296,6 +296,10 @@ akka { # to 'know' if its allowed to join. enforce-on-join = on + # Add named entry to this section with fully qualified class name of the JoinConfigCompatChecker + # to enable. + # Checkers defined in reference.conf can be disabled by application by using empty string value + # for the named entry. checkers { akka-cluster = "akka.cluster.JoinConfigCompatCheckCluster" } diff --git a/akka-cluster/src/main/scala/akka/cluster/ClusterSettings.scala b/akka-cluster/src/main/scala/akka/cluster/ClusterSettings.scala index f26624c335..0539dd767a 100644 --- a/akka-cluster/src/main/scala/akka/cluster/ClusterSettings.scala +++ b/akka-cluster/src/main/scala/akka/cluster/ClusterSettings.scala @@ -191,7 +191,16 @@ final class ClusterSettings(val config: Config, val systemName: String) { val ByPassConfigCompatCheck: Boolean = !cc.getBoolean("configuration-compatibility-check.enforce-on-join") val ConfigCompatCheckers: Set[String] = { import scala.collection.JavaConverters._ - cc.getConfig("configuration-compatibility-check.checkers").root.unwrapped.values().asScala.map(_.toString).toSet + cc.getConfig("configuration-compatibility-check.checkers") + .root + .unwrapped + .values() + .asScala + .iterator + .collect { + case s if s.toString.trim.nonEmpty => s.toString + } + .toSet } val SensitiveConfigPaths = { diff --git a/akka-cluster/src/test/scala/akka/cluster/JoinConfigCompatCheckerSpec.scala b/akka-cluster/src/test/scala/akka/cluster/JoinConfigCompatCheckerSpec.scala index f018a1e07e..604267e126 100644 --- a/akka-cluster/src/test/scala/akka/cluster/JoinConfigCompatCheckerSpec.scala +++ b/akka-cluster/src/test/scala/akka/cluster/JoinConfigCompatCheckerSpec.scala @@ -285,6 +285,7 @@ class JoinConfigCompatCheckerSpec extends AkkaSpec with ClusterTestKit { } } + } "A First Node" must { @@ -595,6 +596,33 @@ class JoinConfigCompatCheckerSpec extends AkkaSpec with ClusterTestKit { clusterTestUtil.shutdownAll() } } + + "be allowed to disable a check" taggedAs LongRunningTest in { + + // this config has sensitive properties that are not compatible with the cluster + // the cluster will ignore them, because they are on the sensitive-config-path + // the cluster won't let it be leaked back to the joining node neither which will fail the join attempt. + val joinNodeConfig = + ConfigFactory.parseString(""" + akka.cluster { + configuration-compatibility-check { + checkers { + # disable what is defined in reference.conf + akka-cluster = "" + akka-cluster-test = "" + } + } + } + """) + + val clusterTestUtil = new ClusterTestUtil(system.name) + try { + val sys = clusterTestUtil.newActorSystem(joinNodeConfig.withFallback(configWithChecker)) + Cluster(sys).settings.ConfigCompatCheckers should ===(Set.empty) + } finally { + clusterTestUtil.shutdownAll() + } + } } }