@Override public void deletePod(String podId) throws KubernetesClientException { try { kubernetesClient.deletePod(podId); } catch (Exception e) { String message = String.format("Could not delete kubernetes pod: [pod-id] %s", podId); log.error(message, e); throw new KubernetesClientException(message, e); } }
public static void deletePods(KubernetesClient client, Logger logger, Filter<Pod> filter) throws MultiException { List<Throwable> errors = new ArrayList<>(); for (Pod pod : client.getPods().getItems()) { if (filter.matches(pod)) { try { logger.info("Deleting pod:" + getId(pod)); client.deletePod(getId(pod)); } catch (Exception e) { errors.add(e); } } } if (!errors.isEmpty()) { throw new MultiException("Error while deleting pods", errors); } }