use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class FilebeatConfigProviderTest method it_does_not_generate_config_for_nodes_wihout_owner.
@Test
public void it_does_not_generate_config_for_nodes_wihout_owner() {
FilebeatConfigProvider filebeatConfigProvider = new FilebeatConfigProvider(getEnvironment(logstashNodes));
ContainerNodeSpec nodeSpec = new ContainerNodeSpec.Builder().nodeFlavor("flavor").nodeState(Node.State.active).nodeType("type").hostname("hostname").minCpuCores(1).minMainMemoryAvailableGb(1).minDiskAvailableGb(1).build();
Optional<String> config = filebeatConfigProvider.getConfig(nodeSpec);
assertFalse(config.isPresent());
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class MultiDockerTest method addAndWaitForNode.
private ContainerNodeSpec addAndWaitForNode(DockerTester tester, String hostName, DockerImage dockerImage) throws InterruptedException {
ContainerNodeSpec containerNodeSpec = new ContainerNodeSpec.Builder().hostname(hostName).wantedDockerImage(dockerImage).wantedVespaVersion("1.2.3").nodeState(Node.State.active).nodeType("tenant").nodeFlavor("docker").wantedRestartGeneration(1L).currentRestartGeneration(1L).minCpuCores(1).minMainMemoryAvailableGb(1).minDiskAvailableGb(1).build();
tester.addContainerNodeSpec(containerNodeSpec);
// Wait for node admin to be notified with node repo state and the docker container has been started
while (tester.nodeAdmin.getListOfHosts().size() != tester.nodeRepositoryMock.getNumberOfContainerSpecs()) {
Thread.sleep(10);
}
ContainerName containerName = ContainerName.fromHostname(hostName);
tester.callOrderVerifier.assertInOrder("createContainerCommand with " + dockerImage + ", HostName: " + hostName + ", " + containerName, "executeInContainerAsRoot with " + containerName + ", args: [" + DockerTester.NODE_PROGRAM + ", resume]");
return containerNodeSpec;
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class FilebeatConfigProviderTest method getConfigString.
private String getConfigString() {
FilebeatConfigProvider filebeatConfigProvider = new FilebeatConfigProvider(getEnvironment(logstashNodes));
ContainerNodeSpec nodeSpec = getNodeSpec(tenant, application, instance);
return filebeatConfigProvider.getConfig(nodeSpec).orElseThrow(() -> new RuntimeException("Failed to get filebeat config"));
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method failedNodeRunningContainerShouldStillBeRunning.
@Test
public void failedNodeRunningContainerShouldStillBeRunning() {
final long restartGeneration = 1;
final ContainerNodeSpec nodeSpec = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.failed).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(restartGeneration).currentRestartGeneration(restartGeneration).build();
NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(nodeSpec));
nodeAgent.converge();
verify(dockerOperations, never()).removeContainer(any(), any());
verify(orchestrator, never()).resume(any(String.class));
verify(nodeRepository, never()).updateNodeAttributes(eq(hostName), any());
}
use of com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec in project vespa by vespa-engine.
the class NodeAgentImplTest method containerIsRestartedIfFlavorChanged.
@Test
public void containerIsRestartedIfFlavorChanged() throws IOException {
final long wantedRestartGeneration = 1;
final long currentRestartGeneration = 1;
ContainerNodeSpec.Builder specBuilder = nodeSpecBuilder.wantedDockerImage(dockerImage).currentDockerImage(dockerImage).nodeState(Node.State.active).wantedVespaVersion(vespaVersion).vespaVersion(vespaVersion).wantedRestartGeneration(wantedRestartGeneration).currentRestartGeneration(currentRestartGeneration);
NodeAgentImpl nodeAgent = makeNodeAgent(dockerImage, true);
ContainerNodeSpec firstSpec = specBuilder.build();
ContainerNodeSpec secondSpec = specBuilder.minDiskAvailableGb(200).build();
ContainerNodeSpec thirdSpec = specBuilder.minCpuCores(4).build();
when(nodeRepository.getContainerNodeSpec(hostName)).thenReturn(Optional.of(firstSpec)).thenReturn(Optional.of(secondSpec)).thenReturn(Optional.of(thirdSpec));
when(dockerOperations.pullImageAsyncIfNeeded(any())).thenReturn(true);
when(storageMaintainer.getDiskUsageFor(eq(containerName))).thenReturn(Optional.of(201326592000L));
when(pathResolver.getApplicationStoragePathForHost()).thenReturn(Files.createTempDirectory("bar"));
nodeAgent.converge();
nodeAgent.converge();
nodeAgent.converge();
InOrder inOrder = inOrder(orchestrator, dockerOperations);
inOrder.verify(orchestrator).resume(any(String.class));
inOrder.verify(orchestrator).resume(any(String.class));
inOrder.verify(orchestrator).suspend(any(String.class));
inOrder.verify(dockerOperations).removeContainer(any(), any());
inOrder.verify(dockerOperations, times(1)).createContainer(eq(containerName), eq(thirdSpec));
inOrder.verify(dockerOperations).startContainer(eq(containerName), eq(thirdSpec));
inOrder.verify(orchestrator).resume(any(String.class));
}
Aggregations