private boolean markWantToRetire(String hostname) {
        Optional<NodeMutex> optionalNodeMutex = nodeRepository().nodes().lockAndGet(hostname);
        if (optionalNodeMutex.isEmpty()) return false;
        try (var nodeMutex = optionalNodeMutex.get()) {
            Node retiredNode = nodeMutex.node().withWantToRetire(true, Agent.SpareCapacityMaintainer,
                                                                 nodeRepository().clock().instant());
            nodeRepository().nodes().write(retiredNode, nodeMutex);
            return true;
        }
    }
Mark node for retirement and redeploy its application
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/SpareCapacityMaintainer.java