aws_lambda_ric 1.0.1 → 1.0.2

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
  SHA256:
3
- metadata.gz: b33180932d42b43cbe38aaf19aca5a30c01212a209cec6eb577b62e8139f4d36
4
- data.tar.gz: 64b49034a0cd70a4e974c8bb2c56c8e73cc607b36e66de08622f8daa3fba982f
3
+ metadata.gz: 2f26bf52b90d1b1db9d7a2e81944ac57e1727ff0e65cc4b3b9b5273487b26114
4
+ data.tar.gz: 129773fdf51a5971dbac1661298f364303326d20d98491d600ae482a2e9f81d6
5
5
  SHA512:
6
- metadata.gz: 0dd4f76dabca24fcae696e0780be387eee6bdff75d1bf9b7f95f1d9e5a37a10823bb9f24b521bb9d64e55bf718b36a5a7f9c84625b7bb25fd4cf88eedaf89498
7
- data.tar.gz: 6a95a1763b7263a87201ac82153cb27344e96927a582e3bae95003f29e3dbf1f60089d5791526624cd863d2b17983cdf03c9074a39b8cb85617f082bd796d550
6
+ metadata.gz: 136489e2b2b18427a00b12000b47ad8831b4b1ffef289f7ff340ac1f81af782e0cb782c73d78deaa7ba5abd1e2966fed9f9e94b07313296fc1223d425e5a3f2c
7
+ data.tar.gz: 3f8a95ad5cae417e6e64496b8ba4405f9b85d8c5402017a89921cb08b020762600abe14faca92e8b79df5fd5777340d7c157925606588992d9e1a33c326c075a
@@ -1,22 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- aws_lambda_ric (1.0.1)
4
+ aws_lambda_ric (1.0.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
+ activesupport (6.0.3.4)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 0.7, < 2)
12
+ minitest (~> 5.1)
13
+ tzinfo (~> 1.1)
14
+ zeitwerk (~> 2.2, >= 2.2.2)
15
+ concurrent-ruby (1.1.7)
16
+ i18n (1.8.5)
17
+ concurrent-ruby (~> 1.0)
9
18
  minitest (5.14.2)
10
19
  rake (13.0.1)
20
+ thread_safe (0.3.6)
21
+ tzinfo (1.2.8)
22
+ thread_safe (~> 0.1)
23
+ zeitwerk (2.4.2)
11
24
 
12
25
  PLATFORMS
13
26
  ruby
27
+ x86_64-linux
14
28
 
15
29
  DEPENDENCIES
30
+ activesupport (~> 6.0.1)
16
31
  aws_lambda_ric!
17
32
  bundler (>= 2.0)
18
33
  minitest (~> 5.0)
19
34
  rake (~> 13.0)
20
35
 
21
36
  BUNDLED WITH
22
- 2.2.0.rc.2
37
+ 2.2.2
data/README.md CHANGED
@@ -113,7 +113,7 @@ This runs the image as a container and starts up an endpoint locally at `http://
113
113
  3) Post an event to the following endpoint using a curl command:
114
114
 
115
115
  ```shell script
