diff options
author | valerijf <valerijf@oath.com> | 2017-08-29 09:37:22 +0200 |
---|---|---|
committer | valerijf <valerijf@oath.com> | 2017-08-29 10:16:20 +0200 |
commit | d5f0e46c3433431c38fd0409023ecc119c1e3c9c (patch) | |
tree | 1d5d8ee32535a9291ab92fd329c85f97ec57e1ab /node-repository | |
parent | 9765dbd388ac09f0f5cd97c7fa7d5bbb06d60abf (diff) |
Write initial node state to history
Diffstat (limited to 'node-repository')
20 files changed, 242 insertions, 99 deletions
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 8f7317b28eb..3228e6ca17e 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 @@ -65,14 +65,15 @@ public class History { public History recordStateTransition(Node.State from, Node.State to, Agent agent, Instant at) { if (from == to) return this; switch (to) { - case ready: return this.withoutApplicationEvents().with(new Event(Event.Type.readied, agent, at)); - case active: return this.with(new Event(Event.Type.activated, agent, at)); - case inactive: return this.with(new Event(Event.Type.deactivated, agent, at)); - case reserved: return this.with(new Event(Event.Type.reserved, agent, at)); - case failed: return this.with(new Event(Event.Type.failed, agent, at)); - case dirty: return this.with(new Event(Event.Type.deallocated, agent, at)); - case parked: return this.with(new Event(Event.Type.parked, agent, at)); - default: return this; + case provisioned: return this.with(new Event(Event.Type.provisioned, agent, at)); + case ready: return this.withoutApplicationEvents().with(new Event(Event.Type.readied, agent, at)); + case active: return this.with(new Event(Event.Type.activated, agent, at)); + case inactive: return this.with(new Event(Event.Type.deactivated, agent, at)); + case reserved: return this.with(new Event(Event.Type.reserved, agent, at)); + case failed: return this.with(new Event(Event.Type.failed, agent, at)); + case dirty: return this.with(new Event(Event.Type.deallocated, agent, at)); + case parked: return this.with(new Event(Event.Type.parked, agent, at)); + default: return this; } } diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java index 651ee44415f..8f218d7e6fc 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/persistence/CuratorDatabaseClient.java @@ -84,6 +84,8 @@ public class CuratorDatabaseClient { for (Node node : nodes) { if (node.state() != expectedState) throw new IllegalArgumentException(node + " is not in the " + node.state() + " state"); + + node = node.with(node.history().recordStateTransition(null, expectedState, Agent.system, clock.instant())); curatorTransaction.add(CuratorOperations.create(toPath(node).getAbsolute(), nodeSerializer.toJson(node))); } transaction.commit(); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java index e27ca004862..704ded54479 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/InactiveAndFailedExpirerTest.java @@ -20,10 +20,12 @@ import com.yahoo.vespa.hosted.provision.testutils.MockDeployer; import org.junit.Test; import java.time.Duration; +import java.util.Arrays; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -62,8 +64,9 @@ public class InactiveAndFailedExpirerTest { // One node is set back to ready Node ready = tester.nodeRepository().setReady(Collections.singletonList(dirty.get(0))).get(0); - assertEquals("Allocated history is removed on readying", 1, ready.history().events().size()); - assertEquals(History.Event.Type.readied, ready.history().events().iterator().next().type()); + assertEquals("Allocated history is removed on readying", + Arrays.asList(History.Event.Type.provisioned, History.Event.Type.readied), + ready.history().events().stream().map(History.Event::type).collect(Collectors.toList())); // Dirty times out for the other one tester.advanceTime(Duration.ofMinutes(14)); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node1.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node1.json index 075ce1693cb..56523f58164 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node1.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node1.json @@ -37,6 +37,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json index 120d6286634..cb24df66cf8 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node10.json @@ -42,6 +42,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node11.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node11.json index 9b3feffad42..e0e899afbef 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node11.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node11.json @@ -1,26 +1,38 @@ { - "url":"http://localhost:8080/nodes/v2/node/host11.yahoo.com", - "id":"host11.yahoo.com", - "state":"provisioned", + "url": "http://localhost:8080/nodes/v2/node/host11.yahoo.com", + "id": "host11.yahoo.com", + "state": "provisioned", "type": "tenant", - "hostname":"host11.yahoo.com", - "parentHostname":"parent.host.yahoo.com", - "openStackId":"host11.yahoo.com", - "flavor":"docker", - "canonicalFlavor":"docker", - "minDiskAvailableGb":100.0, - "minMainMemoryAvailableGb":0.5, - "description":"Flavor-name-is-docker", - "minCpuCores":0.2, - "fastDisk":true, - "environment":"DOCKER_CONTAINER", - "rebootGeneration":0, - "currentRebootGeneration":0, - "failCount":0, - "hardwareFailure":false, - "wantToRetire":false, - "wantToDeprovision" : false, - "history":[], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":["::10","::11"] + "hostname": "host11.yahoo.com", + "parentHostname": "parent.host.yahoo.com", + "openStackId": "host11.yahoo.com", + "flavor": "docker", + "canonicalFlavor": "docker", + "minDiskAvailableGb": 100.0, + "minMainMemoryAvailableGb": 0.5, + "description": "Flavor-name-is-docker", + "minCpuCores": 0.2, + "fastDisk": true, + "environment": "DOCKER_CONTAINER", + "rebootGeneration": 0, + "currentRebootGeneration": 0, + "failCount": 0, + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + } + ], + "ipAddresses": [ + "::1", + "127.0.0.1" + ], + "additionalIpAddresses": [ + "::10", + "::11" + ] } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node2.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node2.json index 52864fc165c..30057dda1d7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node2.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node2.json @@ -37,6 +37,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node3.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node3.json index 4b7af75ee3c..eb13d077d7f 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node3.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node3.json @@ -22,6 +22,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json index 4082db74ff4..1fa8feb4586 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4-after-changes.json @@ -44,6 +44,11 @@ "wantToDeprovision" : true, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json index 10b5689f8ce..1e9138283f7 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node4.json @@ -42,6 +42,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5-after-changes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5-after-changes.json index bf81509b79a..1e1ea1a2445 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5-after-changes.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5-after-changes.json @@ -22,6 +22,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json index 1fc001fa224..f8b9fb72e5e 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node5.json @@ -26,6 +26,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node55.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node55.json index 3c483fa3412..7d07037d076 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node55.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node55.json @@ -7,19 +7,33 @@ "openStackId": "node55", "flavor": "default", "canonicalFlavor": "default", - "minDiskAvailableGb":400.0, - "minMainMemoryAvailableGb":16.0, - "description":"Flavor-name-is-default", - "minCpuCores":2.0, - "fastDisk":true, - "environment":"BARE_METAL", + "minDiskAvailableGb": 400.0, + "minMainMemoryAvailableGb": 16.0, + "description": "Flavor-name-is-default", + "minCpuCores": 2.0, + "fastDisk": true, + "environment": "BARE_METAL", "rebootGeneration": 1, "currentRebootGeneration": 0, "failCount": 0, - "hardwareFailure" : false, - "wantToRetire" : false, - "wantToDeprovision" : false, - "history":[{"event":"deallocated","at":123,"agent":"system"}], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":[] + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { + "event": "deallocated", + "at": 123, + "agent": "system" + } + ], + "ipAddresses": [ + "::1", + "127.0.0.1" + ], + "additionalIpAddresses": [] } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6-after-changes.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6-after-changes.json index adb7ce18c80..be9f3d78663 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6-after-changes.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6-after-changes.json @@ -27,16 +27,40 @@ }, "restartGeneration": 0, "currentRestartGeneration": 0, - "wantedDockerImage":"docker-registry.domain.tld:8080/dist/vespa:6.42.0", - "wantedVespaVersion":"6.42.0", + "wantedDockerImage": "docker-registry.domain.tld:8080/dist/vespa:6.42.0", + "wantedVespaVersion": "6.42.0", "rebootGeneration": 1, "currentRebootGeneration": 0, "failCount": 0, - "hardwareFailure" : false, - "wantToRetire" : false, - "wantToDeprovision" : false, - "history":[{"event":"readied","at":123,"agent":"system"},{"event":"reserved","at":123,"agent":"application"},{"event":"activated","at":123,"agent":"application"}], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":[], - "hardwareDivergence":"{\"actualCpuCores\":2}" + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { + "event": "readied", + "at": 123, + "agent": "system" + }, + { + "event": "reserved", + "at": 123, + "agent": "application" + }, + { + "event": "activated", + "at": 123, + "agent": "application" + } + ], + "ipAddresses": [ + "::1", + "127.0.0.1" + ], + "additionalIpAddresses": [], + "hardwareDivergence": "{\"actualCpuCores\":2}" } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6.json index 750ebbd695e..bd3b15f16ba 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node6.json @@ -37,6 +37,11 @@ "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node7.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node7.json index 9b52598cc67..b1c654b4e00 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node7.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node7.json @@ -7,19 +7,28 @@ "openStackId": "node7", "flavor": "default", "canonicalFlavor": "default", - "minDiskAvailableGb":400.0, - "minMainMemoryAvailableGb":16.0, - "description":"Flavor-name-is-default", - "minCpuCores":2.0, - "fastDisk":true, - "environment":"BARE_METAL", + "minDiskAvailableGb": 400.0, + "minMainMemoryAvailableGb": 16.0, + "description": "Flavor-name-is-default", + "minCpuCores": 2.0, + "fastDisk": true, + "environment": "BARE_METAL", "rebootGeneration": 0, "currentRebootGeneration": 0, "failCount": 0, - "hardwareFailure" : false, - "wantToRetire" : false, - "wantToDeprovision" : false, - "history":[], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":[] + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + } + ], + "ipAddresses": [ + "::1", + "127.0.0.1" + ], + "additionalIpAddresses": [] } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node8.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node8.json index 34fb9d13d81..0fa0bf6631d 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node8.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node8.json @@ -7,19 +7,27 @@ "openStackId": "host8.yahoo.com", "flavor": "default", "canonicalFlavor": "default", - "minDiskAvailableGb":400.0, - "minMainMemoryAvailableGb":16.0, - "description":"Flavor-name-is-default", - "minCpuCores":2.0, - "fastDisk":true, - "environment":"BARE_METAL", + "minDiskAvailableGb": 400.0, + "minMainMemoryAvailableGb": 16.0, + "description": "Flavor-name-is-default", + "minCpuCores": 2.0, + "fastDisk": true, + "environment": "BARE_METAL", "rebootGeneration": 0, "currentRebootGeneration": 0, "failCount": 0, - "hardwareFailure" : false, - "wantToRetire" : false, - "wantToDeprovision" : false, - "history":[], - "ipAddresses":["127.0.0.1"], - "additionalIpAddresses":[] + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + } + ], + "ipAddresses": [ + "127.0.0.1" + ], + "additionalIpAddresses": [] } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node9.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node9.json index f0695598264..43405f0aafc 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node9.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/node9.json @@ -7,19 +7,27 @@ "openStackId": "host9.yahoo.com", "flavor": "large-variant", "canonicalFlavor": "large", - "minDiskAvailableGb":2000.0, - "minMainMemoryAvailableGb":128.0, - "description":"Flavor-name-is-large-variant", - "minCpuCores":64.0, - "fastDisk":true, - "environment":"BARE_METAL", + "minDiskAvailableGb": 2000.0, + "minMainMemoryAvailableGb": 128.0, + "description": "Flavor-name-is-large-variant", + "minCpuCores": 64.0, + "fastDisk": true, + "environment": "BARE_METAL", "rebootGeneration": 0, "currentRebootGeneration": 0, "failCount": 0, - "hardwareFailure" : false, - "wantToRetire" : false, - "wantToDeprovision" : false, - "history":[], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":[] + "hardwareFailure": false, + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + } + ], + "ipAddresses": [ + "::1", + "127.0.0.1"], + "additionalIpAddresses": [] } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent1.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent1.json index da6742275a4..190dbc41f34 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent1.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent1.json @@ -17,15 +17,23 @@ "currentRebootGeneration": 0, "failCount": 0, "hardwareFailure": false, - "wantToRetire" : false, - "wantToDeprovision" : false, + "wantToRetire": false, + "wantToDeprovision": false, "history": [ { + "event": "provisioned", + "at": 123, + "agent": "system" + }, + { "event": "readied", "at": 123, "agent": "system" } ], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":[] + "ipAddresses": [ + "::1", + "127.0.0.1" + ], + "additionalIpAddresses": [] } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent2.json b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent2.json index 65735ecb37c..c7f6344d974 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent2.json +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/responses/parent2.json @@ -17,9 +17,18 @@ "currentRebootGeneration": 0, "failCount": 0, "hardwareFailure": false, - "wantToRetire" : false, - "wantToDeprovision" : false, - "history": [], - "ipAddresses":["::1", "127.0.0.1"], - "additionalIpAddresses":[] + "wantToRetire": false, + "wantToDeprovision": false, + "history": [ + { + "event": "provisioned", + "at": 123, + "agent": "system" + } + ], + "ipAddresses": [ + "::1", + "127.0.0.1" + ], + "additionalIpAddresses": [] } |