Skip to content

Commit 453e341

Browse files
fix: correct work of DaemonSetIgnore kubernetes-client#3545
1 parent aedda76 commit 453e341

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

extended/src/main/java/io/kubernetes/client/extended/kubectl/KubectlDrain.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,19 @@ private V1Node doDrain() throws KubectlException, ApiException, IOException {
7070
validatePods(allPods.getItems());
7171

7272
for (V1Pod pod : allPods.getItems()) {
73+
boolean isDaemonSetPod =false;
7374
// at this point we know, that we have to ignore daemon set pods
7475
if (pod.getMetadata().getOwnerReferences() != null) {
7576
for (V1OwnerReference ref : pod.getMetadata().getOwnerReferences()) {
7677
if (ref.getKind().equals("DaemonSet")) {
77-
continue;
78+
isDaemonSetPod = true;
79+
break;
7880
}
7981
}
8082
}
81-
deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
83+
if (!isDaemonSetPod) {
84+
deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
85+
}
8286
}
8387
return node;
8488
}

0 commit comments

Comments
 (0)