diff options
4 files changed, 6 insertions, 37 deletions
diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/Container.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/Container.java index 062f0503615..7f47b638dde 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/Container.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/Container.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.dockerapi; -import java.time.Instant; import java.util.Objects; /** @@ -13,31 +12,18 @@ public class Container { public final ContainerName name; public final State state; public final int pid; - public final Instant created; public Container( final String hostname, final DockerImage image, final ContainerName containerName, final State state, - final int pid, - final String created) { + final int pid) { this.hostname = hostname; this.image = image; this.name = containerName; this.state = state; this.pid = pid; - this.created = Instant.parse(created); - } - - // For testing only - public Container( - final String hostname, - final DockerImage image, - final ContainerName containerName, - final State state, - final int pid) { - this(hostname, image, containerName, state, pid, "2017-02-13T13:45:12.133713371Z"); } @Override @@ -49,8 +35,7 @@ public class Container { return Objects.equals(hostname, other.hostname) && Objects.equals(image, other.image) && Objects.equals(name, other.name) - && Objects.equals(pid, other.pid) - && Objects.equals(created, other.created); + && Objects.equals(pid, other.pid); } @Override @@ -66,7 +51,6 @@ public class Container { + " name=" + name + " state=" + state + " pid=" + pid - + " created=" + created + "}"; } diff --git a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java index bd06794c733..2f8007f6e91 100644 --- a/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java +++ b/docker-api/src/main/java/com/yahoo/vespa/hosted/dockerapi/DockerImpl.java @@ -375,8 +375,7 @@ public class DockerImpl implements Docker { new DockerImage(response.getConfig().getImage()), new ContainerName(decode(response.getName())), Container.State.valueOf(response.getState().getStatus().toUpperCase()), - response.getState().getPid(), - response.getCreated() + response.getState().getPid() )) .map(Stream::of) .orElse(Stream.empty()); diff --git a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java index 3c8327d1836..87d4509d7c9 100644 --- a/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java +++ b/node-admin/src/main/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImpl.java @@ -96,7 +96,7 @@ public class NodeAgentImpl implements NodeAgent { // The attributes of the last successful node repo attribute update for this node. Used to avoid redundant calls. private NodeAttributes lastAttributesSet = null; private ContainerNodeSpec lastNodeSpec = null; - private CpuUsageReporter lastCpuMetric; + private CpuUsageReporter lastCpuMetric = new CpuUsageReporter(); public NodeAgentImpl( final String hostName, @@ -134,12 +134,8 @@ public class NodeAgentImpl implements NodeAgent { }; // If the container is already running, initialize vespaVersion and lastCpuMetric - lastCpuMetric = new CpuUsageReporter(clock.instant()); dockerOperations.getContainer(containerName) .ifPresent(container -> { - if (container.state.isRunning()) { - lastCpuMetric = new CpuUsageReporter(container.created); - } containerState = RUNNING_HOWEVER_RESUME_SCRIPT_NOT_RUN; logger.info("Container is already running, setting containerState to " + containerState); }); @@ -260,7 +256,7 @@ public class NodeAgentImpl implements NodeAgent { private void startContainer(ContainerNodeSpec nodeSpec) { aclMaintainer.ifPresent(AclMaintainer::run); dockerOperations.startContainer(containerName, nodeSpec); - lastCpuMetric = new CpuUsageReporter(clock.instant()); + lastCpuMetric = new CpuUsageReporter(); currentFilebeatRestarter = filebeatRestarter.scheduleWithFixedDelay(() -> serviceRestarter.accept("filebeat"), 1, 1, TimeUnit.DAYS); storageMaintainer.ifPresent(maintainer -> { @@ -626,11 +622,6 @@ public class NodeAgentImpl implements NodeAgent { class CpuUsageReporter { private long totalContainerUsage = 0; private long totalSystemUsage = 0; - private final Instant created; - - CpuUsageReporter(Instant created) { - this.created = created; - } double getCpuUsagePercentage(long currentContainerUsage, long currentSystemUsage) { long deltaSystemUsage = currentSystemUsage - totalSystemUsage; @@ -641,10 +632,6 @@ public class NodeAgentImpl implements NodeAgent { totalSystemUsage = currentSystemUsage; return cpuUsagePct; } - - long getUptime() { - return Duration.between(created, clock.instant()).getSeconds(); - } } // TODO: Also skip orchestration if we're downgrading in test/staging diff --git a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java index d71d130f9b8..91d9b382b7c 100644 --- a/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java +++ b/node-admin/src/test/java/com/yahoo/vespa/hosted/node/admin/nodeagent/NodeAgentImplTest.java @@ -573,8 +573,7 @@ public class NodeAgentImplTest { dockerImage, containerName, isRunning ? Container.State.RUNNING : Container.State.EXITED, - isRunning ? 1 : 0, - clock.instant().toString())) : + isRunning ? 1 : 0)) : Optional.empty(); when(dockerOperations.getContainerStats(any())).thenReturn(Optional.of(emptyContainerStats)); |