diff options
author | Jon Bratseth <bratseth@oath.com> | 2021-03-29 19:05:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 19:05:29 +0200 |
commit | 3169f66bf208aa984605fa319046aabccc61c421 (patch) | |
tree | f0e601182898dac59e9966780f93c863dce3cd46 | |
parent | ede819b636301ede45d9facb3363b2eb7c926709 (diff) | |
parent | e6a9e45c30c65884d165d3b8e9083d89f1b718c9 (diff) |
Merge pull request #17228 from vespa-engine/freva/in-place-resize
Store resized event for Node
9 files changed, 30 insertions, 15 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java index 5135ae73ea1..1f4bd55525d 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/Node.java @@ -269,8 +269,10 @@ public final class Node implements Nodelike { } /** Returns a node with the flavor assigned to the given value */ - public Node with(Flavor flavor) { - return new Node(id, ipConfig, hostname, parentHostname, flavor, status, state, allocation, history, type, + public Node with(Flavor flavor, Agent agent, Instant instant) { + if (flavor.equals(this.flavor)) return this; + History updateHistory = history.with(new History.Event(History.Event.Type.resized, agent, instant)); + return new Node(id, ipConfig, hostname, parentHostname, flavor, status, state, allocation, updateHistory, type, reports, modelName, reservedTo, exclusiveTo, switchHostname); } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java index 755cd72be93..0c5a8ea1d9f 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/node/History.java @@ -158,6 +158,8 @@ public class History { down, // The node made a config request, indicating it is live requested, + // The node resources/flavor were changed + resized(false), // The node was rebooted rebooted(false), // The node upgraded its OS (implies a reboot) diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java index f08d7aa07e1..9d36be67431 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializer.java @@ -420,6 +420,7 @@ public class NodeSerializer { case "deallocated" : return History.Event.Type.deallocated; case "down" : return History.Event.Type.down; case "requested" : return History.Event.Type.requested; + case "resized" : return History.Event.Type.resized; case "rebooted" : return History.Event.Type.rebooted; case "osUpgraded" : return History.Event.Type.osUpgraded; case "firmwareVerified" : return History.Event.Type.firmwareVerified; @@ -444,6 +445,7 @@ public class NodeSerializer { case deallocated : return "deallocated"; case down : return "down"; case requested: return "requested"; + case resized: return "resized"; case rebooted: return "rebooted"; case osUpgraded: return "osUpgraded"; case firmwareVerified: return "firmwareVerified"; diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java index 49eb44a4ec0..03db7e0e7e5 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Activator.java @@ -14,6 +14,7 @@ import com.yahoo.vespa.hosted.provision.NodeMutex; import com.yahoo.vespa.hosted.provision.NodeRepository; import com.yahoo.vespa.hosted.provision.applications.Application; import com.yahoo.vespa.hosted.provision.applications.ScalingEvent; +import com.yahoo.vespa.hosted.provision.node.Agent; import com.yahoo.vespa.hosted.provision.node.Allocation; import java.time.Instant; @@ -216,7 +217,7 @@ class Activator { HostSpec hostSpec = getHost(node.hostname(), hosts); node = hostSpec.membership().get().retired() ? node.retire(at) : node.unretire(); if (! hostSpec.advertisedResources().equals(node.resources())) // A resized node - node = node.with(new Flavor(hostSpec.advertisedResources())); + node = node.with(new Flavor(hostSpec.advertisedResources()), Agent.application, at); Allocation allocation = node.allocation().get() .with(hostSpec.membership().get()) .withRequestedResources(hostSpec.requestedResources() 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 e014b50a25f..3d3a54774e4 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 @@ -272,7 +272,8 @@ class NodeAllocation { NodeResources hostResources = allNodes.parentOf(node).get().flavor().resources(); return node.with(new Flavor(requestedNodes.resources().get() .with(hostResources.diskSpeed()) - .with(hostResources.storageType()))); + .with(hostResources.storageType())), + Agent.application, nodeRepository.clock().instant()); } private Node setCluster(ClusterSpec cluster, Node node) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java index ea951798da0..e8fa4f04eed 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/restapi/NodePatcher.java @@ -132,7 +132,7 @@ public class NodePatcher implements AutoCloseable { case "failCount" : return node.with(node.status().withFailCount(asLong(value).intValue())); case "flavor" : - return node.with(nodeFlavors.getFlavorOrThrow(asString(value))); + return node.with(nodeFlavors.getFlavorOrThrow(asString(value)), Agent.operator, clock.instant()); case "parentHostname" : return node.withParentHostname(asString(value)); case "ipAddresses" : @@ -152,19 +152,19 @@ public class NodePatcher implements AutoCloseable { return node.withOpenStackId(asString(value)); case "diskGb": case "minDiskAvailableGb": - return node.with(node.flavor().with(node.flavor().resources().withDiskGb(value.asDouble()))); + return node.with(node.flavor().with(node.flavor().resources().withDiskGb(value.asDouble())), Agent.operator, clock.instant()); case "memoryGb": case "minMainMemoryAvailableGb": - return node.with(node.flavor().with(node.flavor().resources().withMemoryGb(value.asDouble()))); + return node.with(node.flavor().with(node.flavor().resources().withMemoryGb(value.asDouble())), Agent.operator, clock.instant()); case "vcpu": case "minCpuCores": - return node.with(node.flavor().with(node.flavor().resources().withVcpu(value.asDouble()))); + return node.with(node.flavor().with(node.flavor().resources().withVcpu(value.asDouble())), Agent.operator, clock.instant()); case "fastDisk": - return node.with(node.flavor().with(node.flavor().resources().with(value.asBool() ? fast : slow))); + return node.with(node.flavor().with(node.flavor().resources().with(value.asBool() ? fast : slow)), Agent.operator, clock.instant()); case "remoteStorage": - return node.with(node.flavor().with(node.flavor().resources().with(value.asBool() ? remote : local))); + return node.with(node.flavor().with(node.flavor().resources().with(value.asBool() ? remote : local)), Agent.operator, clock.instant()); case "bandwidthGbps": - return node.with(node.flavor().with(node.flavor().resources().withBandwidthGbps(value.asDouble()))); + return node.with(node.flavor().with(node.flavor().resources().withBandwidthGbps(value.asDouble())), Agent.operator, clock.instant()); case "modelName": return value.type() == Type.NIX ? node.withoutModelName() : node.withModelName(asString(value)); case "requiredDiskSpeed": diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java index 0a852bbab56..881646fa546 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/persistence/NodeSerializerTest.java @@ -85,7 +85,7 @@ public class NodeSerializerTest { assertEquals(1, node.history().events().size()); node = node.withRestart(new Generation(1, 2)); node = node.withReboot(new Generation(3, 4)); - node = node.with(FlavorConfigBuilder.createDummies("large").getFlavorOrThrow("large")); + node = node.with(FlavorConfigBuilder.createDummies("large").getFlavorOrThrow("large"), Agent.system, clock.instant()); node = node.with(node.status().withVespaVersion(Version.fromString("1.2.3"))); node = node.with(node.status().withIncreasedFailCount().withIncreasedFailCount()); node = node.with(NodeType.tenant); @@ -105,7 +105,7 @@ public class NodeSerializerTest { assertEquals(node.allocation().get().membership(), copy.allocation().get().membership()); assertEquals(node.allocation().get().requestedResources(), copy.allocation().get().requestedResources()); assertEquals(node.allocation().get().isRemovable(), copy.allocation().get().isRemovable()); - assertEquals(1, copy.history().events().size()); + assertEquals(2, copy.history().events().size()); assertEquals(clock.instant().truncatedTo(MILLIS), copy.history().event(History.Event.Type.reserved).get().at()); assertEquals(NodeType.tenant, copy.type()); } @@ -283,12 +283,13 @@ public class NodeSerializerTest { public void flavor_overrides_serialization() { Node node = createNode(); assertEquals(20, node.flavor().resources().diskGb(), 0); - node = node.with(node.flavor().with(FlavorOverrides.ofDisk(1234))); + node = node.with(node.flavor().with(FlavorOverrides.ofDisk(1234)), Agent.system, clock.instant()); assertEquals(1234, node.flavor().resources().diskGb(), 0); Node copy = nodeSerializer.fromJson(Node.State.provisioned, nodeSerializer.toJson(node)); assertEquals(1234, copy.flavor().resources().diskGb(), 0); assertEquals(node, copy); + assertTrue(node.history().event(History.Event.Type.resized).isPresent()); } @Test diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java index 0db5453c963..889fd537740 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java @@ -760,7 +760,8 @@ public class ProvisioningTest { // Pick out a random application node and make it's parent larger, this will make it the spare host NodeList nodes = tester.nodeRepository().nodes().list(); Node randomNode = nodes.owner(application).shuffle(new Random()).first().get(); - tester.nodeRepository().nodes().write(nodes.parentOf(randomNode).get().with(new Flavor(new NodeResources(2, 10, 20, 8))), () -> {}); + tester.nodeRepository().nodes().write(nodes.parentOf(randomNode).get() + .with(new Flavor(new NodeResources(2, 10, 20, 8)), Agent.system, tester.nodeRepository().clock().instant()), () -> {}); // Re-deploy application with 1 node less, the retired node should be on the spare host tester.deploy(application, spec, Capacity.from(new ClusterResources(5, 1, defaultResources))); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-after-changes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-after-changes.json index 77e1fb1e16d..a2f43480605 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-after-changes.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/responses/node4-after-changes.json @@ -70,6 +70,11 @@ "agent": "system" }, { + "event": "resized", + "at": 123, + "agent": "operator" + }, + { "event": "wantToRetire", "at": 123, "agent": "operator" |