summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/os/OsUpgrader.java
blob: 9abb0a2962835a194ce267339f9f98053e30bb50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.os;

import com.yahoo.config.provision.NodeType;
import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.node.History;

import java.time.Duration;
import java.time.Instant;

/**
 * Interface for an OS upgrader.
 *
 * @author mpolden
 */
public interface OsUpgrader {

    /** The duration we should leave new nodes along before scheduling OS upgrades */
    Duration gracePeriod = Duration.ofDays(30);

    /** Trigger upgrade to given target */
    void upgradeTo(OsVersionTarget target);

    /** Disable OS upgrade for all nodes of given type */
    void disableUpgrade(NodeType type);

    default boolean shouldUpgrade(Node node, Instant now) {
        return node.history().age(now).toSeconds() > gracePeriod.toSeconds();
    }

}