aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@verizonmedia.com>2021-07-28 14:39:40 +0200
committerHåkon Hallingstad <hakon@verizonmedia.com>2021-07-28 14:39:40 +0200
commit643032b7df47eb8551cf19d09fad4894a6d7457e (patch)
tree2d50a2cdc6289d7792d171d91d72eda1ac397661 /orchestrator
parentd24031c95eb561edcac408e3f6f676a1960cd3ee (diff)
Use OrchestrationParams
Diffstat (limited to 'orchestrator')
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiFactory.java11
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiImpl.java9
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ClusterApiImpl.java8
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java5
-rw-r--r--orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java19
-rw-r--r--orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java17
-rw-r--r--orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java17
7 files changed, 61 insertions, 25 deletions
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiFactory.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiFactory.java
index d913a1791ba..a3f2fd6e235 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiFactory.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiFactory.java
@@ -1,7 +1,11 @@
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.model;
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.vespa.orchestrator.OrchestratorUtil;
import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory;
+import com.yahoo.vespa.orchestrator.policy.HostedVespaOrchestration;
+import com.yahoo.vespa.orchestrator.policy.OrchestrationParams;
import com.yahoo.vespa.orchestrator.status.ApplicationLock;
import java.time.Clock;
@@ -11,19 +15,20 @@ import java.time.Clock;
*/
public class ApplicationApiFactory {
- private final int numberOfConfigServers;
+ private final OrchestrationParams orchestrationParams;
private final Clock clock;
public ApplicationApiFactory(int numberOfConfigServers, Clock clock) {
- this.numberOfConfigServers = numberOfConfigServers;
+ this.orchestrationParams = HostedVespaOrchestration.create(numberOfConfigServers, 0);
this.clock = clock;
}
public ApplicationApi create(NodeGroup nodeGroup,
ApplicationLock lock,
ClusterControllerClientFactory clusterControllerClientFactory) {
+ ApplicationId applicationId = OrchestratorUtil.toApplicationId(lock.getApplicationInstanceReference());
return new ApplicationApiImpl(nodeGroup, lock, clusterControllerClientFactory,
- numberOfConfigServers, clock);
+ orchestrationParams.getApplicationParams(applicationId), clock);
}
}
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiImpl.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiImpl.java
index efbf9ff7981..804aff70a7f 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiImpl.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ApplicationApiImpl.java
@@ -9,6 +9,7 @@ import com.yahoo.vespa.applicationmodel.ServiceInstance;
import com.yahoo.vespa.orchestrator.OrchestratorContext;
import com.yahoo.vespa.orchestrator.OrchestratorUtil;
import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory;
+import com.yahoo.vespa.orchestrator.policy.ApplicationParams;
import com.yahoo.vespa.orchestrator.status.ApplicationInstanceStatus;
import com.yahoo.vespa.orchestrator.status.ApplicationLock;
import com.yahoo.vespa.orchestrator.status.HostInfos;
@@ -38,13 +39,13 @@ public class ApplicationApiImpl implements ApplicationApi {
public ApplicationApiImpl(NodeGroup nodeGroup,
ApplicationLock lock,
ClusterControllerClientFactory clusterControllerClientFactory,
- int numberOfConfigServers, Clock clock) {
+ ApplicationParams params, Clock clock) {
this.applicationInstance = nodeGroup.getApplication();
this.nodeGroup = nodeGroup;
this.lock = lock;
this.clock = clock;
this.hostInfos = lock.getHostInfos();
- this.clusterInOrder = makeClustersInOrder(nodeGroup, hostInfos, clusterControllerClientFactory, numberOfConfigServers);
+ this.clusterInOrder = makeClustersInOrder(nodeGroup, hostInfos, clusterControllerClientFactory, params);
}
@Override
@@ -113,7 +114,7 @@ public class ApplicationApiImpl implements ApplicationApi {
private List<ClusterApi> makeClustersInOrder(NodeGroup nodeGroup,
HostInfos hostInfos,
ClusterControllerClientFactory clusterControllerClientFactory,
- int numberOfConfigServers) {
+ ApplicationParams params) {
Set<ServiceCluster> clustersInGroup = getServiceClustersInGroup(nodeGroup);
return clustersInGroup.stream()
.map(serviceCluster -> new ClusterApiImpl(
@@ -122,7 +123,7 @@ public class ApplicationApiImpl implements ApplicationApi {
nodeGroup,
hostInfos,
clusterControllerClientFactory,
- numberOfConfigServers,
+ params.clusterParamsFor(serviceCluster.clusterId(), serviceCluster.serviceType()),
clock))
.sorted(ApplicationApiImpl::compareClusters)
.collect(Collectors.toList());
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ClusterApiImpl.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ClusterApiImpl.java
index 57dcb5f3069..6e88b227e61 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ClusterApiImpl.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/model/ClusterApiImpl.java
@@ -8,6 +8,7 @@ import com.yahoo.vespa.applicationmodel.ServiceInstance;
import com.yahoo.vespa.applicationmodel.ServiceStatus;
import com.yahoo.vespa.applicationmodel.ServiceType;
import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory;
+import com.yahoo.vespa.orchestrator.policy.ClusterParams;
import com.yahoo.vespa.orchestrator.policy.SuspensionReasons;
import com.yahoo.vespa.orchestrator.status.HostInfos;
import com.yahoo.vespa.orchestrator.status.HostStatus;
@@ -59,7 +60,7 @@ class ClusterApiImpl implements ClusterApi {
NodeGroup nodeGroup,
HostInfos hostInfos,
ClusterControllerClientFactory clusterControllerClientFactory,
- int numberOfConfigServers,
+ ClusterParams clusterParams,
Clock clock) {
this.applicationApi = applicationApi;
this.serviceCluster = serviceCluster;
@@ -81,9 +82,8 @@ class ClusterApiImpl implements ClusterApi {
servicesDownAndNotInGroup = servicesNotInGroup.stream().filter(this::serviceEffectivelyDown).collect(Collectors.toSet());
int serviceInstances = serviceCluster.serviceInstances().size();
- if ((serviceCluster.isConfigServerLike() || serviceCluster.isConfigServerHostLike()) &&
- serviceInstances < numberOfConfigServers) {
- missingServices = numberOfConfigServers - serviceInstances;
+ if (clusterParams.size().isPresent() && serviceInstances < clusterParams.size().getAsInt()) {
+ missingServices = clusterParams.size().getAsInt() - serviceInstances;
descriptionOfMissingServices = missingServices + " missing " + serviceCluster.nodeDescription(missingServices > 1);
} else {
missingServices = 0;
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java
index caadadcad21..97574fc90ce 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/ApplicationParams.java
@@ -2,6 +2,7 @@
package com.yahoo.vespa.orchestrator.policy;
import com.yahoo.vespa.applicationmodel.ClusterId;
+import com.yahoo.vespa.applicationmodel.ServiceCluster;
import com.yahoo.vespa.applicationmodel.ServiceClusterKey;
import com.yahoo.vespa.applicationmodel.ServiceType;
@@ -43,6 +44,10 @@ public class ApplicationParams {
this.clusterParams = Map.copyOf(clusterParams);
}
+ public ClusterParams clusterParamsFor(ServiceCluster serviceCluster) {
+ return clusterParamsFor(serviceCluster.clusterId(), serviceCluster.serviceType());
+ }
+
public ClusterParams clusterParamsFor(ClusterId clusterId, ServiceType serviceType) {
var key = new ServiceClusterKey(clusterId, serviceType);
return clusterParams.getOrDefault(key, ClusterParams.getDefault());
diff --git a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java
index 311bbb5ea8b..d444f922f82 100644
--- a/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java
+++ b/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/HostedVespaOrchestration.java
@@ -18,6 +18,11 @@ import com.yahoo.vespa.service.duper.ProxyHostApplication;
*/
public class HostedVespaOrchestration {
public static OrchestrationParams create(ConfigserverConfig configserverConfig) {
+ // todo: get the number of proxy nodes
+ return create(configserverConfig.zookeeperserver().size(), 0);
+ }
+
+ public static OrchestrationParams create(int numConfigServers, int numProxies) {
// We'll create parameters for both the controller and config server applications, even though
// only one of them is present, as (a) no harm is done by having the extra parameters, and
// (b) it leads to simpler code below.
@@ -32,7 +37,7 @@ public class HostedVespaOrchestration {
ServiceType.HOST_ADMIN,
new ClusterParams
.Builder()
- .setSize(configserverConfig.zookeeperserver().size())
+ .setSize(numConfigServers)
.build())
.build())
@@ -44,7 +49,7 @@ public class HostedVespaOrchestration {
ServiceType.CONTROLLER,
new ClusterParams
.Builder()
- .setSize(configserverConfig.zookeeperserver().size())
+ .setSize(numConfigServers)
.build())
.build())
@@ -56,7 +61,7 @@ public class HostedVespaOrchestration {
ServiceType.HOST_ADMIN,
new ClusterParams
.Builder()
- .setSize(configserverConfig.zookeeperserver().size())
+ .setSize(numConfigServers)
.build())
.build())
@@ -68,7 +73,7 @@ public class HostedVespaOrchestration {
ServiceType.CONFIG_SERVER,
new ClusterParams
.Builder()
- .setSize(configserverConfig.zookeeperserver().size())
+ .setSize(numConfigServers)
.build())
.build())
@@ -80,8 +85,7 @@ public class HostedVespaOrchestration {
ServiceType.HOST_ADMIN,
new ClusterParams
.Builder()
- // todo: get the number of proxy nodes
- .setSize(0)
+ .setSize(numProxies)
.build())
.build())
@@ -93,8 +97,7 @@ public class HostedVespaOrchestration {
ServiceType.CONTAINER,
new ClusterParams
.Builder()
- // todo: get the number of proxy nodes
- .setSize(0)
+ .setSize(numProxies)
.build())
.build())
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java
index 6bf46052933..237d418aae5 100644
--- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java
+++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ClusterApiImplTest.java
@@ -13,6 +13,7 @@ import com.yahoo.vespa.applicationmodel.ServiceType;
import com.yahoo.vespa.flags.Flags;
import com.yahoo.vespa.flags.InMemoryFlagSource;
import com.yahoo.vespa.orchestrator.OrchestratorUtil;
+import com.yahoo.vespa.orchestrator.policy.ClusterParams;
import com.yahoo.vespa.orchestrator.policy.HostStateChangeDeniedException;
import com.yahoo.vespa.orchestrator.policy.HostedVespaClusterPolicy;
import com.yahoo.vespa.orchestrator.policy.SuspensionReasons;
@@ -88,7 +89,9 @@ public class ClusterApiImplTest {
serviceCluster,
new NodeGroup(modelUtils.createApplicationInstance(new ArrayList<>()), hostName5),
modelUtils.getHostInfos(),
- modelUtils.getClusterControllerClientFactory(), ModelTestUtils.NUMBER_OF_CONFIG_SERVERS, clock);
+ modelUtils.getClusterControllerClientFactory(),
+ ModelTestUtils.APPLICATION_PARAMS.clusterParamsFor(serviceCluster),
+ clock);
assertEquals("{ clusterId=cluster, serviceType=service-type }", clusterApi.clusterInfo());
assertFalse(clusterApi.isStorageCluster());
@@ -274,7 +277,9 @@ public class ClusterApiImplTest {
serviceCluster,
new NodeGroup(modelUtils.createApplicationInstance(new ArrayList<>()), groupNodes),
modelUtils.getHostInfos(),
- modelUtils.getClusterControllerClientFactory(), ModelTestUtils.NUMBER_OF_CONFIG_SERVERS, clock);
+ modelUtils.getClusterControllerClientFactory(),
+ ModelTestUtils.APPLICATION_PARAMS.clusterParamsFor(serviceCluster),
+ clock);
assertEquals(expectedNoServicesInGroupIsUp.map(SuspensionReasons::getMessagesInOrder),
clusterApi.reasonsForNoServicesInGroupIsUp().map(SuspensionReasons::getMessagesInOrder));
@@ -305,7 +310,9 @@ public class ClusterApiImplTest {
serviceCluster,
new NodeGroup(applicationInstance, hostName1, hostName3),
new HostInfos(),
- modelUtils.getClusterControllerClientFactory(), ModelTestUtils.NUMBER_OF_CONFIG_SERVERS, clock);
+ modelUtils.getClusterControllerClientFactory(),
+ ModelTestUtils.APPLICATION_PARAMS.clusterParamsFor(serviceCluster),
+ clock);
assertTrue(clusterApi.isStorageCluster());
assertEquals(Optional.of(hostName1), clusterApi.storageNodeInGroup().map(storageNode -> storageNode.hostName()));
@@ -353,7 +360,9 @@ public class ClusterApiImplTest {
serviceCluster,
new NodeGroup(application, hostnames.get(0)),
modelUtils.getHostInfos(),
- modelUtils.getClusterControllerClientFactory(), clusterSize, clock);
+ modelUtils.getClusterControllerClientFactory(),
+ new ClusterParams.Builder().setSize(clusterSize).build(),
+ clock);
assertEquals(clusterSize - serviceStatusList.size(), clusterApi.missingServices());
assertEquals(clusterSize == serviceStatusList.size(), clusterApi.noServicesOutsideGroupIsDown());
diff --git a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java
index 7cb20350845..6ec03ba3c44 100644
--- a/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java
+++ b/orchestrator/src/test/java/com/yahoo/vespa/orchestrator/model/ModelTestUtils.java
@@ -24,10 +24,14 @@ import com.yahoo.vespa.orchestrator.OrchestrationException;
import com.yahoo.vespa.orchestrator.Orchestrator;
import com.yahoo.vespa.orchestrator.OrchestratorContext;
import com.yahoo.vespa.orchestrator.OrchestratorImpl;
+import com.yahoo.vespa.orchestrator.OrchestratorUtil;
import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory;
import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactoryMock;
+import com.yahoo.vespa.orchestrator.policy.ApplicationParams;
import com.yahoo.vespa.orchestrator.policy.HostedVespaClusterPolicy;
+import com.yahoo.vespa.orchestrator.policy.HostedVespaOrchestration;
import com.yahoo.vespa.orchestrator.policy.HostedVespaPolicy;
+import com.yahoo.vespa.orchestrator.policy.OrchestrationParams;
import com.yahoo.vespa.orchestrator.status.ApplicationLock;
import com.yahoo.vespa.orchestrator.status.HostInfo;
import com.yahoo.vespa.orchestrator.status.HostInfos;
@@ -54,7 +58,16 @@ import static org.mockito.Mockito.mock;
*/
class ModelTestUtils {
+ private static final TenantId TENANT_ID = new TenantId("tenant");
+ private static final ApplicationInstanceId APPLICATION_INSTANCE_ID =
+ new ApplicationInstanceId("application-name:foo:bar:default");
+
public static final int NUMBER_OF_CONFIG_SERVERS = 3;
+ public static final OrchestrationParams ORCHESTRATION_PARAMS =
+ HostedVespaOrchestration.create(NUMBER_OF_CONFIG_SERVERS, 0);
+ public static final ApplicationParams APPLICATION_PARAMS = ORCHESTRATION_PARAMS
+ .getApplicationParams(OrchestratorUtil.toApplicationId(
+ new ApplicationInstanceReference(TENANT_ID, APPLICATION_INSTANCE_ID)));
private final InMemoryFlagSource flagSource = new InMemoryFlagSource();
private final Map<ApplicationInstanceReference, ApplicationInstance> applications = new HashMap<>();
@@ -134,8 +147,8 @@ class ModelTestUtils {
Set<ServiceCluster> serviceClusterSet = new HashSet<>(serviceClusters);
ApplicationInstance application = new ApplicationInstance(
- new TenantId("tenant"),
- new ApplicationInstanceId("application-name:foo:bar:default"),
+ TENANT_ID,
+ APPLICATION_INSTANCE_ID,
serviceClusterSet);
applications.put(application.reference(), application);