Search in sources :

Example 11 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class DockerFailTest method dockerFailTest.

@Test
public void dockerFailTest() throws Exception {
    try (DockerTester dockerTester = new DockerTester()) {
        ContainerNodeSpec containerNodeSpec = new ContainerNodeSpec.Builder().hostname("host1.test.yahoo.com").wantedDockerImage(new DockerImage("dockerImage")).nodeState(Node.State.active).nodeType("tenant").nodeFlavor("docker").wantedRestartGeneration(1L).currentRestartGeneration(1L).minCpuCores(1).minMainMemoryAvailableGb(1).minDiskAvailableGb(1).build();
        dockerTester.addContainerNodeSpec(containerNodeSpec);
        // Wait for node admin to be notified with node repo state and the docker container has been started
        while (dockerTester.nodeAdmin.getListOfHosts().size() == 0) {
            Thread.sleep(10);
        }
        dockerTester.callOrderVerifier.assertInOrder(1200, "createContainerCommand with DockerImage { imageId=dockerImage }, HostName: host1.test.yahoo.com, ContainerName { name=host1 }", "executeInContainerAsRoot with ContainerName { name=host1 }, args: [" + DockerTester.NODE_PROGRAM + ", resume]");
        dockerTester.dockerMock.deleteContainer(new ContainerName("host1"));
        dockerTester.callOrderVerifier.assertInOrder("deleteContainer with ContainerName { name=host1 }", "createContainerCommand with DockerImage { imageId=dockerImage }, HostName: host1.test.yahoo.com, ContainerName { name=host1 }", "executeInContainerAsRoot with ContainerName { name=host1 }, args: [" + DockerTester.NODE_PROGRAM + ", resume]");
    }
}
Also used : ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) Test(org.junit.Test)

Example 12 with DockerImage

use of com.yahoo.vespa.hosted.dockerapi.DockerImage in project vespa by vespa-engine.

the class NodeAgentImpl method updateNodeRepoWithCurrentAttributes.

private void updateNodeRepoWithCurrentAttributes(final ContainerNodeSpec nodeSpec) {
    final NodeAttributes currentNodeAttributes = new NodeAttributes().withRestartGeneration(nodeSpec.currentRestartGeneration.orElse(null)).withRebootGeneration(nodeSpec.currentRebootGeneration.orElse(0L)).withDockerImage(nodeSpec.currentDockerImage.orElse(new DockerImage(""))).withVespaVersion(nodeSpec.vespaVersion.orElse(""));
    final NodeAttributes wantedNodeAttributes = new NodeAttributes().withRestartGeneration(nodeSpec.wantedRestartGeneration.orElse(null)).withRebootGeneration(nodeSpec.wantedRebootGeneration.orElse(0L)).withDockerImage(nodeSpec.wantedDockerImage.filter(node -> containerState == UNKNOWN).orElse(new DockerImage(""))).withVespaVersion(nodeSpec.wantedVespaVersion.filter(node -> containerState == UNKNOWN).orElse(""));
    publishStateToNodeRepoIfChanged(currentNodeAttributes, wantedNodeAttributes);
}
Also used : DockerException(com.yahoo.vespa.hosted.dockerapi.DockerException) ContainerName(com.yahoo.vespa.hosted.dockerapi.ContainerName) Dimensions(com.yahoo.vespa.hosted.dockerapi.metrics.Dimensions) StorageMaintainer(com.yahoo.vespa.hosted.node.admin.maintenance.StorageMaintainer) Environment(com.yahoo.vespa.hosted.node.admin.component.Environment) Date(java.util.Date) PromptContainerData(com.yahoo.vespa.hosted.node.admin.containerdata.PromptContainerData) ThreadFactoryFactory(com.yahoo.concurrent.ThreadFactoryFactory) ProcessResult(com.yahoo.vespa.hosted.dockerapi.ProcessResult) SimpleDateFormat(java.text.SimpleDateFormat) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Node(com.yahoo.vespa.hosted.provision.Node) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) MetricReceiverWrapper(com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper) Future(java.util.concurrent.Future) Duration(java.time.Duration) Map(java.util.Map) ContainerData(com.yahoo.vespa.hosted.node.admin.containerdata.ContainerData) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) LinkedList(java.util.LinkedList) PrefixLogger(com.yahoo.vespa.hosted.node.admin.util.PrefixLogger) ConfigServerContainerData(com.yahoo.vespa.hosted.node.admin.containerdata.ConfigServerContainerData) NodeType(com.yahoo.config.provision.NodeType) DockerOperations(com.yahoo.vespa.hosted.node.admin.docker.DockerOperations) Container(com.yahoo.vespa.hosted.dockerapi.Container) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DimensionMetrics(com.yahoo.vespa.hosted.dockerapi.metrics.DimensionMetrics) NodeRepository(com.yahoo.vespa.hosted.node.admin.configserver.noderepository.NodeRepository) Instant(java.time.Instant) DockerExecTimeoutException(com.yahoo.vespa.hosted.dockerapi.DockerExecTimeoutException) Executors(java.util.concurrent.Executors) MotdContainerData(com.yahoo.vespa.hosted.node.admin.containerdata.MotdContainerData) UncheckedIOException(java.io.UncheckedIOException) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) List(java.util.List) ContainerNodeSpec(com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec) STARTING(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl.ContainerState.STARTING) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage) Docker(com.yahoo.vespa.hosted.dockerapi.Docker) ABSENT(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl.ContainerState.ABSENT) Orchestrator(com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.Orchestrator) UNKNOWN(com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAgentImpl.ContainerState.UNKNOWN) Clock(java.time.Clock) Optional(java.util.Optional) OrchestratorException(com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException) ContainerResources(com.yahoo.vespa.hosted.dockerapi.ContainerResources) DockerImage(com.yahoo.vespa.hosted.dockerapi.DockerImage)

Aggregations

DockerImage (com.yahoo.vespa.hosted.dockerapi.DockerImage)12 Test (org.junit.Test)8 ContainerNodeSpec (com.yahoo.vespa.hosted.node.admin.ContainerNodeSpec)7 ContainerName (com.yahoo.vespa.hosted.dockerapi.ContainerName)6 Container (com.yahoo.vespa.hosted.dockerapi.Container)3 OrchestratorException (com.yahoo.vespa.hosted.node.admin.configserver.orchestrator.OrchestratorException)2 NodeAttributes (com.yahoo.vespa.hosted.node.admin.nodeagent.NodeAttributes)2 Node (com.yahoo.vespa.hosted.provision.Node)2 InOrder (org.mockito.InOrder)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ThreadFactoryFactory (com.yahoo.concurrent.ThreadFactoryFactory)1 NodeType (com.yahoo.config.provision.NodeType)1 ContainerResources (com.yahoo.vespa.hosted.dockerapi.ContainerResources)1 Docker (com.yahoo.vespa.hosted.dockerapi.Docker)1 DockerException (com.yahoo.vespa.hosted.dockerapi.DockerException)1 DockerExecTimeoutException (com.yahoo.vespa.hosted.dockerapi.DockerExecTimeoutException)1 ProcessResult (com.yahoo.vespa.hosted.dockerapi.ProcessResult)1 DimensionMetrics (com.yahoo.vespa.hosted.dockerapi.metrics.DimensionMetrics)1 Dimensions (com.yahoo.vespa.hosted.dockerapi.metrics.Dimensions)1 MetricReceiverWrapper (com.yahoo.vespa.hosted.dockerapi.metrics.MetricReceiverWrapper)1