Search in sources :

Example 1 with History

use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.

the class Node method withCurrentRebootGeneration.

/**
 * Returns a copy of this node with the current reboot generation set to the given number at the given instant
 */
public Node withCurrentRebootGeneration(long generation, Instant instant) {
    Status newStatus = status().withReboot(status().reboot().withCurrent(generation));
    History newHistory = history();
    if (generation > status().reboot().current())
        newHistory = history.with(new History.Event(History.Event.Type.rebooted, Agent.system, instant));
    return this.with(newStatus).with(newHistory);
}
Also used : Status(com.yahoo.vespa.hosted.provision.node.Status) History(com.yahoo.vespa.hosted.provision.node.History)

Example 2 with History

use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.

the class NodesResponse method toSlime.

private void toSlime(History history, Cursor array) {
    for (History.Event event : history.events()) {
        Cursor object = array.addObject();
        object.setString("event", event.type().name());
        object.setLong("at", event.at().toEpochMilli());
        object.setString("agent", event.agent().name());
    }
}
Also used : History(com.yahoo.vespa.hosted.provision.node.History) Cursor(com.yahoo.slime.Cursor)

Example 3 with History

use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.

the class NodesResponse method toSlime.

private void toSlime(Node node, boolean allFields, Cursor object) {
    object.setString("url", nodeParentUrl + node.hostname());
    if (!allFields)
        return;
    object.setString("id", node.id());
    object.setString("state", NodeStateSerializer.wireNameOf(node.state()));
    object.setString("type", node.type().name());
    object.setString("hostname", node.hostname());
    object.setString("type", toString(node.type()));
    if (node.parentHostname().isPresent()) {
        object.setString("parentHostname", node.parentHostname().get());
    }
    object.setString("openStackId", node.openStackId());
    object.setString("flavor", node.flavor().name());
    object.setString("canonicalFlavor", node.flavor().canonicalName());
    object.setDouble("minDiskAvailableGb", node.flavor().getMinDiskAvailableGb());
    object.setDouble("minMainMemoryAvailableGb", node.flavor().getMinMainMemoryAvailableGb());
    if (node.flavor().getDescription() != null && !node.flavor().getDescription().isEmpty())
        object.setString("description", node.flavor().getDescription());
    object.setDouble("minCpuCores", node.flavor().getMinCpuCores());
    if (node.flavor().cost() > 0)
        object.setLong("cost", node.flavor().cost());
    object.setBool("fastDisk", node.flavor().hasFastDisk());
    object.setString("environment", node.flavor().getType().name());
    if (node.allocation().isPresent()) {
        toSlime(node.allocation().get().owner(), object.setObject("owner"));
        toSlime(node.allocation().get().membership(), object.setObject("membership"));
        object.setLong("restartGeneration", node.allocation().get().restartGeneration().wanted());
        object.setLong("currentRestartGeneration", node.allocation().get().restartGeneration().current());
        object.setString("wantedDockerImage", nodeRepository.dockerImage().withTag(node.allocation().get().membership().cluster().vespaVersion()).asString());
        object.setString("wantedVespaVersion", node.allocation().get().membership().cluster().vespaVersion().toFullString());
        try {
            object.setBool("allowedToBeDown", orchestrator.getNodeStatus(new HostName(node.hostname())) == HostStatus.ALLOWED_TO_BE_DOWN);
        } catch (HostNameNotFoundException e) {
        /* ok */
        }
    }
    object.setLong("rebootGeneration", node.status().reboot().wanted());
    object.setLong("currentRebootGeneration", node.status().reboot().current());
    node.status().vespaVersion().filter(version -> !version.isEmpty()).ifPresent(version -> {
        object.setString("vespaVersion", version.toFullString());
        object.setString("currentDockerImage", nodeRepository.dockerImage().withTag(version).asString());
        // TODO: Remove these when they are no longer read
        object.setString("hostedVersion", version.toFullString());
        object.setString("convergedStateVersion", version.toFullString());
    });
    object.setLong("failCount", node.status().failCount());
    object.setBool("hardwareFailure", node.status().hardwareFailureDescription().isPresent());
    node.status().hardwareFailureDescription().ifPresent(failure -> object.setString("hardwareFailureDescription", failure));
    object.setBool("wantToRetire", node.status().wantToRetire());
    object.setBool("wantToDeprovision", node.status().wantToDeprovision());
    toSlime(node.history(), object.setArray("history"));
    ipAddressesToSlime(node.ipAddresses(), object.setArray("ipAddresses"));
    ipAddressesToSlime(node.additionalIpAddresses(), object.setArray("additionalIpAddresses"));
    node.status().hardwareDivergence().ifPresent(hardwareDivergence -> object.setString("hardwareDivergence", hardwareDivergence));
}
Also used : NodeFilter(com.yahoo.vespa.hosted.provision.node.filter.NodeFilter) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException) OutputStream(java.io.OutputStream) Cursor(com.yahoo.slime.Cursor) ApplicationId(com.yahoo.config.provision.ApplicationId) ClusterMembership(com.yahoo.config.provision.ClusterMembership) NodeType(com.yahoo.config.provision.NodeType) Slime(com.yahoo.slime.Slime) HttpRequest(com.yahoo.container.jdisc.HttpRequest) Set(java.util.Set) IOException(java.io.IOException) Orchestrator(com.yahoo.vespa.orchestrator.Orchestrator) Node(com.yahoo.vespa.hosted.provision.Node) NodeRepository(com.yahoo.vespa.hosted.provision.NodeRepository) List(java.util.List) History(com.yahoo.vespa.hosted.provision.node.History) HostName(com.yahoo.vespa.applicationmodel.HostName) SlimeUtils(com.yahoo.vespa.config.SlimeUtils) HostStatus(com.yahoo.vespa.orchestrator.status.HostStatus) URI(java.net.URI) HttpResponse(com.yahoo.container.jdisc.HttpResponse) HostName(com.yahoo.vespa.applicationmodel.HostName) HostNameNotFoundException(com.yahoo.vespa.orchestrator.HostNameNotFoundException)

