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

Use dig, not direct indexing for field that may not exist in RestartTask #841

Merged
merged 3 commits into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## next

## 2.3.1

- Fix a bug in RestartTask where a NoMethodError is thrown if any of the target resources do not have annotations [#841](https://github.com/Shopify/krane/pull/841)

## 2.3.0

- Restart tasks now support restarting StatefulSets and DaemonSets, in addition to Deployments [#836](https://github.com/Shopify/krane/pull/836)
Expand Down
6 changes: 3 additions & 3 deletions lib/krane/restart_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def identify_target_deployments(selector: nil)
selector_string = selector.to_s
apps_v1_kubeclient.get_deployments(namespace: @namespace, label_selector: selector_string)
end
deployments.select { |d| d.metadata.annotations[ANNOTATION] }
deployments.select { |d| d.dig(:metadata, :annotations, ANNOTATION) }
end

def identify_target_statefulsets(selector: nil)
Expand All @@ -176,7 +176,7 @@ def identify_target_statefulsets(selector: nil)
selector_string = selector.to_s
apps_v1_kubeclient.get_stateful_sets(namespace: @namespace, label_selector: selector_string)
end
statefulsets.select { |d| d.metadata.annotations[ANNOTATION] }
statefulsets.select { |ss| ss.dig(:metadata, :annotations, ANNOTATION) }
end

def identify_target_daemonsets(selector: nil)
Expand All @@ -186,7 +186,7 @@ def identify_target_daemonsets(selector: nil)
selector_string = selector.to_s
apps_v1_kubeclient.get_daemon_sets(namespace: @namespace, label_selector: selector_string)
end
daemonsets.select { |d| d.metadata.annotations[ANNOTATION] }
daemonsets.select { |ds| ds.dig(:metadata, :annotations, ANNOTATION) }
end

def build_watchables(kubeclient_resources, started, klass)
Expand Down
2 changes: 1 addition & 1 deletion lib/krane/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Krane
VERSION = "2.3.0"
VERSION = "2.3.1"
end