116
- curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'.
116
+ curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
117
117
  ```
118
118
 
119
119
  This command invokes the function running in the container image and returns a response.
@@ -141,6 +141,18 @@ Then,
141
141
  * to run integration tests: `make test-integ`
142
142
  * to run smoke tests: `make test-smoke`
143
143
 
144
+ ### Troubleshooting
145
+ While running integration tests, you might encounter the Docker Hub rate limit error with the following body:
146
+ ```
147
+ You have reached your pull rate limit. You may increase the limit by authenticating and upgrading: https://www.docker.com/increase-rate-limits
148
+ ```
149
+ To fix the above issue, consider authenticating to a Docker Hub account by setting the Docker Hub credentials as below CodeBuild environment variables.
150
+ ```shell script
151
+ DOCKERHUB_USERNAME=<dockerhub username>
152
+ DOCKERHUB_PASSWORD=<dockerhub password>
153
+ ```
154
+ Recommended way is to set the Docker Hub credentials in CodeBuild job by retrieving them from AWS Secrets Manager.
155
+
144
156
  ## Security
145
157
 
146
158
  If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
@@ -37,4 +37,5 @@ Gem::Specification.new do |spec|
37
37
  spec.add_development_dependency 'bundler', '>= 2.0'
38
38
  spec.add_development_dependency 'minitest', '~> 5.0'
39
39
  spec.add_development_dependency 'rake', '~> 13.0'
40
+ spec.add_development_dependency 'activesupport', '~> 6.0.1'
40
41
  end
@@ -8,6 +8,7 @@ require_relative 'aws_lambda_ric/lambda_handler'
8
8
  require_relative 'aws_lambda_ric/lambda_context'
9
9
  require_relative 'aws_lambda_ric/lambda_logger'
10
10
  require_relative 'aws_lambda_ric/lambda_log_formatter'
11
+ require_relative 'aws_lambda_ric/logger_patch'
11
12
  require_relative 'aws_lambda_ric/telemetry_log_sink'
12
13
  require_relative 'aws_lambda_ric/aws_lambda_marshaller'
13
14
  require_relative 'aws_lambda_ric/xray_cause'
@@ -25,8 +26,8 @@ module AwsLambdaRuntimeInterfaceClient
25
26
 
26
27
  ENV_VAR_RUNTIME_API = 'AWS_LAMBDA_RUNTIME_API'
27
28
 
28
- def initialize(runtime_server_addr)
29
- @lambda_server = LambdaServer.new(runtime_server_addr)
29
+ def initialize(runtime_server_addr, user_agent)
30
+ @lambda_server = LambdaServer.new(runtime_server_addr, user_agent)
30
31
  @runtime_loop_active = true # if false, we will exit the program
31
32
  @exit_code = 0
32
33
  end
@@ -149,23 +150,7 @@ module AwsLambdaRuntimeInterfaceClient
149
150
 
150
151
  def mutate_std_logger
151
152
  Logger.class_eval do
152
- alias_method :orig_initialize, :initialize
153
- def initialize(logdev, shift_age = 0, shift_size = 1048576, level: 'debug',
154
- progname: nil, formatter: nil, datetime_format: nil,
155
- binmode: false, shift_period_suffix: '%Y%m%d')
156
- # use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
157
- if logdev && logdev != $stdout && logdev != $stderr
158
- orig_initialize(logdev, shift_age, shift_size, level, progname,
159
- formatter, datetime_format, binmode, shift_period_suffix)
160
- else
161
- self.level = level
162
- self.progname = progname
163
- @default_formatter = LambdaLogFormatter.new
164
- self.datetime_format = datetime_format
165
- self.formatter = formatter
166
- @logdev = AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.telemetry_log_sink
167
- end
168
- end
153
+ prepend LoggerPatch
169
154
  end
170
155
  end
171
156
 
@@ -30,9 +30,16 @@ module Bootstrap
30
30
  end
31
31
  app_root = Dir.pwd
32
32
  handler = ARGV[0]
33
- lambda_runner = AwsLambdaRuntimeInterfaceClient::LambdaRunner.new(fetch_runtime_server)
33
+ lambda_runner = AwsLambdaRuntimeInterfaceClient::LambdaRunner.new(fetch_runtime_server, get_user_agent)
34
34
  puts "Executing '#{handler}' in function directory '#{app_root}'"
35
35
  lambda_runner.run(app_root, handler)
36
36
  end
37
37
 
38
+ def self.get_user_agent
39
+ ruby_version = RUBY_VERSION.to_s
40
+ version = AwsLambdaRuntimeInterfaceClient::VERSION
41
+
42
+ "aws-lambda-ruby/#{ruby_version}-#{version}"
43
+ end
44
+
38
45
  end
@@ -10,21 +10,22 @@ class LambdaServer
10
10
  LAMBDA_DEFAULT_SERVER_ADDRESS = '127.0.0.1:9001'
11
11
  LAMBDA_RUNTIME_API_VERSION = '2018-06-01'
12
12
 
13
- MAX_HEADER_SIZE = 1024 * 1024
14
- LONG_TIMEOUT = 1_000_000
13
+ MAX_HEADER_SIZE_BYTES = 1024 * 1024
14
+ LONG_TIMEOUT_MS = 1_000_000
15
15
 
16
- def initialize(server_address)
16
+ def initialize(server_address, user_agent)
17
17
  server_address ||= LAMBDA_DEFAULT_SERVER_ADDRESS
18
- @server_address = 'http://' + server_address + '/' + LAMBDA_RUNTIME_API_VERSION
18
+ @server_address = "http://#{server_address}/#{LAMBDA_RUNTIME_API_VERSION}"
19
+ @user_agent = user_agent
19
20
  end
20
21
 
21
22
  def next_invocation
22
23
  next_invocation_uri = URI(@server_address + '/runtime/invocation/next')
23
24
  begin
24
25
  http = Net::HTTP.new(next_invocation_uri.host, next_invocation_uri.port)
25
- http.read_timeout = LONG_TIMEOUT
26
+ http.read_timeout = LONG_TIMEOUT_MS
26
27
  resp = http.start do |connection|
27
- connection.get(next_invocation_uri.path)
28
+ connection.get(next_invocation_uri.path, { 'User-Agent' => @user_agent })
28
29
  end
29
30
  if resp.is_a?(Net::HTTPSuccess)
30
31
  request_id = resp['Lambda-Runtime-Aws-Request-Id']
@@ -51,7 +52,7 @@ class LambdaServer
51
52
  Net::HTTP.post(
52
53
  response_uri,
53
54
  response_object,
54
- { 'Content-Type' => content_type }
55
+ { 'Content-Type' => content_type, 'User-Agent' => @user_agent }
55
56
  )
56
57
  rescue StandardError => e
57
58
  raise LambdaErrors::LambdaRuntimeError.new(e)
@@ -61,8 +62,8 @@ class LambdaServer
61
62
  def send_error_response(request_id:, error_object:, error:, xray_cause:)
62
63
  response_uri = URI(@server_address + "/runtime/invocation/#{request_id}/error")
63
64
  begin
64
- headers = { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type }
65
- headers['Lambda-Runtime-Function-XRay-Error-Cause'] = xray_cause if xray_cause.bytesize < MAX_HEADER_SIZE
65
+ headers = { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type, 'User-Agent' => @user_agent }
66
+ headers['Lambda-Runtime-Function-XRay-Error-Cause'] = xray_cause if xray_cause.bytesize < MAX_HEADER_SIZE_BYTES
66
67
  Net::HTTP.post(
67
68
  response_uri,
68
69
  error_object.to_json,
@@ -79,7 +80,7 @@ class LambdaServer
79
80
  Net::HTTP.post(
80
81
  uri,
81
82
  error_object.to_json,
82
- { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type }
83
+ { 'Lambda-Runtime-Function-Error-Type' => error.runtime_error_type, 'User-Agent' => @user_agent }
83
84
  )
84
85
  rescue StandardError => e
85
86
  raise LambdaErrors::LambdaRuntimeInitError.new(e)
@@ -0,0 +1,21 @@
1
+ # Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+
3
+ module LoggerPatch
4
+ def initialize(logdev, shift_age = 0, shift_size = 1048576, level: 'debug',
5
+ progname: nil, formatter: nil, datetime_format: nil,
6
+ binmode: false, shift_period_suffix: '%Y%m%d')
7
+ # use unpatched constructor if logdev is a filename or an IO Object other than $stdout or $stderr
8
+ if logdev && logdev != $stdout && logdev != $stderr
9
+ super(logdev, shift_age, shift_size, level: level, progname: progname,
10
+ formatter: formatter, datetime_format: datetime_format,
11
+ binmode: binmode, shift_period_suffix: shift_period_suffix)
12
+ else
13
+ self.level = level
14
+ self.progname = progname
15
+ @default_formatter = LambdaLogFormatter.new
16
+ self.datetime_format = datetime_format
17
+ self.formatter = formatter
18
+ @logdev = AwsLambdaRuntimeInterfaceClient::TelemetryLoggingHelper.telemetry_log_sink
19
+ end
20
+ end
21
+ end
@@ -3,5 +3,5 @@
3
3
  # frozen_string_literal: true
4
4
 
5
5
  module AwsLambdaRuntimeInterfaceClient
6
- VERSION = '1.0.1'
6
+ VERSION = '1.0.2'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aws_lambda_ric
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - AWS Lambda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-01 00:00:00.000000000 Z
11
+ date: 2020-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 6.0.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 6.0.1
55
69
  description: The AWS Lambda Ruby Runtime Interface Client implements the Lambda programming
56
70
  model for Ruby.
57
71
  email:
@@ -76,6 +90,7 @@ files:
76
90
  - lib/aws_lambda_ric/lambda_log_formatter.rb
77
91
  - lib/aws_lambda_ric/lambda_logger.rb
78
92
  - lib/aws_lambda_ric/lambda_server.rb
93
+ - lib/aws_lambda_ric/logger_patch.rb
79
94
  - lib/aws_lambda_ric/telemetry_log_sink.rb
80
95
  - lib/aws_lambda_ric/version.rb
81
96
  - lib/aws_lambda_ric/xray_cause.rb