diff options
author | Martin Polden <mpolden@mpolden.no> | 2021-03-04 13:57:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-04 13:57:05 +0100 |
commit | aae1415e63d86c5994653e1e559b198f1f751edc (patch) | |
tree | c08de21a6d332ca41cbe019838c541d35fa76411 /node-repository | |
parent | b25d9cb762a2cf4e9f1db4363a4a38ab480aa44c (diff) | |
parent | 4411647e3a6400ec1e1a95e0e4cf0658ab12d2c7 (diff) |
Merge pull request #16790 from vespa-engine/mpolden/ignore-self
Ignore own index when deciding provision indices
Diffstat (limited to 'node-repository')
3 files changed, 20 insertions, 5 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java index 7e4dc8d5108..940c867dea5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java @@ -102,7 +102,7 @@ public class GroupPreparer { osVersion = nodeRepository.osVersions().targetFor(hostType).orElse(Version.emptyVersion); } HostSharing sharing = hostSharing(requestedNodes, hostType); - List<ProvisionedHost> provisionedHosts = allocation.nodeDeficit() + List<ProvisionedHost> provisionedHosts = allocation.hostDeficit() .map(deficit -> { return hostProvisioner.get().provisionHosts(allocation.provisionIndices(deficit.getCount()), hostType, diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java index f6e0ede4e7d..a52d5c9444b 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java @@ -290,12 +290,12 @@ class NodeAllocation { } /** - * Returns {@link FlavorCount} describing the node deficit for the given {@link NodeSpec}. + * Returns {@link FlavorCount} describing the host deficit for the given {@link NodeSpec}. * * @return empty if the requested spec is already fulfilled. Otherwise returns {@link FlavorCount} containing the - * flavor and node count required to cover the deficit. + * flavor and host count required to cover the deficit. */ - Optional<FlavorCount> nodeDeficit() { + Optional<FlavorCount> hostDeficit() { if (nodeType() != NodeType.config && nodeType() != NodeType.tenant) { return Optional.empty(); // Requests for these node types never have a deficit } @@ -327,6 +327,14 @@ class NodeAllocation { indices.add(i); } } + // Ignore our own index as we should never try to provision ourself. This can happen in the following scenario: + // - cfg1 has been deprovisioned + // - cfg2 has triggered provisioning of a new cfg1 + // - cfg1 is starting and redeploys its infrastructure application during bootstrap. A deficit is detected + // (itself, because cfg1 is only added to the repository *after* it is up) + // - cfg1 tries to provision a new host for itself + Integer myIndex = parseIndex(com.yahoo.net.HostName.getLocalhost()); + indices.remove(myIndex); return indices; } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java index f47bcd0d550..337bbb0cbb4 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/DynamicProvisioningMaintainerTest.java @@ -16,6 +16,7 @@ import com.yahoo.config.provision.ParentHostUnavailableException; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.Zone; +import com.yahoo.net.HostName; import com.yahoo.vespa.flags.Flags; import com.yahoo.vespa.flags.InMemoryFlagSource; import com.yahoo.vespa.flags.PermanentFlags; @@ -480,7 +481,13 @@ public class DynamicProvisioningMaintainerTest { dynamicProvisioningTester.maintainer.maintain(); assertEquals(2, tester.nodeRepository().nodes().list().nodeType(NodeType.confighost).size()); - // Next deployment starts provisioning a new host and child + // Deployment by the removed host has no effect + HostName.setHostNameForTestingOnly("cfg2.example.com"); + tester.prepareAndActivateInfraApplication(configSrvApp, NodeType.config); + assertEquals(List.of(), dynamicProvisioningTester.hostProvisioner.provisionedHosts()); + + // Deployment on another config server starts provisioning a new host and child + HostName.setHostNameForTestingOnly("cfg3.example.com"); try { tester.prepareAndActivateInfraApplication(configSrvApp, NodeType.config); fail("Expected provisioning to fail"); |