roo_on_rails 1.22.0 → 2.0.0.pre.pre.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,26 @@
1
1
  # To update the build configuration, edit the "builds" array below and run:
2
2
  # erb .circleci/config.yml.erb > .circleci/config.yml
3
+
4
+
5
+ # The default Ruby containers modify the behaviour of Bundler in a way that breaks
6
+ # the CI since it makes it harder to run multiple apps in a single container
7
+ # See https://github.com/docker-library/docs/pull/1221/files for a summary
8
+ # Unsettting these variables restores the default behaviour:-
9
+ # * BUNDLE_APP_CONFIG
10
+ # * GEM_HOME
11
+ # * BUNDLE_PATH
12
+ # * BUNDLE_BIN
13
+
3
14
  <%
4
15
  builds = [
5
- ['2.3.4', 'rails_3'],
6
- ['2.3.4', 'rails_4'],
7
- ['2.4.1', 'rails_4'],
8
- ['2.3.4', 'rails_5'],
9
- ['2.4.1', 'rails_5'],
10
- ['2.3.4', 'rails_5_1'],
11
- ['2.4.1', 'rails_5_1'],
12
- ['2.4.1', 'rails_5_2']
16
+ ['2.4.6', 'rails_4'],
17
+ ['2.4.6', 'rails_5'],
18
+ ['2.4.6', 'rails_5_1'],
19
+ ['2.4.6', 'rails_5_2'],
20
+ ['2.5.5', 'rails_4'],
21
+ ['2.5.5', 'rails_5'],
22
+ ['2.5.5', 'rails_5_1'],
23
+ ['2.5.5', 'rails_5_2']
13
24
  ]
14
25
  %>
15
26
  version: 2
@@ -17,7 +28,7 @@ jobs:
17
28
  <% builds.each do |ruby,variant| %>
18
29
  build_<%= ruby %>_<%= variant %>:
19
30
  docker:
20
- - image: deliveroo/multiruby
31
+ - image: ruby:<%= ruby %>-alpine
21
32
  - image: postgres:9.6-alpine
22
33
  environment:
23
34
  PGDATA: /dev/shm/pgdata
@@ -33,28 +44,50 @@ jobs:
33
44
  ln -s /dev/shm/tmp ~/project/tmp
34
45
 
35
46
  - run:
36
- name: Select build variant (Ruby <%= ruby %>, <%= variant %>)
47
+ name: Setup requirements
37
48
  command: |
38
- rbenv local <%= ruby %> ;
39
- gem install bundler ;
49
+ apk add --update git bash build-base postgresql-dev sqlite-dev tzdata nodejs
50
+
51
+ - run:
52
+ name: Configure bundler
53
+ command: |
54
+ unset \
55
+ BUNDLE_APP_CONFIG \
56
+ GEM_HOME \
57
+ BUNDLE_PATH \
58
+ BUNDLE_BIN
40
59
  bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
41
60
 
42
61
  - restore_cache:
43
- keys:
62
+ keys:
44
63
  - v2-bundle-<%= ruby %>-<%= variant %>-{{ .Branch }}
45
64
  - v2-bundle-<%= ruby %>-<%= variant %>
46
65
  - v2-bundle-<%= ruby %>
47
66
 
48
- - run:
49
- name: Install dependencies
67
+ - run:
68
+ name: Install bundle
50
69
  command: |
70
+ unset \
71
+ BUNDLE_APP_CONFIG \
72
+ GEM_HOME \
73
+ BUNDLE_PATH \
74
+ BUNDLE_BIN
51
75
  bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
52
76
 
77
+ # The default Ruby containers modify the behaviour of Bundler in a way that breaks
78
+ # the CI since it makes it harder to run multiple apps in a single container
79
+ # See https://github.com/docker-library/docs/pull/1221/files for a summary
80
+ # Unsettting the variables restores the default behaviour
53
81
  - run:
54
82
  name: Run test suite
55
83
  command: |
56
- unset RACK_ENV &&
57
- unset RAILS_ENV &&
84
+ unset \
85
+ RACK_ENV \
86
+ RAILS_ENV \
87
+ BUNDLE_APP_CONFIG \
88
+ GEM_HOME \
89
+ BUNDLE_PATH \
90
+ BUNDLE_BIN
58
91
  bundle exec rspec
59
92
 
60
93
  - save_cache:
data/Appraisals CHANGED
@@ -1,10 +1,3 @@
1
- appraise 'rails-3' do
2
- gem 'rails', '~> 3.2'
3
- gem 'sqlite3'
4
- gem 'sidekiq', '< 5'
5
- gem 'pg', '~> 0.11'
6
- end
7
-
8
1
  appraise 'rails-4' do
9
2
  gem 'rails', '~> 4.2'
10
3
  gem 'sqlite3'
@@ -1,8 +1,22 @@
1
+ # v2.0.0-pre.1
2
+
3
+ Features:
4
+
5
+ - Remove New Relic
6
+
7
+ # v1.23.0 (2019-04-24)
8
+
9
+ Features:
10
+
11
+ - Setting DATABASE_STATEMENT_TIMEOUT to -1 will prevent the app setting any timeout.
12
+ Setting timeouts from the app conflicts with PGBouncer and should be disabled if
13
+ using one.
14
+
1
15
  # v1.22.0 (2018-08-29)
2
16
 
3
17
  Features:
4
18
 
5
- - Allows specifiying `BASE_NEW_RELIC_APP_NAME` instead of `NEW_RELIC_APP_NAME`, which reports to New Relic per Hopper service.
19
+ - Allows specifying `BASE_NEW_RELIC_APP_NAME` instead of `NEW_RELIC_APP_NAME`, which reports to New Relic per Hopper service.
6
20
 
7
21
  # v1.21.0 (2018-03-27)
8
22
 
data/README.md CHANGED
@@ -17,17 +17,21 @@
17
17
 
18
18
  - [Installation](#installation)
19
19
  - [Library usage](#library-usage)
20
- - [New Relic configuration](#new-relic-configuration)
21
20
  - [Rack middleware](#rack-middleware)
21
+ - [Disabling SSL enforcement](#disabling-ssl-enforcement)
22
22
  - [Database configuration](#database-configuration)
23
23
  - [Sidekiq](#sidekiq)
24
24
  - [HireFire](#hirefire)
25
+ - [For Web Dynos](#for-web-dynos)
26
+ - [For Sidekiq Workers](#for-sidekiq-workers)
25
27
  - [Logging](#logging)
26
28
  - [Identity](#identity)
27
29
  - [Google OAuth authentication](#google-oauth-authentication)
28
30
  - [Datadog Integration](#datadog-integration)
31
+ - [Heroku metrics](#heroku-metrics)
32
+ - [Custom application metrics](#custom-application-metrics)
29
33
  - [Routemaster Client](#routemaster-client)
30
- - [API Authentication ](#api-authentication)
34
+ - [API Authentication](#api-authentication)
31
35
  - [Command features](#command-features)
32
36
  - [Usage](#usage)
33
37
  - [Description](#description)
@@ -48,11 +52,6 @@ Remove the following gems from your Gemfile, as they're provided and configured
48
52
  by `roo_on_rails`:
49
53
 
50
54
  - `dotenv`
51
- - `newrelic_rpm`
52
-
53
- Remove the following configuration files:
54
-
55
- - `newrelic.yml` or `config/newrelic.yml`
56
55
 
57
56
  Also remove any other gem-specific configuration from your repository.
58
57
 
@@ -62,23 +61,19 @@ And then execute:
62
61
 
63
62
  Then re-run your test suite to make sure everything is shipshape.
64
63
 
65
- ## Library usage
64
+ ## Running specs
65
+
66
+ To run the specs locally, you will need to run the following command:
66
67
 
67
- ### New Relic configuration
68
+ ```ruby
69
+ bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
70
+ ```
68
71
 
69
- We enforce configuration of New Relic.
72
+ Where `<%= variant %>` is the Rails version you'd like to test (e.g. `rails_5_2`).
70
73
 
71
- 1. Your app must be loaded with a `NEW_RELIC_LICENSE_KEY` environment variable,
72
- otherwise it will abort.
73
- 2. No `new_relic.yml` file may be presentin your app. Overrides to New Relic settings
74
- through [environment
75
- variables](https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-configuration)
76
- is permitted.
77
- 3. The `NEW_RELIC_APP_NAME` environment variable must be defined
78
- such that the app will be properly registered in New Relic.
74
+ `bundle exec rspec` should then work as normal.
79
75
 
80
- No further configuration is required for production apps as the gem configures
81
- our standard settings.
76
+ ## Library usage
82
77
 
83
78
  ### Rack middleware
84
79
 
@@ -104,6 +99,11 @@ To do this, you can set the `ROO_ON_RAILS_DISABLE_SSL_ENFORCEMENT` to `YES`.
104
99
  The database statement timeout will be set to a low value by default. Use
105
100
  `DATABASE_STATEMENT_TIMEOUT` (milliseconds, default 200) to customise.
106
101
 
102
+ When using a PGBouncer, setting the timeout from the application will cause
103
+ inconsistent results. The timeout should always be set using the RDS parameter
104
+ group in thise case. To prevent the app trying to set a timeout, set
105
+ `DATABASE_STATEMENT_TIMEOUT` to -1.
106
+
107
107
  For database creation and migration (specifically the `db:create`, `db:migrate`,
108
108
  `db:migrate:down` and `db:rollback` tasks) a much higher statement timeout is
109
109
  set by default. Use `MIGRATION_STATEMENT_TIMEOUT` (milliseconds, default 10000)
data/appraise CHANGED
@@ -5,7 +5,7 @@
5
5
  require 'yaml'
6
6
 
7
7
 
8
- RUBIES = YAML.load_file('.travis.yml')['rvm']
8
+ RUBIES = ['2.4.5', '2.5.5']
9
9
  APPRAISALS = `appraisal list`.strip.split(/\s+/)
10
10
 
11
11
  # setup
@@ -36,6 +36,11 @@ module RooOnRails
36
36
  end
37
37
 
38
38
  def run
39
+ # Force output to be unbuffered, otherwise the CI
40
+ # tests will fail because the parent app won't see
41
+ # the log output from the test app
42
+ $stdout.sync = true
43
+ $stderr.sync = true
39
44
  _assert_argv_length(0..0)
40
45
  require 'roo_on_rails/sidekiq/loader'
41
46
  RooOnRails::Sidekiq::Loader.run
@@ -7,7 +7,7 @@ gem "guard-rspec"
7
7
  gem "appraisal"
8
8
  gem "webmock"
9
9
  gem "pg", "~> 0.11"
10
- gem "sqlite3"
10
+ gem "sqlite3", "~> 1.3.6"
11
11
  gem "rails", "~> 4.2"
12
12
 
13
13
  gemspec path: "../"
@@ -7,7 +7,7 @@ gem "guard-rspec"
7
7
  gem "appraisal"
8
8
  gem "webmock"
9
9
  gem "pg", "~> 0.18"
10
- gem "sqlite3"
10
+ gem "sqlite3", "~> 1.3.6"
11
11
  gem "rails", "~> 5.0.0"
12
12
 
13
13
  gemspec path: "../"
@@ -7,7 +7,6 @@ if defined?(Rails)
7
7
  require 'dotenv/rails-now'
8
8
  require 'roo_on_rails/railties/logging'
9
9
  require 'roo_on_rails/railties/env'
10
- require 'roo_on_rails/railties/new_relic'
11
10
  require 'roo_on_rails/railties/database'
12
11
  require 'roo_on_rails/railties/http'
13
12
  require 'roo_on_rails/railties/sidekiq_integration'
@@ -20,10 +20,6 @@ As a last resort, in an emergency, the following people have experience working
20
20
 
21
21
  FIXME: A very brief high-level explanation of what this functional area does
22
22
 
23
- #### 🚨 FIXME: a New Relic alert which might be raised - named so it can be searched for
24
-
25
- FIXME: A description of the New Relic alert, what it means for the service, and what actions should be taken to remedy the situation.
26
-
27
23
  #### 🚨 FIXME: an action which might need to be taken during an incident
28
24
 
29
25
  FIXME: A description of how to perform this action, and any side-effects that the on-call engineer should be aware of.
@@ -58,7 +58,6 @@ module RooOnRails
58
58
  def valid?(service_name, client_key)
59
59
  return false unless whitelisted?(service_name)
60
60
 
61
- NewRelic::Agent.add_custom_attributes(httpBasicUserId: service_name) if defined?(NewRelic)
62
61
  ClientApiKeys.instance.valid?(service_name, client_key)
63
62
  end
64
63
 
@@ -4,15 +4,6 @@ GOOGLE_AUTH_CLIENT_SECRET=''
4
4
  GOOGLE_AUTH_ALLOWED_DOMAINS=''
5
5
  GOOGLE_AUTH_PATH_PREFIX=/auth
6
6
  GOOGLE_AUTH_CONTROLLER=sessions
7
- NEW_RELIC_LOG=stdout
8
- NEW_RELIC_AGENT_ENABLED=true
9
- NEW_RELIC_MONITOR_MODE=true
10
- NEW_RELIC_BROWSER_MONITORING_AUTO_INSTRUMENT=true
11
- NEW_RELIC_CAPTURE_PARAMS=true
12
- NEW_RELIC_TRANSACTION_TRACER_RECORD_SQL=obfuscated
13
- NEW_RELIC_TRANSACTION_TRACER_RECORD_REDIS_ARGUMENTS=true
14
- NEW_RELIC_DEVELOPER_MODE=false
15
- NEW_RELIC_LICENSE_KEY=override-me
16
7
  RACK_SERVICE_TIMEOUT=10
17
8
  RACK_WAIT_TIMEOUT=30
18
9
  ROUTEMASTER_URL=''
@@ -7,15 +7,22 @@ module RooOnRails
7
7
  class PopulateEnvFromJWT
8
8
  UnacceptableKeyError = Class.new(RuntimeError)
9
9
  VALID_PREFIXES_KEY = 'VALID_IDENTITY_URL_PREFIXES'.freeze
10
+ DEFAULT_MAPPED_URLS = {
11
+ 'https://test.deliveroo.co.uk/' => 'https://orderweb.rooenv-staging.io/',
12
+ 'https://deliveroo.co.uk/' => 'https://orderweb.deliverooapp.com/',
13
+ 'https://identity-staging.deliveroo.com/' => 'https://internal-identity.rooenv-staging.io/',
14
+ 'https://identity.deliveroo.com/' => 'https://internal-identity.deliverooapp.com/'
15
+ }.freeze
10
16
 
11
17
  def self.configured?
12
18
  ENV[VALID_PREFIXES_KEY].present?
13
19
  end
14
20
 
15
- def initialize(app, logger:, skip_sig_verify: true)
21
+ def initialize(app, logger:, skip_sig_verify: true, url_mappings: DEFAULT_MAPPED_URLS)
16
22
  @app = app
17
- @keys = {}
18
23
  @logger = logger
24
+ @url_mappings = url_mappings
25
+ @keys = @mapped_urls = {}
19
26
 
20
27
  if skip_sig_verify && non_prod?
21
28
  @logger.warn "JWTs signature verifification has been switched off in development."
@@ -34,7 +41,7 @@ module RooOnRails
34
41
  rescue UnacceptableKeyError, JSON::JWT::Exception => e
35
42
  # Identifying user is clearly attempting to hack or has been given a totally incorrect
36
43
  # token, log this and flag as Forbidden, without executing the rest of the middleware stack.
37
- ::NewRelic::Agent.notice_error(e) if defined?(NewRelic)
44
+ Raven.report_exception(e) if defined?(Raven)
38
45
  [401, {}, []]
39
46
  end
40
47
 
@@ -86,7 +93,7 @@ module RooOnRails
86
93
  return @keys[key_url] if @keys.key?(key_url)
87
94
 
88
95
  @logger.info "Downloading identity public key from #{key_url}"
89
- json = http_request.get(key_url).body
96
+ json = http_request.get(mapped_url(key_url)).body
90
97
  @keys[key_url] = JSON::JWK.new(json)
91
98
  rescue Faraday::ParsingError
92
99
  raise JSON::JWT::InvalidFormat, 'Downloaded JWK is not a valid JSON file'
@@ -101,6 +108,20 @@ module RooOnRails
101
108
  conf.adapter Faraday.default_adapter
102
109
  end
103
110
  end
111
+
112
+ # Allows us to use internal URLs instead of external ones where appropriate
113
+ def mapped_url(url)
114
+ return @mapped_urls[url] unless @mapped_urls[url].nil?
115
+
116
+ @url_mappings.each do |prefix, replacement|
117
+ next unless url.starts_with?(prefix)
118
+ mapped = url.sub(prefix, replacement)
119
+ @mapped_urls[url] = mapped
120
+ return mapped
121
+ end
122
+
123
+ url
124
+ end
104
125
  end
105
126
  end
106
127
  end
@@ -8,11 +8,14 @@ module RooOnRails
8
8
 
9
9
  config = ActiveRecord::Base.configurations[Rails.env]
10
10
  config['variables'] ||= {}
11
- config['variables']['statement_timeout'] = ENV.fetch('DATABASE_STATEMENT_TIMEOUT', 200)
11
+ statement_timeout = ENV.fetch('DATABASE_STATEMENT_TIMEOUT', 200)
12
+ # Use -1 to disable setting the statement timeout
13
+ unless statement_timeout == '-1'
14
+ config['variables']['statement_timeout'] = statement_timeout
15
+ end
12
16
  if ENV.key?('DATABASE_REAPING_FREQUENCY')
13
17
  config['reaping_frequency'] = ENV['DATABASE_REAPING_FREQUENCY']
14
18
  end
15
-
16
19
  ActiveRecord::Base.establish_connection
17
20
  end
18
21
  end
@@ -1,5 +1,4 @@
1
1
  require 'active_support/concern'
2
- require 'new_relic/agent'
3
2
  require 'roo_on_rails/routemaster/publishers'
4
3
 
5
4
  module RooOnRails
@@ -31,7 +30,7 @@ module RooOnRails
31
30
  begin
32
31
  publisher.publish!(force_publish: force_publish)
33
32
  rescue => e
34
- NewRelic::Agent.notice_error(e)
33
+ Raven.report_exception(e) if defined?(Raven)
35
34
  end
36
35
  end
37
36
  end
@@ -1,3 +1,3 @@
1
1
  module RooOnRails
2
- VERSION = '1.22.0'.freeze
2
+ VERSION = '2.0.0-pre.1'.freeze
3
3
  end
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_runtime_dependency 'dotenv-rails', '~> 2.1'
25
- spec.add_runtime_dependency 'newrelic_rpm'
26
25
  spec.add_runtime_dependency 'rails', '>= 3.2.22', '< 5.3'
27
26
  spec.add_runtime_dependency 'platform-api', '~> 2.0'
28
27
  spec.add_runtime_dependency 'hashie', '~> 3.4'
@@ -38,7 +37,7 @@ Gem::Specification.new do |spec|
38
37
  spec.add_runtime_dependency 'routemaster-client'
39
38
  spec.add_runtime_dependency 'json-jwt', '~> 1.8'
40
39
 
41
- spec.add_development_dependency 'bundler', '~> 1.13'
40
+ spec.add_development_dependency 'bundler'
42
41
  spec.add_development_dependency 'rake', '~> 10.0'
43
42
  spec.add_development_dependency 'rspec', '~> 3.0'
44
43
  spec.add_development_dependency 'thor', '~> 0.19'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roo_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.22.0
4
+ version: 2.0.0.pre.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-03 00:00:00.000000000 Z
11
+ date: 2019-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv-rails
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.1'
27
- - !ruby/object:Gem::Dependency
28
- name: newrelic_rpm
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: rails
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -244,16 +230,16 @@ dependencies:
244
230
  name: bundler
245
231
  requirement: !ruby/object:Gem::Requirement
246
232
  requirements:
247
- - - "~>"
233
+ - - ">="
248
234
  - !ruby/object:Gem::Version
249
- version: '1.13'
235
+ version: '0'
250
236
  type: :development
251
237
  prerelease: false
252
238
  version_requirements: !ruby/object:Gem::Requirement
253
239
  requirements:
254
- - - "~>"
240
+ - - ">="
255
241
  - !ruby/object:Gem::Version
256
- version: '1.13'
242
+ version: '0'
257
243
  - !ruby/object:Gem::Dependency
258
244
  name: rake
259
245
  requirement: !ruby/object:Gem::Requirement
@@ -396,7 +382,6 @@ files:
396
382
  - ".rspec"
397
383
  - ".rubocop.yml"
398
384
  - ".ruby-version"
399
- - ".travis.yml"
400
385
  - Appraisals
401
386
  - CHANGELOG.md
402
387
  - CONTRIBUTING.md
@@ -412,7 +397,6 @@ files:
412
397
  - bin/setup
413
398
  - exe/roo_on_rails
414
399
  - gemfiles/.bundle/config
415
- - gemfiles/rails_3.gemfile
416
400
  - gemfiles/rails_4.gemfile
417
401
  - gemfiles/rails_5.gemfile
418
402
  - gemfiles/rails_5_1.gemfile
@@ -461,7 +445,6 @@ files:
461
445
  - lib/roo_on_rails/railties/google_oauth.rb
462
446
  - lib/roo_on_rails/railties/http.rb
463
447
  - lib/roo_on_rails/railties/logging.rb
464
- - lib/roo_on_rails/railties/new_relic.rb
465
448
  - lib/roo_on_rails/railties/rake_tasks.rb
466
449
  - lib/roo_on_rails/railties/roo_identity.rb
467
450
  - lib/roo_on_rails/railties/routemaster.rb
@@ -479,7 +462,6 @@ files:
479
462
  - lib/roo_on_rails/sidekiq/sla_metric.rb
480
463
  - lib/roo_on_rails/statsd.rb
481
464
  - lib/roo_on_rails/tasks/db.rake
482
- - lib/roo_on_rails/tasks/newrelic.rake
483
465
  - lib/roo_on_rails/version.rb
484
466
  - roo_on_rails.gemspec
485
467
  homepage: https://github.com/deliveroo/roo_on_rails
@@ -497,12 +479,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
497
479
  version: '0'
498
480
  required_rubygems_version: !ruby/object:Gem::Requirement
499
481
  requirements:
500
- - - ">="
482
+ - - ">"
501
483
  - !ruby/object:Gem::Version
502
- version: '0'
484
+ version: 1.3.1
503
485
  requirements: []
504
486
  rubyforge_project:
505
- rubygems_version: 2.6.11
487
+ rubygems_version: 2.7.7
506
488
  signing_key:
507
489
  specification_version: 4
508
490
  summary: Scaffolding for building services