pfab 0.58.3 → 0.58.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pfab/cli.rb +34 -21
- data/lib/pfab/version.rb +1 -1
- data/pfab.gemspec +14 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c9aea4ca5e33e1435e9dbc50e7b6229a852ccf9537956a818fc2a4a2dfa81f1
|
4
|
+
data.tar.gz: c6428e97bcb16aece2e493978cea6da82a91113c1bc15e7c942f1978f03100ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b206ecbb17034d19c921926df9d107f8ec14e3065c14c421ae2465d8463fe3a6aadf22bc0e79f3554192b954162b4254273d2c604240ee24cae6008b45ddf34e
|
7
|
+
data.tar.gz: 247ed244b974a5b81268ee5935d0d607a4dd1e0f46d576566e4f9513df7bf1abdb1fd8539b1171fc3cfefb6cc5fb90606ad191c6c348e0a3fb9e0d384769538c
|
data/lib/pfab/cli.rb
CHANGED
@@ -65,16 +65,18 @@ module Pfab
|
|
65
65
|
command :shipit do |c|
|
66
66
|
c.syntax = "pfab shipit"
|
67
67
|
c.summary = "build, generate, apply"
|
68
|
-
c.option "-t", "--timeout
|
68
|
+
c.option "-t", "--timeout TIMEOUT", Integer, "timeout for rollout (default 360s)"
|
69
|
+
c.option "-r", "--retries RETRIES", Integer, "number of retries for rollout (default 3)"
|
70
|
+
c.option "-s", "--sleep SLEEP", Integer, "sleep duration between retries in seconds (default 5)"
|
69
71
|
|
70
72
|
c.action do |args, options|
|
71
|
-
options.default :
|
73
|
+
options.default timeout: 360, retries: 3, sleep: 5
|
72
74
|
app_name = get_app_name(all: true)
|
73
75
|
puts "Shipping #{app_name}"
|
74
76
|
success = cmd_build
|
75
77
|
if success
|
76
78
|
cmd_generate_yaml
|
77
|
-
cmd_apply(timeout: options.timeout)
|
79
|
+
cmd_apply(timeout: options.timeout, retries: options.retries, sleep_duration: options.sleep)
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -207,7 +209,7 @@ module Pfab
|
|
207
209
|
run!
|
208
210
|
end
|
209
211
|
|
210
|
-
def cmd_apply(timeout: 240)
|
212
|
+
def cmd_apply(timeout: 240, retries: 3, sleep_duration: 5)
|
211
213
|
set_kube_context
|
212
214
|
success = true
|
213
215
|
|
@@ -222,9 +224,13 @@ module Pfab
|
|
222
224
|
success &= puts_and_system("git push origin --tags")
|
223
225
|
end
|
224
226
|
|
227
|
+
success &= wait_for_deployments_rollout(timeout, retries: retries, sleep_duration: sleep_duration)
|
228
|
+
|
229
|
+
exit(success ? 0 : 1)
|
230
|
+
end
|
231
|
+
|
232
|
+
def wait_for_deployments_rollout(timeout, retries: 3, sleep_duration: 5)
|
225
233
|
selector = "application=#{@application_yaml['name']}"
|
226
|
-
|
227
|
-
# Get all deployments for the given selector
|
228
234
|
deployment_json = `kubectl get deployment -l #{selector} -o json --namespace=#{yy.namespace}`
|
229
235
|
deployments = JSON.parse(deployment_json)
|
230
236
|
|
@@ -232,26 +238,33 @@ module Pfab
|
|
232
238
|
deployments["items"].each do |deployment|
|
233
239
|
deployment_name = deployment["metadata"]["name"]
|
234
240
|
puts "Waiting for deployment #{deployment_name} to roll out..."
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
241
|
+
|
242
|
+
retries.times do |attempt|
|
243
|
+
rollout_success = kubectl("rollout status deployment/#{deployment_name} --timeout=#{timeout}s")
|
244
|
+
rollout_success = false
|
245
|
+
if rollout_success
|
246
|
+
puts "Deployment #{deployment_name} successfully rolled out. Attempt #{attempt + 1}/#{retries}."
|
247
|
+
break
|
248
|
+
else
|
249
|
+
puts "Attempt #{attempt + 1}/#{retries}: Deployment #{deployment_name} failed to roll out within the specified timeout."
|
250
|
+
if attempt < retries - 1
|
251
|
+
puts "Retrying in #{sleep_duration} seconds..."
|
252
|
+
sleep(sleep_duration)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
unless rollout_success
|
258
|
+
puts "Deployment #{deployment_name} failed to roll out after #{retries} attempts."
|
259
|
+
return false
|
240
260
|
end
|
241
|
-
success &= rollout_success
|
242
261
|
end
|
243
|
-
else
|
244
|
-
puts "No deployments found for selector: #{selector}"
|
245
|
-
success = false
|
246
|
-
end
|
247
|
-
|
248
|
-
if success
|
249
262
|
puts "All deployments successfully rolled out."
|
263
|
+
true
|
250
264
|
else
|
251
|
-
puts "
|
265
|
+
puts "No deployments found for selector: #{selector}"
|
266
|
+
false
|
252
267
|
end
|
253
|
-
|
254
|
-
exit(success ? 0 : 1)
|
255
268
|
end
|
256
269
|
|
257
270
|
def image_exists?(full_image_name)
|
data/lib/pfab/version.rb
CHANGED
data/pfab.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: pfab 0.58.
|
5
|
+
# stub: pfab 0.58.4 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "pfab".freeze
|
9
|
-
s.version = "0.58.
|
9
|
+
s.version = "0.58.4"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Jeff Dwyer".freeze]
|
14
|
-
s.date = "2024-10-
|
14
|
+
s.date = "2024-10-09"
|
15
15
|
s.description = "k8s helper".freeze
|
16
16
|
s.email = "jdwyer@prefab.cloud".freeze
|
17
17
|
s.executables = ["pfab".freeze]
|
@@ -46,33 +46,19 @@ Gem::Specification.new do |s|
|
|
46
46
|
]
|
47
47
|
s.homepage = "http://github.com/prefab-cloud/pfab".freeze
|
48
48
|
s.licenses = ["MIT".freeze]
|
49
|
-
s.rubygems_version = "3.
|
49
|
+
s.rubygems_version = "3.4.6".freeze
|
50
50
|
s.summary = "helper gem".freeze
|
51
51
|
|
52
|
-
|
53
|
-
s.specification_version = 4
|
54
|
-
end
|
52
|
+
s.specification_version = 4
|
55
53
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
s.add_development_dependency(%q<test-unit>.freeze, [">= 0"])
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<commander>.freeze, [">= 0"])
|
68
|
-
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
69
|
-
s.add_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
70
|
-
s.add_dependency(%q<styled_yaml>.freeze, ["~> 0.0.1"])
|
71
|
-
s.add_dependency(%q<rdoc>.freeze, ["~> 6.1"])
|
72
|
-
s.add_dependency(%q<bundler>.freeze, ["~> 2.3"])
|
73
|
-
s.add_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
74
|
-
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
75
|
-
s.add_dependency(%q<test-unit>.freeze, [">= 0"])
|
76
|
-
end
|
54
|
+
s.add_runtime_dependency(%q<commander>.freeze, [">= 0"])
|
55
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
|
56
|
+
s.add_runtime_dependency(%q<pry-byebug>.freeze, [">= 0"])
|
57
|
+
s.add_runtime_dependency(%q<styled_yaml>.freeze, ["~> 0.0.1"])
|
58
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.1"])
|
59
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 2.3"])
|
60
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.4.9"])
|
61
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
62
|
+
s.add_development_dependency(%q<test-unit>.freeze, [">= 0"])
|
77
63
|
end
|
78
64
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pfab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.58.
|
4
|
+
version: 0.58.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Dwyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|