krane 2.4.1 → 2.4.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93f7d9e842d616ea60e2c509f5e5a3fcb54d24375d426efd0345ba3a07dd2008
4
- data.tar.gz: 24ccdd3165654319b55632a866f85839268644cb32ee719f55f03de6e5f63eb6
3
+ metadata.gz: 64b26c01ccbf33a59a0b18463afdcde52c7b223f120b804dd865e99a7fa1195c
4
+ data.tar.gz: bcd0a549f67c53e23f5c8ea556c8a97d847f30d9e54e088b0e26f0c9059c51d0
5
5
  SHA512:
6
- metadata.gz: 1c90430d28fe8513dd86aef6d160e04257beb66f294b998d780c66b27d8bdb7e5320947b06894399c49bcb336795f72a338fb197f3be4626467bfb286bbde2f0
7
- data.tar.gz: 98fc07319ed605978d558777cea947a187bf3857d229b95945096d446fdbacd2637102e34a9e03afb9f5472105ce39d5d396f9c1cf8bc6f4c0677f28e6b88e9b
6
+ metadata.gz: f617f7580dd5de9630ac439f2b0ded0aed198db11a2fbaa3a6ec72d4745c43001e9ffcea7570432ae13dab9224118f50da448958294317a5dd104597809e3dcf
7
+ data.tar.gz: 7a8807bdc559e2fe1b92734a347809f24cade1fac10bd00510b3667b3e9880bd7c37e75c1bf0dee44488a9972ad2f9c1b498a3e96107c143583fb018da2ed6f0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  ## next
2
2
 
3
+ ## 2.4.4
4
+
5
+ *Enhancements*
6
+
7
+ - Improve DaemonSet rollout by ignoring `Evicted` Pods [#883](https://github.com/Shopify/krane/pull/883)
8
+
9
+ ## 2.4.3
10
+
11
+ *Enhancements*
12
+
13
+ - Improve DaemonSet rollout [#881](https://github.com/Shopify/krane/pull/881)
14
+
15
+ ## 2.4.2
16
+
17
+ *Bug fixes*
18
+
19
+ - Resolve errors for StatefulSet restart with `updateStrategy: OnDelete` [#876](https://github.com/Shopify/krane/pull/876)
20
+ - Timeouts during the "predeploy priority resources" phase now raise `DeploymentTimeoutError` instead of `FatalDeploymentError` [#874](https://github.com/Shopify/krane/pull/874)
21
+
3
22
  ## 2.4.1
4
23
 
5
24
  *Enhancements*
@@ -9,7 +9,8 @@ module Krane
9
9
  def sync(cache)
10
10
  super
11
11
  @pods = exists? ? find_pods(cache) : []
12
- @nodes = find_nodes(cache) if @nodes.blank?
12
+
13
+ @nodes = refresh_nodes(cache)
13
14
  end
14
15
 
15
16
  def status
@@ -58,7 +59,7 @@ module Krane
58
59
  def relevant_pods_ready?
59
60
  return true if rollout_data["desiredNumberScheduled"].to_i == rollout_data["numberReady"].to_i # all pods ready
60
61
  relevant_node_names = @nodes.map(&:name)
61
- considered_pods = @pods.select { |p| relevant_node_names.include?(p.node_name) }
62
+ considered_pods = @pods.select { |p| relevant_node_names.include?(p.node_name) && !p.evicted? }
62
63
  @logger.debug("DaemonSet is reporting #{rollout_data['numberReady']} pods ready." \
63
64
  " Considered #{considered_pods.size} pods out of #{@pods.size} for #{@nodes.size} nodes.")
64
65
  considered_pods.present? &&
@@ -66,9 +67,24 @@ module Krane
66
67
  rollout_data["numberReady"].to_i >= considered_pods.length
67
68
  end
68
69
 
70
+ def refresh_nodes(cache)
71
+ new_nodes = find_nodes(cache)
72
+ return new_nodes if @nodes.blank?
73
+
74
+ # Remove non-existent nodes
75
+ @nodes.select do |node|
76
+ new_nodes.find { |n| n.name == node.name } != nil
77
+ end
78
+ end
79
+
69
80
  def find_nodes(cache)
70
81
  all_nodes = cache.get_all(Node.kind)
71
- all_nodes.map { |node_data| Node.new(definition: node_data) }
82
+ all_nodes.each_with_object([]) do |node_data, relevant_nodes|
83
+ next if node_data.dig('spec', 'unschedulable').to_s.downcase == 'true'
84
+ cond = node_data.dig('status', 'conditions').find { |c| c['type'].downcase == 'ready' }
85
+ next if (!cond.nil? && cond['status'].downcase != 'true')
86
+ relevant_nodes << Node.new(definition: node_data)
87
+ end
72
88
  end
73
89
 
74
90
  def rollout_data
@@ -105,6 +105,10 @@ module Krane
105
105
  @instance_data.dig('spec', 'nodeName')
106
106
  end
107
107
 
108
+ def evicted?
109
+ phase == "Failed" && reason == "Evicted"
110
+ end
111
+
108
112
  private
109
113
 
110
114
  def failed_schedule_reason
@@ -19,6 +19,9 @@ module Krane
19
19
  end
20
20
 
21
21
  def deploy_succeeded?
22
+ success = observed_generation == current_generation &&
23
+ desired_replicas == status_data['readyReplicas'].to_i &&
24
+ status_data['currentRevision'] == status_data['updateRevision']
22
25
  if update_strategy == ONDELETE
23
26
  # Gem cannot monitor update since it doesn't occur until delete
24
27
  unless @success_assumption_warning_shown
@@ -27,11 +30,10 @@ module Krane
27
30
  "Consider switching to rollingUpdate.")
28
31
  @success_assumption_warning_shown = true
29
32
  end
33
+ else
34
+ success &= desired_replicas == status_data['currentReplicas'].to_i
30
35
  end
31
- observed_generation == current_generation &&
32
- status_data['currentRevision'] == status_data['updateRevision'] &&
33
- desired_replicas == status_data['readyReplicas'].to_i &&
34
- desired_replicas == status_data['currentReplicas'].to_i
36
+ success
35
37
  end
36
38
 
37
39
  def deploy_failed?
@@ -70,6 +70,7 @@ module Krane
70
70
  r.sync_debug_info(kubectl)
71
71
  end
72
72
  failed_resources.each { |r| logger.summary.add_paragraph(r.debug_message) }
73
+ raise DeploymentTimeoutError if failed_resources.all?(&:deploy_timed_out?)
73
74
  raise FatalDeploymentError, "Failed to deploy #{fail_count} priority #{'resource'.pluralize(fail_count)}"
74
75
  end
75
76
  logger.blank_line
@@ -213,7 +213,7 @@ module Krane
213
213
  def delete_statefulset_pods(record)
214
214
  pods = kubeclient.get_pods(namespace: record.metadata.namespace)
215
215
  pods.select! do |pod|
216
- pod.metadata.ownerReferences.find { |ref| ref.uid == record.metadata.uid }
216
+ pod.metadata&.ownerReferences&.find { |ref| ref.uid == record.metadata.uid }
217
217
  end
218
218
  pods.each { |pod| kubeclient.delete_pod(pod.metadata.name, pod.metadata.namespace) }
219
219
  end
data/lib/krane/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Krane
3
- VERSION = "2.4.1"
3
+ VERSION = "2.4.4"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: krane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Verey
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-02-02 00:00:00.000000000 Z
13
+ date: 2022-04-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport