summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/HostProvisioner.java
blob: 9b765adca89b31a18e4ad647975269a1acaa2d60 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.provisioning;

import com.yahoo.component.Version;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.CloudAccount;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.HostEvent;
import com.yahoo.config.provision.NodeResources;
import com.yahoo.config.provision.NodeType;
import com.yahoo.vespa.hosted.provision.Node;

import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
 * A service which supports provisioning container hosts dynamically.
 *
 * @author freva
 */
public interface HostProvisioner {

    enum HostSharing {
        /** The host must be provisioned exclusively for the applicationId */
        exclusive,

        /** The host must be provisioned to be shared with other applications. */
        shared,

        /** The client has no requirements on whether the host must be provisioned exclusively or shared. */
        any
    }

    /**
     * Schedule provisioning of a given number of hosts.
     *
     * @param provisionIndices list of unique provision indices which will be used to generate the node hostnames
     *                         on the form of <code>[prefix][index].[domain]</code>
     * @param hostType The host type to provision
     * @param resources the resources needed per node - the provisioned host may be significantly larger
     * @param applicationId id of the application that will own the provisioned host
     * @param osVersion the OS version to use. If this version does not exist, implementations may choose a suitable
     *                  fallback version.
     * @param sharing puts requirements on sharing or exclusivity of the host to be provisioned.
     * @param clusterType provision host exclusively for this cluster type
     * @param cloudAccount the cloud account to use
     * @return list of {@link ProvisionedHost} describing the provisioned nodes
     */
    List<ProvisionedHost> provisionHosts(List<Integer> provisionIndices,
                                         NodeType hostType,
                                         NodeResources resources,
                                         ApplicationId applicationId,
                                         Version osVersion,
                                         HostSharing sharing,
                                         Optional<ClusterSpec.Type> clusterType,
                                         Optional<CloudAccount> cloudAccount);

    /**
     * Continue provisioning of given list of Nodes.
     *
     * @param host the host to provision
     * @param children list of all the nodes that run on the given host
     * @return a subset of {@code host} and {@code children} where the values have been modified and should
     * be written back to node-repository.
     * @throws FatalProvisioningException if the provisioning has irrecoverably failed and the input nodes
     * should be deleted from node-repo.
     */
    List<Node> provision(Node host, Set<Node> children) throws FatalProvisioningException;

    /**
     * Deprovisions a given host and resources associated with it and its children (such as DNS entries).
     * This method will only perform the actual deprovisioning of the host and does NOT:
     *  - verify whether it is safe to do
     *  - clean up config server references to this node or any of its children
     * Therefore, this method should probably only be called for hosts that have no children.
     *
     * @param host host to deprovision.
     */
    void deprovision(Node host);

    /** Replace the root (OS) disk of host. Implementations of this are expected to be idempotent.
     *
     * @return the updated node object
     */
    Node replaceRootDisk(Node host);

    /**
     * Returns the maintenance events scheduled for hosts in this zone, in given cloud accounts. Host events in the
     * zone's default cloud account are always included.
     */
    List<HostEvent> hostEventsIn(List<CloudAccount> cloudAccounts);

}