Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure instance data is synced with pod state before reporting DS success #617

Merged
merged 7 commits into from
Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion lib/krane/kubernetes_resource/daemon_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def relevant_pods_ready?
relevant_node_names = @nodes.map(&:name)
considered_pods = @pods.select { |p| relevant_node_names.include?(p.node_name) }
@logger.debug("Considered #{considered_pods.size} pods out of #{@pods.size} for #{@nodes.size} nodes")
timothysmith0609 marked this conversation as resolved.
Show resolved Hide resolved
considered_pods.present? && considered_pods.all?(&:deploy_succeeded?)
considered_pods.present? &&
considered_pods.all?(&:deploy_succeeded?) &&
rollout_data["numberReady"].to_i >= considered_pods.length
end

def find_nodes(cache)
Expand Down
13 changes: 13 additions & 0 deletions test/unit/krane/kubernetes_resource/daemon_set_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ def test_deploy_fails_when_not_all_pods_ready
refute_predicate(ds, :deploy_succeeded?)
end

def test_deploy_waits_for_daemonset_status_to_converge_to_pod_states
status = {
"desiredNumberScheduled": 1,
"updatedNumberScheduled": 1,
"numberReady": 0,
}
ds_template = build_ds_template(filename: 'daemon_set.yml', status: status)
ready_pod_template = load_fixtures(filenames: ['daemon_set_pods.yml']).first # should be a pod in `Ready` state
node_templates = load_fixtures(filenames: ['nodes.yml'])
ds = build_synced_ds(ds_template: ds_template, pod_templates: [ready_pod_template], node_templates: node_templates)
refute_predicate(ds, :deploy_succeeded?)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this against master yields a failure, proving my hypothesis that the divergent state between pods and the DS were the root of the error


private

def build_ds_template(filename:, status: {})
Expand Down