use of org.onosproject.security.AppPermission.Type.CLUSTER_EVENT in project onos by opennetworkinglab.
the class UpgradeManager method handleClusterEvent.
/**
* Handles a cluster event.
*
* @param event the cluster event
*/
protected void handleClusterEvent(ClusterEvent event) {
checkPermission(CLUSTER_EVENT);
// If an instance was deactivated, check whether we need to roll back the upgrade.
if (event.type() == ClusterEvent.Type.INSTANCE_DEACTIVATED) {
Upgrade upgrade = getState();
if (upgrade.status().upgraded()) {
// Get the upgraded subset of the cluster and check whether the down node is a member
// of the upgraded subset. If so, roll back the upgrade to tolerate the failure.
Set<NodeId> upgradedNodes = clusterService.getNodes().stream().map(ControllerNode::id).filter(id -> clusterService.getVersion(id).equals(upgrade.target())).collect(Collectors.toSet());
if (upgradedNodes.contains(event.subject().id())) {
log.warn("Upgrade failure detected: rolling back upgrade");
rollback();
}
}
}
}
Aggregations