Skip to content

Commit

Permalink
Look for node conditions related taints instead of conditions directly
Browse files Browse the repository at this point in the history
  • Loading branch information
wayt committed Apr 1, 2022
1 parent 50ab7c0 commit 1613dd6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/krane/kubernetes_resource/daemon_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def find_nodes(cache)
all_nodes = cache.get_all(Node.kind)
all_nodes.each_with_object([]) do |node_data, relevant_nodes|
next if node_data.dig('spec', 'unschedulable').to_s.downcase == 'true'
cond = node_data.dig('status', 'conditions').find { |c| c['type'].downcase == 'ready' }
next if (!cond.nil? && cond['status'].downcase != 'true')
taints = node_data['spec'].fetch('taints', []).select { |t| t['key'].start_with?('node.kubernetes.io/') }
next unless taints.empty?
relevant_nodes << Node.new(definition: node_data)
end
end
Expand Down
5 changes: 4 additions & 1 deletion test/unit/krane/kubernetes_resource/daemon_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ def test_deploy_passes_when_nodes_not_ready
refute_predicate(ds, :deploy_succeeded?)

# node 2 Pod Ready status is False, if the node is not ready it should not account as blocking
node_templates[2]['status']['conditions'].find { |c| c['type'].downcase == 'ready' }['status'] = 'False'
node_templates[2]['spec']['taints'] = [{
"effect": "NoExecute",
"key": "node.kubernetes.io/not-ready"
}]

stub_kind_get("DaemonSet", items: [ds_template])
stub_kind_get("Pod", items: pod_templates)
Expand Down

0 comments on commit 1613dd6

Please sign in to comment.