Skip to content

Commit 3ba4279

Browse files
authored
Merge pull request #361 from aws/1.6.0
1.6.0
2 parents 0efb955 + 4580c70 commit 3ba4279

File tree

28 files changed

+483
-251
lines changed

28 files changed

+483
-251
lines changed

.github/workflows/ruby.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ name: Ruby
99

1010
on:
1111
push:
12-
branches: [ master ]
12+
branches: [ main ]
1313
pull_request:
14-
branches: [ master ]
14+
branches: [ main ]
1515

1616
jobs:
1717
test:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
ruby-version: ['2.6', '2.7']
21+
ruby-version: ['2.7']
2222
steps:
2323
- uses: actions/checkout@v2
2424
- name: Set up Ruby
@@ -28,7 +28,3 @@ jobs:
2828
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
2929
- name: Run tests
3030
run: bundle exec rake
31-
- name: Coveralls
32-
uses: coverallsapp/github-action@master
33-
with:
34-
github-token: ${{ secrets.GITHUB_TOKEN }}

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source 'http://rubygems.org'
77
gemspec
88
gem "process_manager", "0.0.13", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/process_manager-0.0.13"
99
gem "codedeploy-commands", "1.0.0", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/codedeploy-commands-1.0.0"
10+
gem "simple_pid", "0.2.1", :path => "#{File.expand_path(__FILE__)}/../vendor/gems/simple_pid-0.2.1"
1011

1112
group :test do
1213
gem 'test-unit'

Rakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ Rake::TestTask.new(:test) do |t|
1111
t.libs << ['test', 'lib', 'test/helpers']
1212

1313
test_files = FileList.new("test/**/*_test.rb")
14+
test_files.exclude("test/instance_agent/plugins/windows/*_test.rb")
1415
t.test_files = test_files
1516
t.verbose = true
1617
end
1718
task :default => [:version_tracking, :test]
1819
task :release => [:version_tracking, :test]
1920

2021
desc "Run unit tests in spec/"
21-
RSpec::Core::RakeTask.new(:spec)
22+
RSpec::Core::RakeTask.new({:exclude_pattern =>'spec/aws/codedeploy/local/deployer_spec.rb'})
2223
task :test => :spec
2324

2425
begin

bin/codedeploy-agent

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
$:.unshift File.join(File.dirname(File.expand_path('..', __FILE__)), 'lib')
44

5-
ruby_versions = ["3.0", "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"]
5+
ruby_versions = ["3.2", "3.1", "3.0", "2.7", "2.6", "2.5", "2.4", "2.3", "2.2", "2.1", "2.0"]
66
actual_ruby_version = RUBY_VERSION.split('.').map{|s|s.to_i}
77
left_bound = '2.0.0'.split('.').map{|s|s.to_i}
88
ruby_bin = nil

bin/codedeploy-local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ begin
131131
rescue Docopt::Exit => e
132132
puts e.message
133133
exit(false)
134-
rescue AWS::CodeDeploy::Local::CLIValidator::ValidationError,InstanceMetadata::InstanceMetadataError,SystemCallError,ArgumentError => e
134+
rescue AWS::CodeDeploy::Local::CLIValidator::ValidationError,SystemCallError,ArgumentError => e
135135
puts "ERROR: #{e.message}"
136136
exit(false)
137137
rescue Aws::Errors::MissingCredentialsError => e

bin/install

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,39 @@
55
# than 2.0. Testing on multiple Ruby versions is required for
66
# changes to this part of the code.
77
##################################################################
8-
class Proxy
9-
instance_methods.each do |m|
10-
undef_method m unless m =~ /(^__|^send$|^object_id$)/
8+
9+
class LoggerWrapper
10+
def initialize(loggers)
11+
@loggers = loggers
1112
end
1213

13-
def initialize(*targets)
14-
@targets = targets
14+
def debug(message)
15+
@loggers.each do |logger|
16+
logger.debug(message)
17+
end
1518
end
1619

17-
def path
18-
@targets.map do |target|
19-
if target.respond_to?(:path)
20-
target.__send__(:path)
21-
else
22-
# default to to_s since it's just used as a label for log statements.
23-
target.__send__(:to_s)
24-
end
20+
def error(message)
21+
@loggers.each do |logger|
22+
logger.error(message)
2523
end
2624
end
2725

28-
protected
26+
def info(message)
27+
@loggers.each do |logger|
28+
logger.info(message)
29+
end
30+
end
2931

30-
def method_missing(name, *args, &block)
31-
@targets.map do |target|
32-
target.__send__(name, *args, &block)
32+
def level(message)
33+
@loggers.each do |logger|
34+
logger.level = message
35+
end
36+
end
37+
38+
def warn(message)
39+
@loggers.each do |logger|
40+
logger.warn(message)
3341
end
3442
end
3543
end
@@ -40,17 +48,17 @@ require 'logger'
4048

