kubernetes-deploy 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 272fadd954c2e206c412aca3e26d5efde55fd9e1
4
- data.tar.gz: 999e798b55468bdd5b5ffc91438b95c0560d6d6d
3
+ metadata.gz: 3ce203eba2242a33d7bdf6d5e6ed33dce0de85c2
4
+ data.tar.gz: 5d8ead3d6d9ca37ee9edc6701e98a2acdedffd31
5
5
  SHA512:
6
- metadata.gz: a30a0c161a519c6c58779ea8d155bf0970d2afae90a8e2c68c8853ef8fa019ff46ea914c24262981329f1a28ab7bf4eac89d0e03f33fd96f771ba8fc6b87fbdb
7
- data.tar.gz: e8ddd22ae6d095a5169a7ce0a131b40e2595d70cd9bf913486a2dd85b6c5dbe823917bb1ae2006cdf4d7b2c2f06c8b71d816ecb09e3d707d705ce33186935c55
6
+ metadata.gz: c81aaf0f6442b0dac0f2ce67c175eefe120574347eb470979f5f2d75c678e422cc92dd5959160a61e8069f9758a4919830ff5db4c5137911dd72df83b456181a
7
+ data.tar.gz: dd78a292e16ae848bda6ed798c39eac63aa71395a1c5e447297d8f33262e3db47377a15537559b56fa3c2a3f5541607bb85c3987cf92366069b9b9a0974461f8
@@ -115,14 +115,9 @@ module KubernetesDeploy
115
115
  !deploy_succeeded? && !deploy_failed? && (Time.now.utc - @deploy_started > timeout)
116
116
  end
117
117
 
118
- def tpr?
119
- false
120
- end
121
-
122
118
  # Expected values: :apply, :replace, :replace_force
123
119
  def deploy_method
124
- # TPRs must use update for now: https://github.com/kubernetes/kubernetes/issues/39906
125
- tpr? ? :replace : :apply
120
+ :apply
126
121
  end
127
122
 
128
123
  def debug_message
@@ -25,9 +25,5 @@ module KubernetesDeploy
25
25
  def exists?
26
26
  @found
27
27
  end
28
-
29
- def tpr?
30
- true
31
- end
32
28
  end
33
29
  end
@@ -23,10 +23,6 @@ module KubernetesDeploy
23
23
  false
24
24
  end
25
25
 
26
- def tpr?
27
- true
28
- end
29
-
30
26
  def exists?
31
27
  @found
32
28
  end
@@ -55,15 +55,10 @@ module KubernetesDeploy
55
55
  end
56
56
 
57
57
  def timeout_message
58
- return if unmanaged?
59
- return unless @phase == "Running" && !@ready
60
- pieces = ["Your pods are running, but the following containers seem to be failing their readiness probes:"]
61
- @containers.each do |c|
62
- next if c.init_container? || c.ready?
63
- yellow_name = ColorizedString.new(c.name).yellow
64
- pieces << "> #{yellow_name} must respond with a good status code at '#{c.probe_location}'"
65
- end
66
- pieces.join("\n") + "\n"
58
+ return STANDARD_TIMEOUT_MESSAGE unless readiness_probe_failure?
59
+ probe_failure_msgs = @containers.map(&:readiness_fail_reason).compact
60
+ header = "The following containers have not passed their readiness probes on at least one pod:\n"
61
+ header + probe_failure_msgs.join("\n") + "\n"
67
62
  end
68
63
 
69
64
  def failure_message
@@ -104,6 +99,12 @@ module KubernetesDeploy
104
99
 
105
100
  private
106
101
 
102
+ def readiness_probe_failure?
103
+ return false if @ready || unmanaged?
104
+ return false if @phase != "Running"
105
+ @containers.any?(&:readiness_fail_reason)
106
+ end
107
+
107
108
  def ready?(status_data)
108
109
  ready_condition = status_data.fetch("conditions", []).find { |condition| condition["type"] == "Ready" }
109
110
  ready_condition.present? && (ready_condition["status"] == "True")
@@ -162,13 +163,14 @@ module KubernetesDeploy
162
163
  end
163
164
 
164
165
  class Container
165
- attr_reader :name, :probe_location
166
+ attr_reader :name
166
167
 
167
168
  def initialize(definition, init_container: false)
168
169
  @init_container = init_container
169
170
  @name = definition["name"]
170
171
  @image = definition["image"]
171
- @probe_location = definition.dig("readinessProbe", "httpGet", "path")
172
+ @http_probe_location = definition.dig("readinessProbe", "httpGet", "path")
173
+ @exec_probe_command = definition.dig("readinessProbe", "exec", "command")
172
174
  @status = {}