Example 4 with History

use of com.yahoo.vespa.hosted.provision.node.History in project vespa by vespa-engine.

the class NodeFailer method updateNodeLivenessEventsForReadyNodes.

private void updateNodeLivenessEventsForReadyNodes() {
    // We do this here ("lazily") to avoid writing to zk for each config request.
    for (Node node : nodeRepository().getNodes(Node.State.ready)) {
        Optional<Instant> lastLocalRequest = hostLivenessTracker.lastRequestFrom(node.hostname());
        if (!lastLocalRequest.isPresent())
            continue;
        Optional<History.Event> recordedRequest = node.history().event(History.Event.Type.requested);
        if (!recordedRequest.isPresent() || recordedRequest.get().at().isBefore(lastLocalRequest.get())) {
            History updatedHistory = node.history().with(new History.Event(History.Event.Type.requested, Agent.system, lastLocalRequest.get()));
            nodeRepository().write(node.with(updatedHistory));
        }
    }
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) Instant(java.time.Instant) History(com.yahoo.vespa.hosted.provision.node.History)

Aggregations

History (com.yahoo.vespa.hosted.provision.node.History)4 Cursor (com.yahoo.slime.Cursor)2 Node (com.yahoo.vespa.hosted.provision.Node)2 ApplicationId (com.yahoo.config.provision.ApplicationId)1 ClusterMembership (com.yahoo.config.provision.ClusterMembership)1 NodeType (com.yahoo.config.provision.NodeType)1 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 HttpResponse (com.yahoo.container.jdisc.HttpResponse)1 Slime (com.yahoo.slime.Slime)1 HostName (com.yahoo.vespa.applicationmodel.HostName)1 SlimeUtils (com.yahoo.vespa.config.SlimeUtils)1 NodeRepository (com.yahoo.vespa.hosted.provision.NodeRepository)1 Status (com.yahoo.vespa.hosted.provision.node.Status)1 NodeFilter (com.yahoo.vespa.hosted.provision.node.filter.NodeFilter)1 HostNameNotFoundException (com.yahoo.vespa.orchestrator.HostNameNotFoundException)1 Orchestrator (com.yahoo.vespa.orchestrator.Orchestrator)1 HostStatus (com.yahoo.vespa.orchestrator.status.HostStatus)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1