Skip to content

Commit 5eb5e75

Browse files
committed
fix: correct work of DaemonSetIgnore #3545
1 parent aedda76 commit 5eb5e75

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,21 @@ private V1Node doDrain() throws KubectlException, ApiException, IOException {
6969

7070
validatePods(allPods.getItems());
7171

72+
boolean isDaemonSetPod;
7273
for (V1Pod pod : allPods.getItems()) {
74+
isDaemonSetPod = false;
7375
// at this point we know, that we have to ignore daemon set pods
7476
if (pod.getMetadata().getOwnerReferences() != null) {
7577
for (V1OwnerReference ref : pod.getMetadata().getOwnerReferences()) {
7678
if (ref.getKind().equals("DaemonSet")) {
77-
continue;
79+
isDaemonSetPod = true;
80+
break;
7881
}
7982
}
8083
}
81-
deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
84+
if (!isDaemonSetPod) {
85+
deletePod(api, pod.getMetadata().getName(), pod.getMetadata().getNamespace());
86+
}
8287
}
8388
return node;
8489
}

0 commit comments

Comments
 (0)