173
175
  end
174
176
 
@@ -198,8 +200,20 @@ module KubernetesDeploy
198
200
  end
199
201
  end
200
202
 
203
+ def readiness_fail_reason
204
+ return if ready? || init_container?
205
+ return unless (@http_probe_location || @exec_probe_command).present?
206
+
207
+ yellow_name = ColorizedString.new(name).yellow
208
+ if @http_probe_location
209
+ "> #{yellow_name} must respond with a good status code at '#{@http_probe_location}'"
210
+ elsif @exec_probe_command
211
+ "> #{yellow_name} must exit 0 from the following command: '#{@exec_probe_command.join(' ')}'"
212
+ end
213
+ end
214
+
201
215
  def ready?
202
- @status['ready'] == "true"
216
+ @status['ready'] == true
203
217
  end
204
218
 
205
219
  def init_container?
@@ -25,10 +25,6 @@ module KubernetesDeploy
25
25
  false
26
26
  end
27
27
 
28
- def tpr?
29
- true
30
- end
31
-
32
28
  def exists?
33
29
  @found
34
30
  end
@@ -47,7 +47,7 @@ module KubernetesDeploy
47
47
  kube-public
48
48
  )
49
49
 
50
- # Things removed from default prune whitelist:
50
+ # Things removed from default prune whitelist at https://github.com/kubernetes/kubernetes/blob/0dff56b4d88ec7551084bf89028dbeebf569620e/pkg/kubectl/cmd/apply.go#L411:
51
51
  # core/v1/Namespace -- not namespaced
52
52
  # core/v1/PersistentVolume -- not namespaced
53
53
  # core/v1/Endpoints -- managed by services
@@ -55,20 +55,19 @@ module KubernetesDeploy
55
55
  # core/v1/ReplicationController -- superseded by deployments/replicasets
56
56
  # extensions/v1beta1/ReplicaSet -- managed by deployments
57
57
  # core/v1/Secret -- should not committed / managed by shipit
58
- BASE_PRUNE_WHITELIST = %w(
58
+ PRUNE_WHITELIST = %w(
59
59
  core/v1/ConfigMap
60
60
  core/v1/Pod
61
61
  core/v1/Service
62
62
  batch/v1/Job
63
63
  extensions/v1beta1/DaemonSet
64
64
  extensions/v1beta1/Deployment
65
+ apps/v1beta1/Deployment
65
66
  extensions/v1beta1/Ingress
66
67
  apps/v1beta1/StatefulSet
68
+ autoscaling/v1/HorizontalPodAutoscaler
67
69
  ).freeze
68
70
 
69
- PRUNE_WHITELIST_V_1_5 = %w(extensions/v1beta1/HorizontalPodAutoscaler).freeze
70
- PRUNE_WHITELIST_V_1_6 = %w(autoscaling/v1/HorizontalPodAutoscaler).freeze
71
-
72
71
  def initialize(namespace:, context:, current_sha:, template_dir:, logger:, bindings: {})
73
72
  @namespace = namespace
74
73
  @context = context
@@ -170,23 +169,6 @@ module KubernetesDeploy
170
169
  end
171
170
  end
172
171
 
173
- def versioned_prune_whitelist
174
- if server_major_version == "1.5"
175
- BASE_PRUNE_WHITELIST + PRUNE_WHITELIST_V_1_5
176
- else
177
- BASE_PRUNE_WHITELIST + PRUNE_WHITELIST_V_1_6
178
- end
179
- end
180
-
181
- def server_major_version
182
- @server_major_version ||= begin
183
- out, _, _ = kubectl.run('version', '--short')
184
- matchdata = /Server Version: v(?<version>\d\.\d)/.match(out)
185
- raise "Could not determine server version" unless matchdata[:version]
186
- matchdata[:version]
187
- end
188
- end
189
-
190
172
  # Inspect the file referenced in the kubectl stderr
191
173
  # to make it easier for developer to understand what's going on
192
174
  def find_bad_files_from_kubectl_output(stderr)
@@ -398,7 +380,7 @@ module KubernetesDeploy
398
380
 
399
381
  if prune
400
382
  command.push("--prune", "--all")
401
- versioned_prune_whitelist.each { |type| command.push("--prune-whitelist=#{type}") }
383
+ PRUNE_WHITELIST.each { |type| command.push("--prune-whitelist=#{type}") }
402
384
  end
403
385
 
404
386
  out, err, st = kubectl.run(*command, log_failure: false)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module KubernetesDeploy
3
- VERSION = "0.11.2"
3
+ VERSION = "0.12.0"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubernetes-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katrina Verey