blob: c22bda8a5cf01f3fec1be3845377c57ab1be9f4a (
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
|
// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.provision.maintenance;
import com.yahoo.config.provision.NodeType;
import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeRepository;
import java.time.Duration;
/**
* This maintainer (de)activates OS upgrades according to Vespa upgrade status of nodes in this repository.
*
* If a node is upgrading to a new Vespa version, any ongoing OS upgrade will be paused for all nodes of that type. OS
* upgrades will resume once all nodes of that type have completed their Vespa upgrade.
*
* @author mpolden
*/
public class OsUpgradeActivator extends Maintainer {
public OsUpgradeActivator(NodeRepository nodeRepository, Duration interval) {
super(nodeRepository, interval);
}
@Override
protected void maintain() {
for (var nodeType : NodeType.values()) {
if (!nodeType.isDockerHost()) continue;
var active = canUpgradeOsOf(nodeType);
nodeRepository().osVersions().setActive(nodeType, active);
}
}
/** Returns whether to allow OS upgrade of nodes of given type */
private boolean canUpgradeOsOf(NodeType type) {
return nodeRepository().list()
.nodeType(type)
.state(Node.State.ready, Node.State.active) // Only consider nodes in long-term states
.changingVersion()
.asList()
.isEmpty();
}
}
|