diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-12-14 11:06:14 +0100 |
---|---|---|
committer | Harald Musum <musum@verizonmedia.com> | 2020-12-14 11:06:14 +0100 |
commit | 1e73025f837341b4a5367f73a55d9504e13c77ac (patch) | |
tree | f68682999762d7577906b2e6ee06f6ce9ef07e3c /clustercontroller-apps | |
parent | a7eafc4a8b773785f944425bdf40ad9218a656a2 (diff) |
Disallow creating a cluster controller having no zookeeper cluster
Diffstat (limited to 'clustercontroller-apps')
2 files changed, 8 insertions, 28 deletions
diff --git a/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java b/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java index c95d814eb99..5ce8f20bced 100644 --- a/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java +++ b/clustercontroller-apps/src/main/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurer.java @@ -31,7 +31,6 @@ public class ClusterControllerClusterConfigurer { configure(fleetcontrollerConfig); configure(slobroksConfig); configure(zookeepersConfig); - checkIfZooKeeperNeeded(); if (controller != null) { controller.setOptions(options.clusterName, options, metricImpl); } @@ -79,7 +78,7 @@ public class ClusterControllerClusterConfigurer { } private void configure(SlobroksConfig config) { - String specs[] = new String[config.slobrok().size()]; + String[] specs = new String[config.slobrok().size()]; for (int i = 0; i < config.slobrok().size(); i++) { specs[i] = config.slobrok().get(i).connectionspec(); } @@ -87,22 +86,14 @@ public class ClusterControllerClusterConfigurer { } private void configure(ZookeepersConfig config) { - options.zooKeeperServerAddress = config.zookeeperserverlist(); + options.zooKeeperServerAddress = verifyZooKeeperAddress(config.zookeeperserverlist()); } - private void checkIfZooKeeperNeeded() { - // For legacy (testing, presumably) reasons, support running 1 instance - // without a ZK cluster. This is really a Horrible Thing(tm) since we - // violate cluster state versioning invariants when the controller is - // restarted. - if (options.zooKeeperServerAddress == null || "".equals(options.zooKeeperServerAddress)) { - if (options.fleetControllerCount > 1) { - throw new IllegalArgumentException( - "Must set zookeeper server with multiple fleetcontrollers"); - } else { - options.zooKeeperServerAddress = null; // Force null - } + private String verifyZooKeeperAddress(String zooKeeperServerAddress) { + if (zooKeeperServerAddress == null || "".equals(zooKeeperServerAddress)) { + throw new IllegalArgumentException("zookeeper server address must be set, was '" + zooKeeperServerAddress + "'"); } + return zooKeeperServerAddress; } } diff --git a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java index 330174f0313..37131349602 100644 --- a/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java +++ b/clustercontroller-apps/src/test/java/com/yahoo/vespa/clustercontroller/apps/clustercontroller/ClusterControllerClusterConfigurerTest.java @@ -58,19 +58,8 @@ public class ClusterControllerClusterConfigurerTest { assertTrue(configurer.getOptions() != null); assertEquals(0.123, configurer.getOptions().minNodeRatioPerGroup, 0.01); - // Oki with no zookeeper if one node - zookeepersConfig.zookeeperserverlist(""); - new ClusterControllerClusterConfigurer( - controller, - new StorDistributionConfig(distributionConfig), - new FleetcontrollerConfig(fleetcontrollerConfig), - new SlobroksConfig(slobroksConfig), - new ZookeepersConfig(zookeepersConfig), - metric - ); - try{ - fleetcontrollerConfig.fleet_controller_count(5); + zookeepersConfig.zookeeperserverlist(""); new ClusterControllerClusterConfigurer( controller, new StorDistributionConfig(distributionConfig), @@ -81,7 +70,7 @@ public class ClusterControllerClusterConfigurerTest { ); fail("Should not get here"); } catch (Exception e) { - assertEquals("Must set zookeeper server with multiple fleetcontrollers", e.getMessage()); + assertEquals("zookeeper server address must be set, was ''", e.getMessage()); } } |