@Override
    protected double maintain() {
        if (!nodeRepository().zone().cloud().dynamicProvisioning()) return 1.0;

        NodeList candidates = nodeRepository().nodes().list()
                                              .parents()
                                              .not().deprovisioning();
        List<CloudAccount> cloudAccounts = candidates.stream()
                                                     .map(Node::cloudAccount)
                                                     .filter(cloudAccount -> !cloudAccount.isUnspecified())
                                                     .distinct()
                                                     .toList();
        Map<String, List<HostEvent>> eventsByHostId = hostProvisioner.hostEventsIn(cloudAccounts).stream()
                                                                     .collect(Collectors.groupingBy(HostEvent::hostId));
        Instant now = nodeRepository().clock().instant();
        for (var host : candidates) {
            List<HostEvent> events = eventsByHostId.get(host.id());
            if (events == null || events.isEmpty()) continue;

            LOG.info("Deprovisioning " + host + " affected by maintenance event" + (events.size() > 1 ? "s" : "") + ": " + events);
            nodeRepository().nodes().deprovision(host.hostname(), Agent.system, now);
        }
        return 1.0;
    }
Retire and deprovision hosts that are scheduled for maintenance by the cloud provider.

Only applies to dynamically provisioned zones, where a replacement host will be provisioned.

@author mpolden
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/HostRetirer.java