4149
if($stdout.isatty)
4250
# if we are being run in a terminal, log to stdout and the log file.
43-
@log = Logger.new(Proxy.new(File.open(log_file_path, 'a+'), $stdout))
51+
@log = LoggerWrapper.new([Logger.new(log_file_path), Logger.new($stdout)])
52+
@log.level(Logger::INFO)
4453
else
4554
# keep at most 2MB of old logs rotating out 1MB at a time
4655
@log = Logger.new(log_file_path, 2, 1048576)
56+
@log.level = Logger::INFO
4757
# make sure anything coming out of ruby ends up in the log file
4858
$stdout.reopen(log_file_path, 'a+')
4959
$stderr.reopen(log_file_path, 'a+')
5060
end
5161

52-
@log.level = Logger::INFO
53-
5462
require 'net/http'
5563

5664
# This class is copied (almost directly) from lib/instance_metadata.rb
@@ -128,7 +136,7 @@ class IMDS
128136
Net::HTTP.start(IP_ADDRESS, 80, :read_timeout => 10, :open_timeout => 10) do |http|
129137
response = http.request(request)
130138
if block_given?
131-
yield(response)
139+
yield(response)
132140
elsif response.kind_of? Net::HTTPSuccess
133141
response.body
134142
else
@@ -153,7 +161,7 @@ class IMDS
153161
end
154162

155163
class S3Bucket
156-
# Split out as older versions of ruby dont like multi entry attr
164+
# Split out as older versions of ruby dont like multi entry attr
157165
attr :domain
158166
attr :region
159167
attr :bucket
@@ -203,8 +211,8 @@ to check for a running agent.
203211
To use a HTTP proxy, specify --proxy followed by the proxy server
204212
defined by http://hostname:port
205213
206-
This install script needs Ruby version 2.x installed as a prerequisite.
207-
Currently recommended Ruby versions are 2.0.0, 2.1.8, 2.2.4, 2.3, 2.4, 2.5, 2.6 and 2.7.
214+
This install script needs Ruby versions 2.x or 3.x installed as a prerequisite.
215+
Currently recommended Ruby versions are 2.0.0, 2.1.8, 2.2.4, 2.3, 2.4, 2.5, 2.6, 2.7, 3.0, 3.1, and 3.2
208216
If multiple Ruby versions are installed, the default ruby version will be used.
209217
If the default ruby version does not satisfy requirement, the newest version will be used.
210218
If you do not have a supported Ruby version installed, please install one of them first.
@@ -213,7 +221,7 @@ EOF
213221
end
214222

215223
def supported_ruby_versions
216-
['3.0', '2.7', '2.6', '2.5', '2.4', '2.3', '2.2', '2.1', '2.0']
224+
['3.2','3.1','3.0', '2.7', '2.6', '2.5', '2.4', '2.3', '2.2', '2.1', '2.0']
217225
end
218226

219227
# check ruby version, only version 2.x 3.x works
@@ -231,8 +239,8 @@ EOF
231239
if(File.exist?("/usr/bin/ruby#{version}"))
232240
return "/usr/bin/ruby#{version}"
233241
elsif (File.symlink?("/usr/bin/ruby#{version}"))
234-
@log.error("The symlink /usr/bin/ruby#{version} exists, but it's linked to a non-existent directory or non-executable file.")
235-
exit(1)
242+
@log.error("The symlink /usr/bin/ruby#{version} exists, but it's linked to a non-existent directory or non-executable file.")
243+
exit(1)
236244
end
237245
end
238246

@@ -299,10 +307,10 @@ EOF
299307
# change interpreter when symlink /usr/bin/ruby2.x exists, but running with non-supported ruby version
300308
actual_ruby_version = RUBY_VERSION.split('.').map{|s|s.to_i}
301309
left_bound = '2.0.0'.split('.').map{|s|s.to_i}
302-
right_bound = '3.0.0'.split('.').map{|s|s.to_i}
310+
right_bound = '3.2.1'.split('.').map{|s|s.to_i}
303311
if (actual_ruby_version <=> left_bound) < 0
304312
if(!@reexeced)
305-
@log.info("The current Ruby version is not 2.x or 3.0.x! Restarting the installer with #{ruby_interpreter_path}")
313+
@log.info("The current Ruby version is not 2.x or 3.x! Restarting the installer with #{ruby_interpreter_path}")
306314
exec("#{ruby_interpreter_path}", __FILE__, '--re-execed' , *@args)
307315
else
308316
unsupported_ruby_version_error
@@ -393,7 +401,7 @@ EOF
393401
exceptions = [OpenURI::HTTPError, OpenSSL::SSL::SSLError]
394402
begin
395403
uri.open(:ssl_verify_mode => OpenSSL::SSL::VERIFY_PEER, :redirect => true, :read_timeout => 120, :proxy => @http_proxy) do |s3|
396-
package_file.write(s3.read)
404+
package_file.write(s3.read)
397405
end
398406
rescue *exceptions => e
399407
@log.warn("Could not find package to download at '#{uri.to_s}' - Retrying... Attempt: '#{retries.to_s}'")
@@ -406,7 +414,7 @@ EOF
406414
exit(1)
407415
end
408416
end
409-
end
417+
end
410418

