jflow 0.5.0 → 0.5.1

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: 960a8f21a063f379ca90a83d8ff0755251d6de18
4
- data.tar.gz: 1b18e34ab879287ff16008aac79c2d4604688250
3
+ metadata.gz: 7114166aa1644ef7562c3d6060f8e3ef7d9674f0
4
+ data.tar.gz: 43957bc2f311ef683b3d02acbf2f90f13fa808f0
5
5
  SHA512:
6
- metadata.gz: 4a32307b41cefa618afb109e24d4c45b92ca9a9493d3558c4aa6fcd62306f28a0336e070a96c9344faa329db77eea9ed98ba48422d778dacba35cb579487e4d6
7
- data.tar.gz: 6051f0c1c0063372303d76c51d136b53554912b42d26ead5847cee611ea6579c995a026a1a96cf4c0436da238fb0a3a277df4aaa5280d10b5f610bf56e49c8c4
6
+ metadata.gz: 3a08dedc85116cc5b91dc87cce3b3c78cb76f700e1cf187cf43086b331c6d32b3e288290f21084e8040085699825d34efaa482937e03d1bf5064d21124ba1ce9
7
+ data.tar.gz: b51304ab2e19f526f736454e532f848a96c930b4ba49a80693eaed5a2ea992489cf3f4da0c88b11ccfa568a63d896d4d9e8d4fb53251421206cdf683fe956fe2
@@ -39,4 +39,19 @@ module JFlow
39
39
  end
40
40
  end
41
41
  end
42
+
43
+ def self.handle_exception(exception)
44
+ JFlow.configuration.error_handlers.each do |error_handler|
45
+ begin
46
+ error_handler.call(exception)
47
+ rescue => e
48
+ log_error("Error handler failed!")
49
+ log_error(e.backtrace.join("\n")) unless e.backtrace.nil?
50
+ end
51
+ end
52
+ end
53
+
54
+ def self.log_error(str)
55
+ JFlow.configuration.logger.error "[#{Thread.current.object_id}] #{str}"
56
+ end
42
57
  end
@@ -92,14 +92,7 @@ module JFlow
92
92
  end
93
93
 
94
94
  def handle_exception(exception)
95
- JFlow.configuration.error_handlers.each do |error_handler|
96
- begin
97
- error_handler.call(exception)
98
- rescue => e
99
- log_error("Error handler failed!")
100
- log_error(e.backtrace.join("\n")) unless e.backtrace.nil?
101
- end
102
- end
95
+ JFlow.handle_exception(exception)
103
96
  end
104
97
 
105
98
  private
@@ -45,6 +45,7 @@ module JFlow
45
45
  Thread.current.set_state(:working)
46
46
  task.run!
47
47
  rescue => exception
48
+ Thread.current.set_state(:polling)
48
49
  task.handle_exception(exception)
49
50
  task.failed!(exception)
50
51
  end
@@ -76,4 +77,4 @@ module JFlow
76
77
 
77
78
  end
78
79
  end
79
- end
80
+ end
@@ -70,9 +70,14 @@ module JFlow
70
70
  protector = JFlow::TerminationProtector.new
71
71
  loop do
72
72
  break if Thread.current.marked_for_shutdown?
73
- protector.set_protection(should_protect?) if is_ec2_instance?
74
- stats.tick if enable_stats
75
- sleep 30
73
+ begin
74
+ protector.set_protection(should_protect?) if is_ec2_instance?
75
+ stats.tick if enable_stats
76
+ sleep 30
77
+ rescue => e
78
+ JFlow.handle_exception(e)
79
+ sleep 180
80
+ end
76
81
  end
77
82
  end
78
83
  end
@@ -1,9 +1,15 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
-
4
3
  module JFlow
5
4
  class TerminationProtector
6
5
 
6
+ attr_accessor :asg_client, :ec2_client
7
+
8
+ def initialize(asg_client = nil, ec2_client = nil)
9
+ @asg_client = asg_client || Aws::AutoScaling::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
10
+ @ec2_client = ec2_client || Aws::EC2::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
11
+ end
12
+
7
13
  def region
8
14
  instance_data['region']
9
15
  end
@@ -18,7 +24,6 @@ module JFlow
18
24
  end
19
25
 
20
26
  def get_asg_name
