pfab 0.58.3 → 0.58.5
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 +4 -4
- data/lib/pfab/cli.rb +33 -21
- data/lib/pfab/version.rb +1 -1
- data/pfab.gemspec +3 -3
- 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: 9095dc3b5c4ad4e96aee6c137ecfe7700f78e9a62fb8cb88b5706bba4b32c778
|
|
4
|
+
data.tar.gz: 0bc0d39e855cd149c15f2b93c831a4468687e8be9fa3d6243da6c40efbc0f7ec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 31d52d5108797d2b5314a79b269187959ec38bb1093a80803deb7652d825ee882cc95baa6d1fabb5103cd8bed1db2892203a0bec2524f796838277257afde974
|
|
7
|
+
data.tar.gz: 22810edb93eee2aacc48b0d76f6dd86acd66b73c1ab56aab264a0cff36f6a960f889aeb4ff294d66ccb858caa5059075502ae176115b59cbc0a322ed97f1f5e4
|
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,32 @@ 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
|
+
if rollout_success
|
|
245
|
+
puts "Deployment #{deployment_name} successfully rolled out. Attempt #{attempt + 1}/#{retries}."
|
|
246
|
+
break
|
|
247
|
+
else
|
|
248
|
+
puts "Attempt #{attempt + 1}/#{retries}: Deployment #{deployment_name} failed to roll out within the specified timeout."
|
|
249
|
+
if attempt < retries - 1
|
|
250
|
+
puts "Retrying in #{sleep_duration} seconds..."
|
|
251
|
+
sleep(sleep_duration)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
unless rollout_success
|
|
257
|
+
puts "Deployment #{deployment_name} failed to roll out after #{retries} attempts."
|
|
258
|
+
return false
|
|
240
259
|
end
|
|
241
|
-
success &= rollout_success
|
|
242
260
|
end
|
|
243
|
-
else
|
|
244
|
-
puts "No deployments found for selector: #{selector}"
|
|
245
|
-
success = false
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
if success
|
|
249
261
|
puts "All deployments successfully rolled out."
|
|
262
|
+
true
|
|
250
263
|
else
|
|
251
|
-
puts "
|
|
264
|
+
puts "No deployments found for selector: #{selector}"
|
|
265
|
+
false
|
|
252
266
|
end
|
|
253
|
-
|
|
254
|
-
exit(success ? 0 : 1)
|
|
255
267
|
end
|
|
256
268
|
|
|
257
269
|
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.5 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.5"
|
|
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]
|
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.5
|
|
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
|