411419
def get_version_file_from_s3(s3_bucket, key)
412420
@log.info("Downloading version file from bucket #{s3_bucket.bucket} and key #{key}...")

codedeploy_agent.gemspec

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
22
spec.name = 'aws_codedeploy_agent'
3-
spec.version = '1.5.0'
3+
spec.version = '1.6.0'
44
spec.summary = 'Packages AWS CodeDeploy agent libraries'
55
spec.description = 'AWS CodeDeploy agent is responsible for doing the actual work of deploying software on an individual EC2 instance'
66
spec.author = 'Amazon Web Services'
@@ -9,16 +9,15 @@ Gem::Specification.new do |spec|
99
spec.bindir = ['bin']
1010
spec.require_paths = ['lib']
1111
spec.license = 'Apache-2.0'
12-
spec.required_ruby_version = '~> 2.0'
12+
spec.required_ruby_version = '>= 2.7.0'
1313

1414
spec.add_dependency('gli', '~> 2.5')
1515
spec.add_dependency('json_pure', '~> 1.6')
1616
spec.add_dependency('archive-tar-minitar', '~> 0.5.2')
1717
spec.add_dependency('rubyzip', '~> 1.3.0')
18-
spec.add_dependency('logging', '~> 1.8')
18+
spec.add_dependency('logging', '~> 2.2')
1919
spec.add_dependency('aws-sdk-core', '~> 3')
2020
spec.add_dependency('aws-sdk-s3', '~> 1')
21-
spec.add_dependency('simple_pid', '~> 0.2.1')
2221
spec.add_dependency('docopt', '~> 0.5.0')
2322
spec.add_dependency('concurrent-ruby', '~> 1.1.9')
2423

lib/aws/codedeploy/local/cli_validator.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def validate(args)
2727
raise ValidationError.new("location #{location} cannot be http, only encrypted (https) url endpoints supported")
2828
end
2929

30-
if (uri.scheme != 'https' && uri.scheme != 's3' && !File.exists?(location))
30+
if (uri.scheme != 'https' && uri.scheme != 's3' && !File.exist?(location))
3131
raise ValidationError.new("location #{location} is specified as a file or directory which does not exist")
3232
end
3333

@@ -41,10 +41,10 @@ def validate(args)
4141

4242
if (type == 'directory' && (uri.scheme != 'https' && uri.scheme != 's3' && File.directory?(location)))
4343
appspec_filename = args['--appspec-filename']
44-
if !appspec_filename.nil? && !File.exists?("#{location}/#{appspec_filename}")
44+
if !appspec_filename.nil? && !File.exist?("#{location}/#{appspec_filename}")
4545
raise ValidationError.new("Expecting appspec file at location #{location}/#{appspec_filename} but it is not found there. Please either run the CLI from within a directory containing the #{appspec_filename} file or specify a bundle location containing an #{appspec_filename} file in its root directory")
4646
end
47-
if appspec_filename.nil? && !File.exists?("#{location}/appspec.yml") && !File.exists?("#{location}/appspec.yaml")
47+
if appspec_filename.nil? && !File.exist?("#{location}/appspec.yml") && !File.exist?("#{location}/appspec.yaml")
4848
raise ValidationError.new("Expecting appspec file at location #{location}/appspec.yml or #{location}/appspec.yaml but it is not found there. Please either run the CLI from within a directory containing the appspec.yml or appspec.yaml file or specify a bundle location containing an appspec.yml or appspec.yaml file in its root directory")
4949
end
5050
end

lib/instance_agent/log.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class InstanceAgent::DeploymentLog
88

99
def initialize
1010
deployment_logs_dir = File.join(InstanceAgent::Config.config[:root_dir], 'deployment-logs')
11-
FileUtils.mkdir_p(deployment_logs_dir) unless File.exists? deployment_logs_dir
11+
FileUtils.mkdir_p(deployment_logs_dir) unless File.exist? deployment_logs_dir
1212
@deployment_log ||= Logger.new(File.join(deployment_logs_dir, "#{InstanceAgent::Config.config[:program_name]}-deployments.log"), 8, 64 * 1024 * 1024)
1313
@deployment_log.formatter = proc do |severity, datetime, progname, msg|
1414
"[#{datetime.strftime('%Y-%m-%d %H:%M:%S.%L')}] #{msg}\n"

0 commit comments

Comments
 (0)