diff options
author | Valerij Fredriksen <freva@users.noreply.github.com> | 2019-06-02 15:59:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-02 15:59:46 +0200 |
commit | 9ff9c4f20bd4b5440ece8f879de35dff7de12102 (patch) | |
tree | 8feb9969838e6078606978ec16d0b49e759c717d /node-repository | |
parent | b33f016430c8f659e11d32cee616442cd029bcc2 (diff) | |
parent | b0154dbc54bf7257d4d1803c4b0895b11f56335b (diff) |
Merge pull request #9639 from vespa-engine/freva/default-target-version
Default target version v2
Diffstat (limited to 'node-repository')
12 files changed, 100 insertions, 131 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureProvisioner.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureProvisioner.java index 9ab816b8acc..3392569d1f2 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureProvisioner.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureProvisioner.java @@ -1,7 +1,6 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.maintenance; -import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.InfraDeployer; import com.yahoo.log.LogLevel; import com.yahoo.vespa.hosted.provision.NodeRepository; @@ -28,13 +27,13 @@ public class InfrastructureProvisioner extends Maintainer { @Override protected void maintain() { - for (ApplicationId application : infraDeployer.getSupportedInfraApplications()) { + infraDeployer.getSupportedInfraDeployments().forEach((application, deployment) -> { try { - infraDeployer.getDeployment(application).orElseThrow().activate(); + deployment.activate(); } catch (RuntimeException e) { logger.log(LogLevel.INFO, "Failed to activate " + application, e); // loop around to activate the next application } - } + }); } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersions.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersions.java index 7e2e729149b..ca2a5bb271c 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersions.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersions.java @@ -2,6 +2,7 @@ package com.yahoo.vespa.hosted.provision.maintenance; import com.yahoo.component.Version; +import com.yahoo.component.Vtag; import com.yahoo.config.provision.NodeType; import com.yahoo.vespa.curator.Lock; import com.yahoo.vespa.hosted.provision.persistence.CuratorDatabaseClient; @@ -23,52 +24,73 @@ public class InfrastructureVersions { private static final Logger logger = Logger.getLogger(InfrastructureVersions.class.getName()); private final CuratorDatabaseClient db; + private final Version defaultVersion; public InfrastructureVersions(CuratorDatabaseClient db) { + this(db, Vtag.currentVersion); + } + + InfrastructureVersions(CuratorDatabaseClient db, Version defaultVersion) { this.db = db; + this.defaultVersion = defaultVersion; } public void setTargetVersion(NodeType nodeType, Version newTargetVersion, boolean force) { - switch (nodeType) { - case config: - case confighost: - case proxyhost: - case controller: - case controllerhost: - break; - default: - throw new IllegalArgumentException("Cannot set version for type " + nodeType); - } - if (newTargetVersion.isEmpty()) { - throw new IllegalArgumentException("Invalid target version: " + newTargetVersion.toFullString()); - } + assertLegalNodeTypeForTargetVersion(nodeType); try (Lock lock = db.lockInfrastructureVersions()) { Map<NodeType, Version> infrastructureVersions = db.readInfrastructureVersions(); - Optional<Version> currentTargetVersion = Optional.ofNullable(infrastructureVersions.get(nodeType)); + Version currentTargetVersion = Optional.ofNullable(infrastructureVersions.get(nodeType)) + .orElse(Version.emptyVersion); // Trying to set the version to the current version, skip - if (currentTargetVersion.equals(Optional.of(newTargetVersion))) return; + if (currentTargetVersion.equals(newTargetVersion)) return; // If we don't force the set, we must set the new version to higher than the already set version - if (!force && currentTargetVersion.isPresent()) { - if (currentTargetVersion.get().isAfter(newTargetVersion)) - throw new IllegalArgumentException(String.format("Cannot downgrade version without setting 'force'. " + - "Current target version: %s, attempted to set target version: %s", - currentTargetVersion.get().toFullString(), newTargetVersion.toFullString())); + if (!force && currentTargetVersion.isAfter(newTargetVersion)) { + throw new IllegalArgumentException(String.format("Cannot downgrade version without setting 'force'. Current target version: %s, attempted to set target version: %s", + currentTargetVersion.toFullString(), newTargetVersion.toFullString())); } - infrastructureVersions.put(nodeType, newTargetVersion); + if (newTargetVersion.isEmpty()) { + infrastructureVersions.remove(nodeType); + logger.info("Removing target version for " + nodeType); + } else { + infrastructureVersions.put(nodeType, newTargetVersion); + logger.info("Setting target version for " + nodeType + " to " + newTargetVersion.toFullString()); + } db.writeInfrastructureVersions(infrastructureVersions); - logger.info("Set target version for " + nodeType + " to " + newTargetVersion.toFullString()); } } - public Optional<Version> getTargetVersionFor(NodeType nodeType) { - return Optional.ofNullable(db.readInfrastructureVersions().get(nodeType)); + public Version getTargetVersionFor(NodeType nodeType) { + assertLegalNodeTypeForTargetVersion(nodeType); + + return Optional.ofNullable(db.readInfrastructureVersions().get(nodeType)).orElseGet(() -> { + // Target version has never been set for this node type, set it to the default version of this server. + // We need to set the version (in ZK) to prevent another config server from returning a different version. + // No lock needed since this is only an issue in bootstrap case and in a potential race, all versions + // are equally valid + setTargetVersion(nodeType, defaultVersion, false); + return defaultVersion; + }); } public Map<NodeType, Version> getTargetVersions() { return Collections.unmodifiableMap(db.readInfrastructureVersions()); } + + private static void assertLegalNodeTypeForTargetVersion(NodeType nodeType) { + switch (nodeType) { + case config: + case confighost: + case controller: + case controllerhost: + case proxyhost: + case host: + break; + default: + throw new IllegalArgumentException("Target version for type " + nodeType + " is not allowed"); + } + } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java index 8102f5cc305..b7e8395cc92 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailer.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.maintenance; -import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.provision.Deployer; import com.yahoo.config.provision.Deployment; import com.yahoo.config.provision.HostLivenessTracker; @@ -68,13 +67,11 @@ public class NodeFailer extends Maintainer { private final Instant constructionTime; private final ThrottlePolicy throttlePolicy; private final Metric metric; - private final ConfigserverConfig configserverConfig; public NodeFailer(Deployer deployer, HostLivenessTracker hostLivenessTracker, ServiceMonitor serviceMonitor, NodeRepository nodeRepository, Duration downTimeLimit, Clock clock, Orchestrator orchestrator, - ThrottlePolicy throttlePolicy, Metric metric, - ConfigserverConfig configserverConfig) { + ThrottlePolicy throttlePolicy, Metric metric) { // check ping status every five minutes, but at least twice as often as the down time limit super(nodeRepository, min(downTimeLimit.dividedBy(2), Duration.ofMinutes(5))); this.deployer = deployer; @@ -86,7 +83,6 @@ public class NodeFailer extends Maintainer { this.constructionTime = clock.instant(); this.throttlePolicy = throttlePolicy; this.metric = metric; - this.configserverConfig = configserverConfig; } @Override @@ -244,7 +240,7 @@ public class NodeFailer extends Maintainer { } private boolean expectConfigRequests(Node node) { - return !node.type().isDockerHost() || configserverConfig.nodeAdminInContainer(); + return !node.type().isDockerHost(); } private boolean hasNodeRequestedConfigAfter(Node node, Instant instant) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java index 9ace6ad55ef..18ae7e17d6d 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/NodeRepositoryMaintenance.java @@ -2,7 +2,6 @@ package com.yahoo.vespa.hosted.provision.maintenance; import com.google.inject.Inject; -import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.AbstractComponent; import com.yahoo.config.provision.Deployer; import com.yahoo.config.provision.Environment; @@ -59,21 +58,19 @@ public class NodeRepositoryMaintenance extends AbstractComponent { public NodeRepositoryMaintenance(NodeRepository nodeRepository, Deployer deployer, InfraDeployer infraDeployer, HostLivenessTracker hostLivenessTracker, ServiceMonitor serviceMonitor, Zone zone, Orchestrator orchestrator, Metric metric, - ConfigserverConfig configserverConfig, ProvisionServiceProvider provisionServiceProvider, FlagSource flagSource) { this(nodeRepository, deployer, infraDeployer, hostLivenessTracker, serviceMonitor, zone, Clock.systemUTC(), - orchestrator, metric, configserverConfig, provisionServiceProvider, flagSource); + orchestrator, metric, provisionServiceProvider, flagSource); } public NodeRepositoryMaintenance(NodeRepository nodeRepository, Deployer deployer, InfraDeployer infraDeployer, HostLivenessTracker hostLivenessTracker, ServiceMonitor serviceMonitor, Zone zone, Clock clock, Orchestrator orchestrator, Metric metric, - ConfigserverConfig configserverConfig, ProvisionServiceProvider provisionServiceProvider, FlagSource flagSource) { DefaultTimes defaults = new DefaultTimes(zone); - nodeFailer = new NodeFailer(deployer, hostLivenessTracker, serviceMonitor, nodeRepository, durationFromEnv("fail_grace").orElse(defaults.failGrace), clock, orchestrator, throttlePolicyFromEnv().orElse(defaults.throttlePolicy), metric, configserverConfig); + nodeFailer = new NodeFailer(deployer, hostLivenessTracker, serviceMonitor, nodeRepository, durationFromEnv("fail_grace").orElse(defaults.failGrace), clock, orchestrator, throttlePolicyFromEnv().orElse(defaults.throttlePolicy), metric); periodicApplicationMaintainer = new PeriodicApplicationMaintainer(deployer, nodeRepository, defaults.redeployMaintainerInterval, durationFromEnv("periodic_redeploy_interval").orElse(defaults.periodicRedeployInterval)); operatorChangeApplicationMaintainer = new OperatorChangeApplicationMaintainer(deployer, nodeRepository, clock, durationFromEnv("operator_change_redeploy_interval").orElse(defaults.operatorChangeRedeployInterval)); reservationExpirer = new ReservationExpirer(nodeRepository, clock, durationFromEnv("reservation_expiry").orElse(defaults.reservationExpiry)); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java index d002d81cc2c..f3fdb583abf 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImpl.java @@ -23,7 +23,6 @@ import com.yahoo.vespa.service.monitor.InfraApplicationApi; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.function.Function; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -38,7 +37,6 @@ public class InfraDeployerImpl implements InfraDeployer { private final Provisioner provisioner; private final InfrastructureVersions infrastructureVersions; private final DuperModelInfraApi duperModel; - private final Map<ApplicationId, InfraApplicationApi> infraApplicationApiByApplicationId; @Inject public InfraDeployerImpl(NodeRepository nodeRepository, Provisioner provisioner, DuperModelInfraApi duperModel) { @@ -46,21 +44,17 @@ public class InfraDeployerImpl implements InfraDeployer { this.provisioner = provisioner; this.infrastructureVersions = nodeRepository.infrastructureVersions(); this.duperModel = duperModel; - this.infraApplicationApiByApplicationId = duperModel.getSupportedInfraApplications().stream() - .collect(Collectors.toUnmodifiableMap( - InfraApplicationApi::getApplicationId, - Function.identity())); } - @Override public Optional<Deployment> getDeployment(ApplicationId application) { - return Optional.ofNullable(infraApplicationApiByApplicationId.get(application)).map(InfraDeployment::new); + return duperModel.getInfraApplication(application).map(InfraDeployment::new); } @Override - public List<ApplicationId> getSupportedInfraApplications() { - return List.copyOf(infraApplicationApiByApplicationId.keySet()); + public Map<ApplicationId, Deployment> getSupportedInfraDeployments() { + return duperModel.getSupportedInfraApplications().stream() + .collect(Collectors.toMap(InfraApplicationApi::getApplicationId, InfraDeployment::new)); } private class InfraDeployment implements Deployment { @@ -81,13 +75,6 @@ public class InfraDeployerImpl implements InfraDeployer { try (Mutex lock = nodeRepository.lock(application.getApplicationId())) { NodeType nodeType = application.getCapacity().type(); - Optional<Version> targetVersion = infrastructureVersions.getTargetVersionFor(nodeType); - if (targetVersion.isEmpty()) { - logger.log(LogLevel.DEBUG, "No target version set for " + nodeType + ", removing application"); - removeApplication(application.getApplicationId()); - return; - } - candidateNodes = nodeRepository .getNodes(nodeType, Node.State.ready, Node.State.reserved, Node.State.active, Node.State.inactive); if (candidateNodes.isEmpty()) { @@ -96,10 +83,11 @@ public class InfraDeployerImpl implements InfraDeployer { return; } - if (!allActiveNodesOn(targetVersion.get(), candidateNodes)) { + Version targetVersion = infrastructureVersions.getTargetVersionFor(nodeType); + if (!allActiveNodesOn(targetVersion, candidateNodes)) { hostSpecs = provisioner.prepare( application.getApplicationId(), - application.getClusterSpecWithVersion(targetVersion.get()), + application.getClusterSpecWithVersion(targetVersion), application.getCapacity(), 1, // groups logger::log); diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java index 1a612e0ff00..62e17ab63ad 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockDuperModel.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; /** @@ -30,6 +31,11 @@ public class MockDuperModel implements DuperModelInfraApi { } @Override + public Optional<InfraApplicationApi> getInfraApplication(ApplicationId applicationId) { + return Optional.ofNullable(supportedInfraApps.get(applicationId)); + } + + @Override public boolean infraApplicationIsActive(ApplicationId applicationId) { return activeApps.containsKey(applicationId); } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockInfraDeployer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockInfraDeployer.java index 5a5f8431653..831520cf383 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockInfraDeployer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/testutils/MockInfraDeployer.java @@ -4,7 +4,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.Deployment; import com.yahoo.config.provision.InfraDeployer; -import java.util.List; +import java.util.Map; import java.util.Optional; public class MockInfraDeployer implements InfraDeployer { @@ -14,7 +14,7 @@ public class MockInfraDeployer implements InfraDeployer { } @Override - public List<ApplicationId> getSupportedInfraApplications() { - return List.of(); + public Map<ApplicationId, Deployment> getSupportedInfraDeployments() { + return Map.of(); } } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersionsTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersionsTest.java index 4ee3ade351a..62e783be1f7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersionsTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InfrastructureVersionsTest.java @@ -8,7 +8,6 @@ import org.junit.Test; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -19,9 +18,10 @@ import static org.junit.Assert.fail; */ public class InfrastructureVersionsTest { + private final Version defaultVersion = Version.fromString("6.13.37"); private final NodeRepositoryTester tester = new NodeRepositoryTester(); private final InfrastructureVersions infrastructureVersions = - new InfrastructureVersions(tester.nodeRepository().database()); + new InfrastructureVersions(tester.nodeRepository().database(), defaultVersion); private final Version version = Version.fromString("6.123.456"); @@ -29,14 +29,14 @@ public class InfrastructureVersionsTest { public void can_only_downgrade_with_force() { assertTrue(infrastructureVersions.getTargetVersions().isEmpty()); - assertEquals(Optional.empty(), infrastructureVersions.getTargetVersionFor(NodeType.config)); + assertEquals(defaultVersion, infrastructureVersions.getTargetVersionFor(NodeType.config)); infrastructureVersions.setTargetVersion(NodeType.config, version, false); - assertEquals(Optional.of(version), infrastructureVersions.getTargetVersionFor(NodeType.config)); + assertEquals(version, infrastructureVersions.getTargetVersionFor(NodeType.config)); // Upgrading to new version without force is fine - Version new_version = Version.fromString("6.123.457"); // version + 1 - infrastructureVersions.setTargetVersion(NodeType.config, new_version, false); - assertEquals(Optional.of(new_version), infrastructureVersions.getTargetVersionFor(NodeType.config)); + Version newVersion = Version.fromString("6.123.457"); // version + 1 + infrastructureVersions.setTargetVersion(NodeType.config, newVersion, false); + assertEquals(newVersion, infrastructureVersions.getTargetVersionFor(NodeType.config)); // Downgrading to old version without force fails try { @@ -45,7 +45,7 @@ public class InfrastructureVersionsTest { } catch (IllegalArgumentException ignored) { } infrastructureVersions.setTargetVersion(NodeType.config, version, true); - assertEquals(Optional.of(version), infrastructureVersions.getTargetVersionFor(NodeType.config)); + assertEquals(version, infrastructureVersions.getTargetVersionFor(NodeType.config)); } @Test diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java index 9e57ae6dcd6..3e42a0efad7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailTester.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.maintenance; -import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; @@ -78,13 +77,8 @@ public class NodeFailTester { private final Orchestrator orchestrator; private final NodeRepositoryProvisioner provisioner; private final Curator curator; - private final ConfigserverConfig configserverConfig; private NodeFailTester() { - this(new ConfigserverConfig(new ConfigserverConfig.Builder())); - } - - private NodeFailTester(ConfigserverConfig configserverConfig) { clock = new ManualClock(); curator = new MockCurator(); nodeRepository = new NodeRepository(nodeFlavors, curator, clock, zone, new MockNameResolver().mockAnyLookup(), @@ -92,15 +86,10 @@ public class NodeFailTester { provisioner = new NodeRepositoryProvisioner(nodeRepository, nodeFlavors, zone, new MockProvisionServiceProvider(), new InMemoryFlagSource()); hostLivenessTracker = new TestHostLivenessTracker(clock); orchestrator = new OrchestratorMock(); - this.configserverConfig = configserverConfig; } public static NodeFailTester withTwoApplications() { - return withTwoApplications(new ConfigserverConfig(new ConfigserverConfig.Builder())); - } - - public static NodeFailTester withTwoApplications(ConfigserverConfig configserverConfig) { - NodeFailTester tester = new NodeFailTester(configserverConfig); + NodeFailTester tester = new NodeFailTester(); tester.createReadyNodes(16, nodeResources); tester.createHostNodes(3); @@ -209,7 +198,7 @@ public class NodeFailTester { } public NodeFailer createFailer() { - return new NodeFailer(deployer, hostLivenessTracker, serviceMonitor, nodeRepository, downtimeLimitOneHour, clock, orchestrator, NodeFailer.ThrottlePolicy.hosted, metric, configserverConfig); + return new NodeFailer(deployer, hostLivenessTracker, serviceMonitor, nodeRepository, downtimeLimitOneHour, clock, orchestrator, NodeFailer.ThrottlePolicy.hosted, metric); } public void allNodesMakeAConfigRequestExcept(Node ... deadNodeArray) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailerTest.java index a8b0d0becd4..66c05e474a8 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/NodeFailerTest.java @@ -1,8 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.maintenance; -import com.yahoo.cloud.config.ConfigserverConfig; -import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.NodeResources; import com.yahoo.config.provision.NodeType; import com.yahoo.vespa.applicationmodel.ServiceInstance; @@ -337,34 +335,8 @@ public class NodeFailerTest { } @Test - public void docker_host_failed_without_config_requests() { - NodeFailTester tester = NodeFailTester.withTwoApplications( - new ConfigserverConfig(new ConfigserverConfig.Builder().nodeAdminInContainer(true)) - ); - - // For a day all nodes work so nothing happens - for (int minutes = 0, interval = 30; minutes < 24 * 60; minutes += interval) { - tester.clock.advance(Duration.ofMinutes(interval)); - tester.allNodesMakeAConfigRequestExcept(); - tester.failer.run(); - assertEquals( 3, tester.nodeRepository.getNodes(NodeType.host, Node.State.ready).size()); - assertEquals( 0, tester.nodeRepository.getNodes(NodeType.host, Node.State.failed).size()); - } - - - // Two ready nodes and a ready docker node die, but only 2 of those are failed out - tester.clock.advance(Duration.ofMinutes(180)); - Node dockerHost = tester.nodeRepository.getNodes(NodeType.host, Node.State.ready).iterator().next(); - tester.allNodesMakeAConfigRequestExcept(dockerHost); - tester.failer.run(); - assertEquals( 2, tester.nodeRepository.getNodes(NodeType.host, Node.State.ready).size()); - assertEquals( 1, tester.nodeRepository.getNodes(NodeType.host, Node.State.failed).size()); - } - - @Test - public void not_failed_without_config_requests_if_node_admin_on_host() { - NodeFailTester tester = NodeFailTester.withTwoApplications( - new ConfigserverConfig(new ConfigserverConfig.Builder().nodeAdminInContainer(false))); + public void docker_host_not_failed_without_config_requests() { + NodeFailTester tester = NodeFailTester.withTwoApplications(); // For a day all nodes work so nothing happens for (int minutes = 0, interval = 30; minutes < 24 * 60; minutes += interval) { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java index 44bdec75f51..c6f91b6a0b9 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InfraDeployerImplTest.java @@ -68,22 +68,13 @@ public class InfraDeployerImplTest { private final NodeType nodeType; public InfraDeployerImplTest(InfraApplicationApi application) { - when(duperModelInfraApi.getSupportedInfraApplications()).thenReturn(List.of(application)); + when(duperModelInfraApi.getInfraApplication(eq(application.getApplicationId()))).thenReturn(Optional.of(application)); this.application = application; this.nodeType = application.getCapacity().type(); this.infraDeployer = new InfraDeployerImpl(nodeRepository, provisioner, duperModelInfraApi); } @Test - public void remove_application_if_without_target_version() { - addNode(1, Node.State.active, Optional.of(target)); - when(duperModelInfraApi.infraApplicationIsActive(eq(application.getApplicationId()))).thenReturn(true); - infraDeployer.getDeployment(application.getApplicationId()).orElseThrow().activate(); - verify(duperModelInfraApi).infraApplicationRemoved(application.getApplicationId()); - verifyRemoved(1); - } - - @Test public void remove_application_if_without_nodes() { remove_application_without_nodes(true); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java index 3fbfc7c2487..6524292f48c 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java @@ -646,19 +646,12 @@ public class RestApiTest { assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"), "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.456\",\"controller\":\"6.123.456\"},\"osVersions\":{},\"dockerImages\":{}}"); - // Setting empty version fails - assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost", - Utf8.toBytes("{\"version\": null}"), - Request.Method.PATCH), - 400, - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Invalid target version: 0.0.0\"}"); - // Setting version for unsupported node type fails assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/tenant", Utf8.toBytes("{\"version\": \"6.123.456\"}"), Request.Method.PATCH), 400, - "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Cannot set version for type tenant\"}"); + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Target version for type tenant is not allowed\"}"); // Omitting version field fails assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost", @@ -685,6 +678,22 @@ public class RestApiTest { assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"), "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.1\",\"controller\":\"6.123.456\"},\"osVersions\":{},\"dockerImages\":{}}"); + // Setting empty version without force fails + assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost", + Utf8.toBytes("{\"version\": null}"), + Request.Method.PATCH), + 400, + "{\"error-code\":\"BAD_REQUEST\",\"message\":\"Cannot downgrade version without setting 'force'. Current target version: 6.123.1, attempted to set target version: 0.0.0\"}"); + + assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost", + Utf8.toBytes("{\"version\": null, \"force\": true}"), + Request.Method.PATCH), + "{\"message\":\"Set version to 0.0.0 for nodes of type confighost\"}"); + + // Verify version has been removed + assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"), + "{\"versions\":{\"config\":\"6.123.456\",\"controller\":\"6.123.456\"},\"osVersions\":{},\"dockerImages\":{}}"); + // Upgrade OS for confighost and host assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost", Utf8.toBytes("{\"osVersion\": \"7.5.2\"}"), @@ -697,7 +706,7 @@ public class RestApiTest { // OS versions are set assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/"), - "{\"versions\":{\"config\":\"6.123.456\",\"confighost\":\"6.123.1\",\"controller\":\"6.123.456\"},\"osVersions\":{\"host\":\"7.5.2\",\"confighost\":\"7.5.2\"},\"dockerImages\":{}}"); + "{\"versions\":{\"config\":\"6.123.456\",\"controller\":\"6.123.456\"},\"osVersions\":{\"host\":\"7.5.2\",\"confighost\":\"7.5.2\"},\"dockerImages\":{}}"); // Upgrade OS and Vespa together assertResponse(new Request("http://localhost:8080/nodes/v2/upgrade/confighost", |