Skip to content
Merged
Show file tree
Hide file tree
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 @@ -38,6 +38,9 @@ public String toString() {
}

public static V1Taint findTaint(V1Node node, String key, Effect effect) {
if (node.getSpec() == null || node.getSpec().getTaints() == null) {
return null;
}
for (V1Taint taint : node.getSpec().getTaints()) {
if (taint.getKey().equals(key) && taint.getEffect().equals(effect.toString())) {
return taint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,12 @@ void noExecuteTaints() {
assertThat(Taints.findTaint(node, "key1", Taints.Effect.NO_EXECUTE).getEffect())
.isEqualTo(effect);
}

@Test
void findTaintWithoutSpecReturnsNull() {
// A node without a spec (or without a taints list) must not NPE; it simply has no taints,
// consistent with the null-spec handling in removeTaint.
V1Node node = new V1Node();
assertThat(Taints.findTaint(node, "key1", Taints.Effect.NO_SCHEDULE)).isNull();
}
}
Loading