blob: b1eace947ccd5bca6a0812a2be975aa62c502a39 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation.change;
import com.yahoo.config.model.api.ConfigChangeAction;
import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.config.application.api.ValidationId;
import com.yahoo.vespa.model.container.ApplicationContainer;
import com.yahoo.vespa.model.container.ApplicationContainerCluster;
import com.yahoo.vespa.model.content.cluster.ContentCluster;
import java.util.ArrayList;
import java.util.List;
/**
* Checks that this does not remove a content cluster (or changes its id)
* as that means losing all data of that cluster.
*
* @author bratseth
*/
public class ContentClusterRemovalValidator implements ChangeValidator {
@Override
public List<ConfigChangeAction> validate(VespaModel current, VespaModel next, DeployState deployState) {
List<ConfigChangeAction> actions = new ArrayList<>();
for (String currentClusterId : current.getContentClusters().keySet()) {
ContentCluster nextCluster = next.getContentClusters().get(currentClusterId);
if (nextCluster == null) {
deployState.validationOverrides().invalid(ValidationId.contentClusterRemoval,
"Content cluster '" + currentClusterId + "' is removed. " +
"This will cause loss of all data in this cluster",
deployState.now());
// If we allow the removal, we must restart all containers to ensure mbus is OK.
for (ApplicationContainerCluster cluster : next.getContainerClusters().values()) {
actions.add(new VespaRestartAction(cluster.id(),
"Content cluster '" + currentClusterId + "' has been removed",
cluster.getContainers().stream().map(ApplicationContainer::getServiceInfo).toList()));
}
}
}
return actions;
}
}
|