use of com.yahoo.vespa.hosted.dockerapi.ContainerResources in project vespa by vespa-engine.
the class NodeAgentImpl method shouldRemoveContainer.
private Optional<String> shouldRemoveContainer(ContainerNodeSpec nodeSpec, Container existingContainer) {
final Node.State nodeState = nodeSpec.nodeState;
if (nodeState == Node.State.dirty || nodeState == Node.State.provisioned) {
return Optional.of("Node in state " + nodeState + ", container should no longer be running");
}
if (nodeSpec.wantedDockerImage.isPresent() && !nodeSpec.wantedDockerImage.get().equals(existingContainer.image)) {
return Optional.of("The node is supposed to run a new Docker image: " + existingContainer + " -> " + nodeSpec.wantedDockerImage.get());
}
if (!existingContainer.state.isRunning()) {
return Optional.of("Container no longer running");
}
ContainerResources wantedContainerResources = ContainerResources.from(nodeSpec.minCpuCores, nodeSpec.minMainMemoryAvailableGb);
if (!wantedContainerResources.equals(existingContainer.resources)) {
return Optional.of("Container should be running with different resource allocation, wanted: " + wantedContainerResources + ", actual: " + existingContainer.resources);
}
if (containerState == STARTING)
return Optional.of("Container failed to start");
return Optional.empty();
}
Aggregations