Support disable of join compat config check, #26719

This commit is contained in:
Patrik Nordwall 2019-04-15 16:58:32 +02:00
parent ee67c113e5
commit caa1752206
3 changed files with 42 additions and 1 deletions

View file

@ -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"
}

View file

@ -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 = {

View file

@ -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()
}
}
}
}