krane 2.4.0 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -0
- data/README.md +1 -1
- data/lib/krane/kubernetes_resource/daemon_set.rb +18 -2
- data/lib/krane/kubernetes_resource/stateful_set.rb +5 -5
- data/lib/krane/resource_deployer.rb +1 -0
- data/lib/krane/restart_task.rb +24 -11
- data/lib/krane/template_sets.rb +2 -2
- data/lib/krane/version.rb +1 -1
- metadata +2 -3
- data/.buildkite/pipeline.nightly.yml +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56b75748b54eff6f26c64869117e2ec648569a019e77068f13766ce5b371aab7
|
4
|
+
data.tar.gz: c0d9cb8a202f7a2ccdc0975e7447373bf725705af25ba2f799b02efc9a55ddcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e070999eba8cde1d8a9bc89b77643ef957c234f572a7537b060bac6b2664ea7b8efe9d765aa516b98aaad9ce0cde1e3cb47e5e260d3be4d64a9533a303fdb54
|
7
|
+
data.tar.gz: 6bf1e6adc954c2531f8d871872c5ac352aeb5359abfefd690ad42b289ebd35456fb75f6a69ccc733675134a44f670844f565d82726ac589480fc2c0e319c979f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
## next
|
2
2
|
|
3
|
+
## 2.4.3
|
4
|
+
|
5
|
+
*Enhancements*
|
6
|
+
|
7
|
+
- Improve DaemonSet rollout [#881](https://github.com/Shopify/krane/pull/881)
|
8
|
+
|
9
|
+
## 2.4.2
|
10
|
+
|
11
|
+
*Bug fixes*
|
12
|
+
|
13
|
+
- Resolve errors for StatefulSet restart with `updateStrategy: OnDelete` [#876](https://github.com/Shopify/krane/pull/876)
|
14
|
+
- Timeouts during the "predeploy priority resources" phase now raise `DeploymentTimeoutError` instead of `FatalDeploymentError` [#874](https://github.com/Shopify/krane/pull/874)
|
15
|
+
|
16
|
+
## 2.4.1
|
17
|
+
|
18
|
+
*Enhancements*
|
19
|
+
|
20
|
+
- Support restart task for stateful sets that use the `OnDelete` strategy [#840](https://github.com/Shopify/krane/pull/840)
|
21
|
+
- Make `krane render` produce output in a deterministic order [#871](https://github.com/Shopify/krane/pull/871)
|
22
|
+
|
23
|
+
*Other*
|
24
|
+
|
25
|
+
- Remove buildkite [#869](https://github.com/Shopify/krane/pull/869)
|
26
|
+
|
3
27
|
## 2.4.0
|
4
28
|
|
5
29
|
*Enhancements*
|
data/README.md
CHANGED
@@ -73,7 +73,7 @@ If you need the ability to render dynamic values in templates before deploying,
|
|
73
73
|
|
74
74
|
## Prerequisites
|
75
75
|
|
76
|
-
* Ruby 2.
|
76
|
+
* Ruby 2.7+
|
77
77
|
* Your cluster must be running Kubernetes v1.19.0 or higher<sup>1</sup>
|
78
78
|
|
79
79
|
<sup>1</sup> We run integration tests against these Kubernetes versions. You can find our
|
@@ -9,7 +9,8 @@ module Krane
|
|
9
9
|
def sync(cache)
|
10
10
|
super
|
11
11
|
@pods = exists? ? find_pods(cache) : []
|
12
|
-
|
12
|
+
|
13
|
+
@nodes = refresh_nodes(cache)
|
13
14
|
end
|
14
15
|
|
15
16
|
def status
|
@@ -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.
|
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
|
@@ -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,13 +30,10 @@ module Krane
|
|
27
30
|
"Consider switching to rollingUpdate.")
|
28
31
|
@success_assumption_warning_shown = true
|
29
32
|
end
|
30
|
-
true
|
31
33
|
else
|
32
|
-
|
33
|
-
status_data['currentRevision'] == status_data['updateRevision'] &&
|
34
|
-
desired_replicas == status_data['readyReplicas'].to_i &&
|
35
|
-
desired_replicas == status_data['currentReplicas'].to_i
|
34
|
+
success &= desired_replicas == status_data['currentReplicas'].to_i
|
36
35
|
end
|
36
|
+
success
|
37
37
|
end
|
38
38
|
|
39
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
|
data/lib/krane/restart_task.rb
CHANGED
@@ -69,10 +69,10 @@ module Krane
|
|
69
69
|
deployments, statefulsets, daemonsets = identify_target_workloads(deployments, statefulsets,
|
70
70
|
daemonsets, selector: selector)
|
71
71
|
|
72
|
-
@logger.phase_heading("Triggering restart
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
@logger.phase_heading("Triggering restart")
|
73
|
+
restart_deployments!(deployments)
|
74
|
+
restart_statefulsets!(statefulsets)
|
75
|
+
restart_daemonsets!(daemonsets)
|
76
76
|
|
77
77
|
if verify_result
|
78
78
|
@logger.phase_heading("Waiting for rollout")
|
@@ -210,7 +210,15 @@ module Krane
|
|
210
210
|
apps_v1_kubeclient.patch_daemon_set(record.metadata.name, build_patch_payload(record), @namespace)
|
211
211
|
end
|
212
212
|
|
213
|
-
def
|
213
|
+
def delete_statefulset_pods(record)
|
214
|
+
pods = kubeclient.get_pods(namespace: record.metadata.namespace)
|
215
|
+
pods.select! do |pod|
|
216
|
+
pod.metadata&.ownerReferences&.find { |ref| ref.uid == record.metadata.uid }
|
217
|
+
end
|
218
|
+
pods.each { |pod| kubeclient.delete_pod(pod.metadata.name, pod.metadata.namespace) }
|
219
|
+
end
|
220
|
+
|
221
|
+
def restart_deployments!(deployments)
|
214
222
|
deployments.each do |record|
|
215
223
|
begin
|
216
224
|
patch_deployment_with_restart(record)
|
@@ -221,18 +229,23 @@ module Krane
|
|
221
229
|
end
|
222
230
|
end
|
223
231
|
|
224
|
-
def
|
232
|
+
def restart_statefulsets!(statefulsets)
|
225
233
|
statefulsets.each do |record|
|
226
|
-
|
234
|
+
@logger.info("Triggered `StatefulSet/#{record.metadata.name}` restart")
|
235
|
+
if record.spec.updateStrategy&.type == "OnDelete"
|
236
|
+
@logger.info("`StatefulSet/#{record.metadata.name}` has updateStrategy: OnDelete," \
|
237
|
+
" Restarting by forcefully deleting child pods"
|
238
|
+
)
|
239
|
+
delete_statefulset_pods(record)
|
240
|
+
else
|
227
241
|
patch_statefulset_with_restart(record)
|
228
|
-
@logger.info("Triggered `StatefulSet/#{record.metadata.name}` restart")
|
229
|
-
rescue Kubeclient::HttpError => e
|
230
|
-
raise RestartAPIError.new(record.metadata.name, e.message)
|
231
242
|
end
|
243
|
+
rescue Kubeclient::HttpError => e
|
244
|
+
raise RestartAPIError.new(record.metadata.name, e.message)
|
232
245
|
end
|
233
246
|
end
|
234
247
|
|
235
|
-
def
|
248
|
+
def restart_daemonsets!(daemonsets)
|
236
249
|
daemonsets.each do |record|
|
237
250
|
begin
|
238
251
|
patch_daemonset_with_restart(record)
|
data/lib/krane/template_sets.rb
CHANGED
@@ -104,11 +104,11 @@ module Krane
|
|
104
104
|
dir_paths.each do |template_dir|
|
105
105
|
resource_templates[template_dir] = Dir.foreach(template_dir).select do |filename|
|
106
106
|
filename.end_with?(*VALID_TEMPLATES) || filename == EjsonSecretProvisioner::EJSON_SECRETS_FILE
|
107
|
-
end
|
107
|
+
end.sort
|
108
108
|
end
|
109
109
|
|
110
110
|
# Filename paths
|
111
|
-
file_paths.each do |filename|
|
111
|
+
file_paths.sort.each do |filename|
|
112
112
|
dir_name = File.dirname(filename)
|
113
113
|
resource_templates[dir_name] ||= []
|
114
114
|
resource_templates[dir_name] << File.basename(filename) unless resource_templates[dir_name].include?(filename)
|
data/lib/krane/version.rb
CHANGED
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.
|
4
|
+
version: 2.4.3
|
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-
|
13
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -411,7 +411,6 @@ executables:
|
|
411
411
|
extensions: []
|
412
412
|
extra_rdoc_files: []
|
413
413
|
files:
|
414
|
-
- ".buildkite/pipeline.nightly.yml"
|
415
414
|
- ".github/CODEOWNERS"
|
416
415
|
- ".github/ISSUE_TEMPLATE.md"
|
417
416
|
- ".github/probots.yml"
|
@@ -1,15 +0,0 @@
|
|
1
|
-
steps:
|
2
|
-
- name: 'Run Test Suite (:kubernetes: 1.16-latest)'
|
3
|
-
command: bin/ci
|
4
|
-
agents:
|
5
|
-
queue: k8s-ci
|
6
|
-
env:
|
7
|
-
LOGGING_LEVEL: 4
|
8
|
-
KUBERNETES_VERSION: v1.16-latest
|
9
|
-
- name: 'Run Test Suite (:kubernetes: 1.15-latest)'
|
10
|
-
command: bin/ci
|
11
|
-
agents:
|
12
|
-
queue: k8s-ci
|
13
|
-
env:
|
14
|
-
LOGGING_LEVEL: 4
|
15
|
-
KUBERNETES_VERSION: v1.15-latest
|