Class: Vidar::DeployStatus
- Inherits:
-
Object
- Object
- Vidar::DeployStatus
- Defined in:
- lib/vidar/deploy_status.rb
Overview
Polls Kubernetes pod status until deployment completes or times out.
Constant Summary collapse
- INITIAL_SLEEP =
2- SLEEP =
10- MAX_TRIES =
30
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#max_tries ⇒ Object
readonly
Returns the value of attribute max_tries.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
Instance Method Summary collapse
-
#initialize(namespace:, filter: nil, max_tries: MAX_TRIES) ⇒ DeployStatus
constructor
A new instance of DeployStatus.
-
#success? ⇒ Boolean
True if the last observed pod set reported success.
-
#wait_until_completed ⇒ void
Waits until all pods are deployed and none are still initializing.
-
#wait_until_up ⇒ void
Waits until at least one pod exists in the namespace.
Constructor Details
#initialize(namespace:, filter: nil, max_tries: MAX_TRIES) ⇒ DeployStatus
Returns a new instance of DeployStatus.
13 14 15 16 17 |
# File 'lib/vidar/deploy_status.rb', line 13 def initialize(namespace:, filter: nil, max_tries: MAX_TRIES) @namespace = namespace @filter = filter @max_tries = max_tries end |
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
8 9 10 |
# File 'lib/vidar/deploy_status.rb', line 8 def filter @filter end |
#max_tries ⇒ Object (readonly)
Returns the value of attribute max_tries.
8 9 10 |
# File 'lib/vidar/deploy_status.rb', line 8 def max_tries @max_tries end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
8 9 10 |
# File 'lib/vidar/deploy_status.rb', line 8 def namespace @namespace end |
Instance Method Details
#success? ⇒ Boolean
Returns true if the last observed pod set reported success.
46 47 48 49 50 |
# File 'lib/vidar/deploy_status.rb', line 46 def success? return false unless @last_pod_set @last_pod_set.success? end |
#wait_until_completed ⇒ void
This method returns an undefined value.
Waits until all pods are deployed and none are still initializing.
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vidar/deploy_status.rb', line 34 def wait_until_completed sleep(INITIAL_SLEEP) max_tries.times do ps = current_pod_set break if ps.deployed? sleep(SLEEP) end end |
#wait_until_up ⇒ void
This method returns an undefined value.
Waits until at least one pod exists in the namespace.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vidar/deploy_status.rb', line 21 def wait_until_up sleep(INITIAL_SLEEP) max_tries.times do ps = current_pod_set break if ps.any? sleep(SLEEP) end end |