staypuft 0.5.14 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 76ef07b6490d37e26005189f760b35a3dc490a96
4
- data.tar.gz: f58f1ff00ab900cba9e420bf2285e69e794cedf5
3
+ metadata.gz: 393d259fe817948071494184f9fa3cd51ea8e654
4
+ data.tar.gz: 3641379f31897bed7e704f231b01b56254ea2656
5
5
  SHA512:
6
- metadata.gz: cf97c5664747ae8531c58467ce6a819e5da449a17a1fe44d29fa6708dec8d0d6856ffc81034463ce8dd4f4a8ec5c50ceec350aec2bc1077ce41ba961ed14c233
7
- data.tar.gz: abf04187d87bf7a0b8d30bad9dbb25dba23384ddcd4c0282fbe30494a0a34b45404988d678b6aa662d331338871dd51ea9af7dce1cd99577f5419e9f2eb6a1de
6
+ metadata.gz: 7ead581569132ae1531579d4ebe3b1b5808e2e7fba8e9166a34e1331ab3087227584e6eb827c68c83a1de46f75254bb065be3b5a45a45c2f77b7b01bfdf5213f
7
+ data.tar.gz: 378d4ba1e8647803e39665fe020fe22b57aeb7b308f206d179b6f6f53bb526761bc514c927f87f078b50b46907adbb3bef9a666b7200123de6bac51b72101072
@@ -16,6 +16,9 @@ module Actions
16
16
 
17
17
  class ReportWait < Actions::Base
18
18
 
19
+ TIMEOUT = 9000
20
+
21
+ middleware.use Actions::Staypuft::Middleware::Timeout
19
22
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
20
23
  include Dynflow::Action::Polling
21
24
 
@@ -16,7 +16,13 @@ module Actions
16
16
 
17
17
  class WaitUntilProvisioned < Actions::Base
18
18
 
19
+ TIMEOUT = 7200
20
+
19
21
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
22
+ # Using the Timeout middleware to make sure input[:timeout] is
23
+ # set. The actual timeout check is performed separately for
24
+ # the WaitUntilProvisioned because it's not a polling action.
25
+ middleware.use Actions::Staypuft::Middleware::Timeout
20
26
 
21
27
  def plan(host)
22
28
  plan_self host_id: host.id
@@ -26,11 +32,22 @@ module Actions
26
32
  case event
27
33
  when nil
28
34
  suspend do |suspended_action|
35
+ # schedule timeout
36
+ world.clock.ping suspended_action, input[:timeout], "timeout"
37
+
38
+ # wake up when provisioning is finished
29
39
  Rails.cache.write(
30
40
  ::Staypuft::Concerns::HostOrchestrationBuildHook.cache_id(input[:host_id]),
31
41
  { execution_plan_id: suspended_action.execution_plan_id,
32
42
  step_id: suspended_action.step_id })
33
43
  end
44
+ when "timeout"
45
+ # clear timeout_start so that the action can be resumed/skipped
46
+ output[:timeout_start] = nil
47
+ fail(::Staypuft::Exception,
48
+ "You've reached the timeout set for this action. If the " +
49
+ "action is still ongoing, you can click on the " +
50
+ "\"Resume Deployment\" button to continue.")
34
51
  when Hash
35
52
  output[:installed_at] = event.fetch(:installed_at).to_s
36
53
  when Dynflow::Action::Skip
@@ -17,7 +17,9 @@ module Actions
17
17
  class WaitUntilReady < Actions::Base
18
18
 
19
19
  STARTUP_GRACE_PERIOD = 60
20
+ TIMEOUT = 1800
20
21
 
22
+ middleware.use Actions::Staypuft::Middleware::Timeout
21
23
  middleware.use Actions::Staypuft::Middleware::AsCurrentUser
22
24
  include Dynflow::Action::Polling
23
25
 
@@ -0,0 +1,39 @@
1
+ module Actions
2
+ module Staypuft
3
+ module Middleware
4
+ class Timeout < Dynflow::Middleware
5
+
6
+ def plan(*args)
7
+ pass(*args).tap do
8
+ action.input[:timeout] ||= action.class::TIMEOUT
9
+ end
10
+ end
11
+
12
+ def run(*args)
13
+ assert_timeout_not_reached
14
+ pass(*args)
15
+ end
16
+
17
+ private
18
+
19
+ def assert_timeout_not_reached
20
+ action.output[:timeout_start] ||= Time.now.to_i
21
+
22
+ timeout_start = action.output[:timeout_start]
23
+ now = Time.now.to_i
24
+ timeout = action.input[:timeout]
25
+
26
+ if now - timeout_start > timeout
27
+ # clear timeout_start so that the action can be resumed/skipped
28
+ action.output[:timeout_start] = nil
29
+ fail(::Staypuft::Exception,
30
+ "You've reached the timeout set for this action. If the " +
31
+ "action is still ongoing, you can click on the " +
32
+ "\"Resume Deployment\" button to continue.")
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module Staypuft
2
- VERSION = '0.5.14'
2
+ VERSION = '0.5.15'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: staypuft
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.14
4
+ version: 0.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Staypuft team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-21 00:00:00.000000000 Z
11
+ date: 2015-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: foreman-tasks
@@ -178,6 +178,7 @@ files:
178
178
  - app/lib/actions/staypuft/host/deploy.rb
179
179
  - app/lib/actions/staypuft/host/create.rb
180
180
  - app/lib/actions/staypuft/middleware/as_current_user.rb
181
+ - app/lib/actions/staypuft/middleware/timeout.rb
181
182
  - app/lib/staypuft/network_query.rb
182
183
  - app/lib/staypuft/deployment_param_importer.rb
183
184
  - app/lib/staypuft/seeder.rb