21
- ec2_client = Aws::EC2::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
22
27
  instance_tags = ec2_client.describe_tags(filters: [
23
28
  {
24
29
  name: "resource-id",
@@ -32,9 +37,12 @@ module JFlow
32
37
  end
33
38
 
34
39
  def set_protection(protect_status)
40
+ @previous_protect_status ||= false
41
+ return if @previous_protect_status == protect_status
42
+ @previous_protect_status = protect_status
43
+
35
44
  JFlow.configuration.logger.debug "Setting termination protection status to #{protect_status} for instance #{instance_id} in region #{region}"
36
45
  begin
37
- asg_client = Aws::AutoScaling::Client.new(region: region, credentials: Aws::InstanceProfileCredentials.new)
38
46
  asg_client.set_instance_protection({
39
47
  instance_ids: [instance_id],
40
48
  auto_scaling_group_name: get_asg_name,
@@ -42,8 +50,8 @@ module JFlow
42
50
  })
43
51
  rescue => e
44
52
  JFlow.configuration.logger.debug "Something went wrong setting termination proection: #{e.inspect}"
53
+ JFlow.handle_exception(e)
45
54
  end
46
55
  end
47
-
48
56
  end
49
57
  end
@@ -1,3 +1,3 @@
1
1
  module JFlow
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,114 +1,114 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christophe Verbinnen
8
8
  - Richard Vorp
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-05-19 00:00:00.000000000 Z
12
+ date: 2016-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: aws-sdk
16
- version_requirements: !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '2'
21
- requirement: !ruby/object:Gem::Requirement
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
22
24
  requirements:
23
25
  - - "~>"
24
26
  - !ruby/object:Gem::Version
25
27
  version: '2'
26
- prerelease: false
27
- type: :runtime
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: hash_validator
30
- version_requirements: !ruby/object:Gem::Requirement
30
+ requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0.4'
35
- requirement: !ruby/object:Gem::Requirement
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
36
38
  requirements:
37
39
  - - "~>"
38
40
  - !ruby/object:Gem::Version
39
41
  version: '0.4'
40
- prerelease: false
41
- type: :runtime
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: jflow_exceptions
44
- version_requirements: !ruby/object:Gem::Requirement
44
+ requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 0.1.1
49
- requirement: !ruby/object:Gem::Requirement
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
50
52
  requirements:
51
53
  - - "~>"
52
54
  - !ruby/object:Gem::Version
53
55
  version: 0.1.1
54
- prerelease: false
55
- type: :runtime
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: bundler
58
- version_requirements: !ruby/object:Gem::Requirement
58
+ requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '1.10'
63
- requirement: !ruby/object:Gem::Requirement
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
64
66
  requirements:
65
67
  - - "~>"
66
68
  - !ruby/object:Gem::Version
67
69
  version: '1.10'
68
- prerelease: false
69
- type: :development
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rake
72
- version_requirements: !ruby/object:Gem::Requirement
72
+ requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
76
  version: '10.0'
77
- requirement: !ruby/object:Gem::Requirement
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
78
80
  requirements:
79
81
  - - "~>"
80
82
  - !ruby/object:Gem::Version
81
83
  version: '10.0'
82
- prerelease: false
83
- type: :development
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: rspec
86
- version_requirements: !ruby/object:Gem::Requirement
86
+ requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
- requirement: !ruby/object:Gem::Requirement
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
92
94
  requirements:
93
95
  - - ">="
94
96
  - !ruby/object:Gem::Version
95
97
  version: '0'
96
- prerelease: false
97
- type: :development
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: simplecov
100
- version_requirements: !ruby/object:Gem::Requirement
100
+ requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
- requirement: !ruby/object:Gem::Requirement
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
106
108
  requirements:
107
109
  - - ">="
108
110
  - !ruby/object:Gem::Version
109
111
  version: '0'
110
- prerelease: false
111
- type: :development
112
112
  description: you know, for flow
113
113
  email:
114
114
  - christophe.verbinnen@lookout.com
@@ -147,7 +147,7 @@ homepage: https://github.com/djpate/jflow
147
147
  licenses: []
148
148
  metadata:
149
149
  allowed_push_host: https://rubygems.org
150
- post_install_message:
150
+ post_install_message:
151
151
  rdoc_options: []
152
152
  require_paths:
153
153
  - lib
@@ -162,9 +162,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubyforge_project:
165
+ rubyforge_project:
166
166
  rubygems_version: 2.4.8
167
- signing_key:
167
+ signing_key:
168
168
  specification_version: 4
169
169
  summary: SWF Flow framework for jRuby
170
170
  test_files: []
171
+ has_rdoc: