elastic_beans 0.10.0.alpha10 → 0.10.0.alpha11

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: 7080610cdba10edf2a2bb8413e2d738febbc415f
4
- data.tar.gz: b9c95b1062a85eec83478ee53ca50b7f34934883
3
+ metadata.gz: 1baec72dd59bc86eedee59dcafe6965b4c2d12b1
4
+ data.tar.gz: 5a50bf6ccae347c30691f131c6ab8ca1f3e7d286
5
5
  SHA512:
6
- metadata.gz: d1b63b448029c173f635c6a952921dea8ba0a93470f6e55317539988e41cf8c78c2ffc5faae84f2efa6f42b3135c4496f5c193198f36d6cd4c389b1f7370d721
7
- data.tar.gz: 6d059ce51759b9621a4bc5bfff0e12ce4e3d8dd7436e8991af8b0dc1cf9ce461d99062977348bf623046fdfcfddef12c219ba0e92bc7de38795084b820705950
6
+ metadata.gz: 37e66cfb04a05853f6fbdc5ead050531b4038a532cc06a26d96c40a4f6183900ce03d988a9caff6c90d5cac717b390a31f62b46383db32faeeb98cb681dd1184
7
+ data.tar.gz: 83b5db9fd76e13d82ae2da0f3e3870cd18d8510fa3ad3b56f266e04e0772d52f1b7b14d46f1e51064a14e0ac079249904df4623e74b49769ca0bc078647acb6b
@@ -101,10 +101,24 @@ module ElasticBeans
101
101
  raise AccessDeniedS3Error.new
102
102
  end
103
103
 
104
+ # Removes command metadata created by #register_command.
105
+ # Used by `beans exec --interactive` to clean up the interactive task metadata.
106
+ #
107
+ # Raises an error if access is denied.
108
+ def deregister_command(command)
109
+ key = "#{command_key_prefix}#{command.id}.json"
110
+ s3.delete_object(
111
+ bucket: bucket_name,
112
+ key: key,
113
+ )
114
+ rescue ::Aws::S3::Errors::AccessDenied
115
+ raise AccessDeniedS3Error.new(bucket: bucket_name, key: key)
116
+ end
117
+
104
118
  # Enqueues a one-off Exec::Command to be run on the application's +exec+ environment.
105
119
  # Does not wait for action to be taken, but returns immediately after enqueuing the command.
106
120
  #
107
- # Raises an error if the exec environment or queue cannot be found.
121
+ # Raises an error if the exec environment or queue cannot be found, or if access is denied.
108
122
  def enqueue_command(command)
109
123
  if environments.none? { |environment| environment.is_a?(Environment::Exec) }
110
124
  raise MissingExecEnvironmentError.new(application: self)
@@ -113,20 +127,12 @@ module ElasticBeans
113
127
  if command.to_s == command
114
128
  command = Exec::Command.new(command_string: command)
115
129
  end
116
- command.metadata[:bucket] = bucket_name
117
- command.metadata[:key] = "#{command_key_prefix}#{command.id}.json"
118
- s3.put_object(
119
- bucket: bucket_name,
120
- key: command.metadata[:key],
121
- body: command.to_json,
122
- )
123
130
 
131
+ register_command(command)
124
132
  sqs.send_message(
125
133
  queue_url: exec_queue_url,
126
134
  message_body: command.to_json,
127
135
  )
128
- rescue ::Aws::S3::Errors::AccessDenied
129
- raise AccessDeniedS3Error.new(bucket: bucket_name, key: command.metadata[:key])
130
136
  end
131
137
 
132
138
  # Fetches up to 100 previously-enqueued commands that are running or scheduled to run.
@@ -197,6 +203,27 @@ module ElasticBeans
197
203
  raise AccessDeniedS3Error.new(bucket: bucket_name, key: key)
198
204
  end
199
205
 
206
+ # Registers command metadata so that #enqueued_commands will find it.
207
+ # Adds +:bucket+ and +:key+ keys to the command's ElasticBeans::Exec::Command#metadata.
208
+ # Used by +beans exec --interactive" so that +beans ps+ displays interactive tasks that are not enqueued normally.
209
+ #
210
+ # Raises an error if access is denied.
211
+ def register_command(command)
212
+ unless exists?
213
+ raise MissingApplicationError.new(application: self)
214
+ end
215
+
216
+ command.metadata[:bucket] = bucket_name
217
+ command.metadata[:key] = "#{command_key_prefix}#{command.id}.json"
218
+ s3.put_object(
219
+ bucket: bucket_name,
220
+ key: command.metadata[:key],
221
+ body: command.to_json,
222
+ )
223
+ rescue ::Aws::S3::Errors::AccessDenied
224
+ raise AccessDeniedS3Error.new(bucket: bucket_name, key: command.metadata[:key])
225
+ end
226
+
200
227
  # Returns an ElasticBeans::ApplicationVersion for each version of the Elastic Beanstalk application.
201
228
  def versions
202
229
  response = elastic_beanstalk.describe_application_versions(application_name: name)
@@ -59,8 +59,13 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
59
59
  begin
60
60
  ui.debug { "Freezing exec instance... (ID=#{freeze_command.id})" }
61
61
  application.enqueue_command(freeze_command)
62
+ application.register_command(command)
63
+
62
64
  freeze_command = wait_until_command_taken(freeze_command)
63
65
  ui.debug { "Frozen exec instance: '#{freeze_command.instance_id}'" }
66
+ command.instance_id = freeze_command.instance_id
67
+ command.start_time = freeze_command.start_time
68
+ application.register_command(command)
64
69
 
65
70
  begin
66
71
  instance_ip = ec2.describe_instances(instance_ids: [freeze_command.instance_id]).reservations[0].instances[0].private_ip_address
@@ -105,6 +110,7 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
105
110
  raise BastionAuthenticationError.new(cause: e)
106
111
  ensure
107
112
  application.kill_command(freeze_command)
113
+ application.deregister_command(command)
108
114
  end
109
115
  else
110
116
  application.enqueue_command(command)
@@ -13,10 +13,10 @@ module ElasticBeans
13
13
  attr_reader :command_string
14
14
 
15
15
  # The instance ID this command is being executed on.
16
- attr_reader :instance_id
16
+ attr_accessor :instance_id
17
17
 
18
18
  # The time this command started execution.
19
- attr_reader :start_time
19
+ attr_accessor :start_time
20
20
 
21
21
  # Command metadata, such as where to store execution data in S3.
22
22
  attr_reader :metadata
@@ -65,7 +65,7 @@ class SQSConsumer
65
65
  log("Freeze command ID=#{command['id']} never terminated; timing out after #{FREEZE_TIMEOUT} seconds")
66
66
  end
67
67
  else
68
- # poll command metadata to see if it is still available, if it disappears then kill the process
68
+ # poll killed metadata to see if it has appeared, if it appears then kill the process
69
69
  killed_thread = Thread.new do
70
70
  while_killed(command) do
71
71
  if already_killed?
@@ -1,3 +1,3 @@
1
1
  module ElasticBeans
2
- VERSION = "0.10.0.alpha10"
2
+ VERSION = "0.10.0.alpha11"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_beans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0.alpha10
4
+ version: 0.10.0.alpha11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stegman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-28 00:00:00.000000000 Z
11
+ date: 2017-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk