Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,27 @@ private V1Node doDrain() throws KubectlException, ApiException, IOException {
V1Node node = performCordon();

V1PodList allPods =
api.listPodForAllNamespaces()
.fieldSelector("spec.nodeName=" + node.getMetadata().getName())
.execute();
api.listPodForAllNamespaces()
.fieldSelector("spec.nodeName=" + node.getMetadata().getName())
.execute();

validatePods(allPods.getItems());

boolean isDaemonSetPod;
for (V1Pod pod : allPods.getItems()) {
isDaemonSetPod = false;
// at this point we know, that we have to ignore daemon set pods
if (pod.getMetadata().getOwnerReferences() != null) {
for (V1OwnerReference ref : pod.getMetadata().getOwnerReferences()) {
if (ref.getKind().equals("DaemonSet")) {
continue;
isDaemonSetPod = true;
break;
}
}
}
deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
if (!isDaemonSetPod) {
deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
}
}
return node;
}
Expand All @@ -103,13 +108,13 @@ private void validatePods(List<V1Pod> pods) throws KubectlException {
}

private void deletePod(CoreV1Api api, String name, String namespace)
throws ApiException, IOException, KubectlException {
throws ApiException, IOException, KubectlException {
api.deleteNamespacedPod(name, namespace).gracePeriodSeconds(gracePeriodSeconds).execute();
waitForPodDelete(api, name, namespace);
}

private void waitForPodDelete(CoreV1Api api, String name, String namespace)
throws KubectlException {
throws KubectlException {
long start = System.currentTimeMillis();
do {
try {
Expand Down