gooddata 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebb2d24e75eda57c8dca39237e1f0a81a8d9a73324278927fff78b99beb0a1db
4
- data.tar.gz: fb22a2ced11bf90f0ff4356ccc361698e20ab80bd8be02161458deaf49d8bade
3
+ metadata.gz: 17915efe04170645f4e8356b210c2c98fadc3926fca45857a6324a537dd85263
4
+ data.tar.gz: 895d3fcf15066eb6df268f000ea83102d3e69727f544dadb24570ee58b050170
5
5
  SHA512:
6
- metadata.gz: 3afb795645aedca94fd96cd58cb92d3e5232e898a98cb231d9f7f5dffcad711a68a6eeb313b1ba04a6c72f2d2b296b3132477e703a859c3995036b47c6de219a
7
- data.tar.gz: 784b70f590256dfabe834d78ec5e9fe6979d41e27a53449826fc330d2a732f2cf5a287d94d7be83a23a72920238b826caa87d26a1fe36493ca35bd3303af0d26
6
+ metadata.gz: 9ee13b4d1c287c7a8d29c504d63863037d13e87cd7f00856d755fc67c81f5e3995378ba2a940dd6a0434a008147a79f0c7278dc4775d60790a598891c001f42d
7
+ data.tar.gz: f4a99bd298c23989a146d172b70649cdc56b848e52686d61abde02e4b700510a12e1d0fa830b42d25ee7d6bdb590b4f1372828bdf701fb7657ea8e11db8d8d74
@@ -0,0 +1,17 @@
1
+ microservices:
2
+ lcm-bricks:
3
+ docker:
4
+ dockerfile: './Dockerfile'
5
+ argumentsFromFiles:
6
+ BRICKS_VERSION: 'VERSION'
7
+
8
+ integratedTests:
9
+ - env: bash
10
+ path: .
11
+ vault:
12
+ GD_SPEC_PASSWORD: secret/v1/ruby/test/bia_encryption_key
13
+ command: ./bin/run_smoke_tests.sh
14
+ image: harbor.intgdc.com/staging/lcm-bricks:GIT_REV
15
+ repo_mount_dir: /src
16
+ microservices:
17
+ - lcm-bricks
data/.travis.yml CHANGED
@@ -20,8 +20,8 @@ jobs:
20
20
  stage: before-merge
21
21
  script: |
22
22
  git remote add upstream https://github.com/gooddata/gooddata-ruby.git
23
- git fetch upstream master
24
- bundle exec pronto run -c upstream/master --exit-code
23
+ git fetch upstream develop
24
+ bundle exec pronto run -c upstream/develop --exit-code
25
25
 
26
26
  - name: unit tests
27
27
  stage: before-merge
@@ -191,16 +191,22 @@ jobs:
191
191
  env: GD_ENV=development
192
192
 
193
193
  - stage: gem-release
194
- rvm:
195
- - 2.3
196
- - jruby-9.1.14
197
- script: echo "Deploying to rubygems.org ..."
194
+ name: deploy MRI gem
195
+ rvm: 2.3
198
196
  deploy:
199
197
  provider: rubygems
200
198
  gem: gooddata
201
199
  api_key: $RUBYGEMS_API_KEY
202
- on:
203
- branch: master
200
+ - &gem-smoke-test
201
+ stage: gem-release
202
+ name: smoke test MRI gem
203
+ rvm: 2.3
204
+ script: |
205
+ gem install gooddata
206
+ ruby -e "require 'gooddata';GoodData.version"
207
+ - <<: *gem-smoke-test
208
+ name: smoke test JRuby gem
209
+ rvm: jruby-9.1.14
204
210
 
205
211
  notifications:
206
212
  email:
data/CHANGELOG.md CHANGED
@@ -1,4 +1,18 @@
1
1
  # GoodData Ruby SDK Changelog
2
+ ## 2.0.1
3
+ - Fix pronto branch
4
+ - Fix requiring version.rb
5
+ - TMA-693 fixed problem with logout after timeout
6
+ - fixup! TMA-807: splunk in k8s
7
+ - Revert "Revert "TMA-807: splunkLogger in bricks forwards messages to RemoteSyslogLogger""
8
+ - TMA-807: splunk in k8s
9
+ - Deploy jruby gem automatically
10
+ - Fix code style issue
11
+ - Revert "Fix splunk test"
12
+ - Revert "TMA-807: splunkLogger in bricks forwards messages to RemoteSyslogLogger"
13
+ - Fix splunk test
14
+ - TMA-807: splunkLogger in bricks forwards messages to RemoteSyslogLogger
15
+
2
16
  ## 2.0.0
3
17
 
4
18
  This is a major version release because the method `.release_info` has been hard-deprecated.
data/Jenkinsfile CHANGED
@@ -5,17 +5,4 @@
5
5
  @Library('pipelines-shared-libs')
6
6
  import com.gooddata.pipeline.Pipeline
7
7
 
8
- def config = [
9
- 'microservices': [
10
- 'lcm-bricks': [
11
- 'docker': [
12
- 'dockerfile': './Dockerfile',
13
- 'arguments': [
14
- 'BRICKS_VERSION': { readFile('./VERSION').trim() }
15
- ]
16
- ]
17
- ]
18
- ]
19
- ]
20
-
21
- Pipeline.get(this, config).run()
8
+ Pipeline.resolve(this).run()
data/SDK_VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.1
data/bin/run_brick.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'remote_syslog_logger'
4
3
  require_relative '../lib/gooddata'
5
4
 
6
5
  DEFAULT_BRICK = 'hello_world_brick'
@@ -9,34 +8,19 @@ HIDDEN_BRICK_PARAMS_PREFIX = 'HIDDEN_BRICK_PARAM_'
9
8
 
10
9
  brick_type = !ARGV.empty? ? ARGV[0] : DEFAULT_BRICK
11
10
 
12
- syslog_node = ENV['NODE_NAME']
13
- log = RemoteSyslogLogger.new(syslog_node, 514, :program => "ruby_#{brick_type}", :facility => 'local2')
14
-
15
- log.info "action=#{brick_type}_execution status=init"
16
-
17
11
  def get_brick_params(prefix)
18
12
  ENV.select { |k,| k.to_s.match(/^#{prefix}.*/) }.map { |k, v| [k.slice(prefix.length..-1), v] }.to_h
19
13
  end
20
14
 
21
- begin
22
- brick_pipeline = GoodData::Bricks::Pipeline.send("#{brick_type}_pipeline")
23
- normal_params = get_brick_params(BRICK_PARAM_PREFIX)
24
- hidden_params = get_brick_params(HIDDEN_BRICK_PARAMS_PREFIX)
25
- params = normal_params.merge(hidden_params)
26
-
27
- params['values_to_mask'] = hidden_params.values
28
- commit_hash = ENV['GOODDATA_RUBY_COMMIT'] || ''
29
- execution_id = ENV['GDC_EXECUTION_ID']
30
- params['gooddata_ruby_commit'] = commit_hash
31
- params['GDC_LOG_DIRECTORY'] = ENV['GDC_LOG_DIRECTORY'] || '/tmp/'
32
- params['GDC_EXECUTION_ID'] = execution_id
33
- log.info "action=#{brick_type}_execution status=start commit_hash=#{commit_hash} execution_id=#{execution_id}"
34
- @brick_result = brick_pipeline.call(params)
35
- log.info "action=#{brick_type}_execution status=finished"
36
- rescue NoMethodError => e
37
- log.info "action=#{brick_type}_execution status=error Invalid brick type '#{brick_type}', #{e.message}"
38
- raise e
39
- rescue StandardError => e
40
- log.info "action=#{brick_type}_execution status=error #{e.message}"
41
- raise e
42
- end
15
+ brick_pipeline = GoodData::Bricks::Pipeline.send("#{brick_type}_pipeline")
16
+ normal_params = get_brick_params(BRICK_PARAM_PREFIX)
17
+ hidden_params = get_brick_params(HIDDEN_BRICK_PARAMS_PREFIX)
18
+ params = normal_params.merge(hidden_params)
19
+
20
+ params['values_to_mask'] = hidden_params.values
21
+ commit_hash = ENV['GOODDATA_RUBY_COMMIT'] || ''
22
+ execution_id = ENV['GDC_EXECUTION_ID']
23
+ params['gooddata_ruby_commit'] = commit_hash
24
+ params['GDC_LOG_DIRECTORY'] = ENV['GDC_LOG_DIRECTORY'] || '/tmp/'
25
+ params['GDC_EXECUTION_ID'] = execution_id
26
+ brick_pipeline.call(params)
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+
3
+ export LCM_BRICKS_IMAGE_TAG=$GOODDATA_RUBY_COMMIT
4
+ /bin/bash -l -c ". /usr/local/rvm/scripts/rvm && bundle exec rake -f lcm.rake test:smoke"
@@ -4,6 +4,7 @@
4
4
 
5
5
  require_relative '../../mixins/property_accessor'
6
6
  require_relative '../../lcm/helpers/helpers'
7
+ require_relative '../../version'
7
8
 
8
9
  module GoodData
9
10
  module ContextManager
@@ -5,7 +5,7 @@
5
5
  # LICENSE file in the root directory of this source tree.
6
6
 
7
7
  require 'logger'
8
- require 'gooddata/core/splunk_logger'
8
+ require 'gooddata/core/splunk_logger_decorator'
9
9
 
10
10
  require 'gooddata/extensions/true'
11
11
  require 'gooddata/extensions/false'
@@ -13,6 +13,8 @@ require 'gooddata/extensions/integer'
13
13
  require 'gooddata/extensions/string'
14
14
  require 'gooddata/extensions/nil'
15
15
 
16
+ require 'remote_syslog_logger'
17
+
16
18
  using TrueExtensions
17
19
  using FalseExtensions
18
20
  using IntegerExtensions
@@ -47,20 +49,20 @@ module GoodData
47
49
  params['GDC_LOGGER'] = logger
48
50
  GoodData.logging_http_on if params['HTTP_LOGGING'] && params['HTTP_LOGGING'].to_b
49
51
 
50
- # Initialize splunk logger
51
- if params['SPLUNK_LOGGING'] && params['SPLUNK_LOGGING'].to_b
52
+ unless params['NO_SPLUNK_LOGGING'] && params['NO_SPLUNK_LOGGING'].to_b
52
53
  GoodData.logger.info "Statistics collecting is turned ON. All the data is anonymous."
53
- splunk_logger = SplunkLogger.new params['SPLUNK_LOG_PATH'] || GoodData::DEFAULT_SPLUNKLOG_OUTPUT
54
+ # NODE_NAME is set up by k8s execmgr
55
+ syslog_node = ENV['NODE_NAME']
56
+ splunk_file_logger = syslog_node ? RemoteSyslogLogger.new(syslog_node, 514, program: "lcm_ruby_brick", facility: 'local2') : Logger.new(STDOUT)
57
+ splunk_logger = SplunkLoggerDecorator.new splunk_file_logger
54
58
  splunk_logger.level = params['SPLUNK_LOG_LEVEL'] || GoodData::DEFAULT_SPLUNKLOG_LEVEL
55
59
  splunk_logger = splunk_logger.extend(ContextLoggerDecorator)
56
60
  splunk_logger.context_source = GoodData.gd_logger
57
61
  values_to_mask = params['values_to_mask'] || []
58
62
  values_to_mask.concat MaskLoggerDecorator.extract_values params
59
63
  splunk_logger = MaskLoggerDecorator.new(splunk_logger, values_to_mask) if values_to_mask.any?
60
- else
61
- splunk_logger = NilLogger.new
64
+ GoodData.splunk_logging_on splunk_logger
62
65
  end
63
- GoodData.splunk_logging_on splunk_logger
64
66
 
65
67
  # Initialize context: Execution ID
66
68
  GoodData.gd_logger.execution_id = params['GDC_EXECUTION_ID'] || SecureRandom.urlsafe_base64(16)
@@ -42,12 +42,9 @@ module GoodData
42
42
  Rest::Client.disconnect
43
43
  end
44
44
 
45
- def with_connection(options = nil, second_options = nil, third_options = {}, &bl)
46
- connection = connect(options, second_options, third_options)
47
- bl.call(connection)
48
- rescue Exception => e # rubocop:disable RescueException
49
- GoodData.logger.error(e.message)
50
- raise e
45
+ def with_connection(options = nil, second_options = nil, third_options = {}, &block)
46
+ client = connect(options, second_options, third_options)
47
+ block.call(client)
51
48
  ensure
52
49
  disconnect
53
50
  end
@@ -7,7 +7,7 @@
7
7
  require 'rest-client'
8
8
 
9
9
  require_relative 'nil_logger'
10
- require_relative 'splunk_logger'
10
+ require_relative 'splunk_logger_decorator'
11
11
  require_relative 'gd_logger'
12
12
 
13
13
  module GoodData
@@ -21,7 +21,6 @@ module GoodData
21
21
 
22
22
  DEFAULT_SPLUNKLOG_LEVEL = Logger::INFO
23
23
  DEFAULT_SPLUNKLOG_OUTPUT = STDERR
24
- DEFAULT_SPLUNKLOGGER_CLASS = SplunkLogger
25
24
 
26
25
  class << self
27
26
  attr_accessor :logger, :rest_logger, :gd_logger
@@ -46,12 +45,6 @@ module GoodData
46
45
  @logger
47
46
  end
48
47
 
49
- # Turn logging on
50
- #
51
- # ### Example
52
- #
53
- # GoodData.logging_off
54
- #
55
48
  def logging_off
56
49
  @logger = NilLogger.new
57
50
  end
@@ -60,24 +53,12 @@ module GoodData
60
53
  !@logger.instance_of?(NilLogger)
61
54
  end
62
55
 
63
- # Turn logging on with HTTP included
64
- #
65
- # ### Example
66
- #
67
- # GoodData.logging_http_on
68
- #
69
56
  def logging_http_on(level = DEFAULT_RESTLOG_LEVEL, output = DEFAULT_RESTLOG_OUTPUT, klass = DEFAULT_RESTLOGGER_CLASS)
70
57
  @rest_logger = klass.new(output)
71
58
  @rest_logger.level = level
72
59
  @rest_logger
73
60
  end
74
61
 
75
- # Turn logging on
76
- #
77
- # ### Example
78
- #
79
- # GoodData.logging_http_off
80
- #
81
62
  def logging_http_off
82
63
  @rest_logger = NilLogger.new
83
64
  end
@@ -86,17 +67,10 @@ module GoodData
86
67
  !@rest_logger.instance_of?(NilLogger)
87
68
  end
88
69
 
89
- # Turn splunk logging on
90
70
  def splunk_logging_on(logger)
91
71
  gd_logger.logging_on :splunk, logger
92
72
  end
93
73
 
94
- # Turn splunk logging off
95
- #
96
- # ### Example
97
- #
98
- # GoodData.logging_splunk_off
99
- #
100
74
  def splunk_logging_off
101
75
  gd_logger.logging_off :splunk
102
76
  end
@@ -6,7 +6,11 @@ require 'logger'
6
6
 
7
7
  module GoodData
8
8
  # Logger that process given message to format readable by splunk
9
- class SplunkLogger < Logger
9
+ class SplunkLoggerDecorator < Logger
10
+ def initialize(logger = Logger)
11
+ @logger = logger
12
+ end
13
+
10
14
  def hash_to_string(hash)
11
15
  hash.map { |pair| " #{pair[0]}=#{pair[1]}" }.join ""
12
16
  end
@@ -17,7 +21,7 @@ module GoodData
17
21
  def add(severity, message = nil, progname = nil)
18
22
  message = hash_to_string(message) if message.is_a? Hash
19
23
  progname = hash_to_string(progname) if progname.is_a? Hash
20
- super(severity, message, progname) unless (progname && progname.include?("\n")) || (message && message.include?("\n"))
24
+ @logger.add(severity, message, progname) unless (progname && progname.chomp == '') || (message && message.chomp == '')
21
25
  end
22
26
  end
23
27
  end
@@ -33,7 +33,7 @@ module GoodData
33
33
  include Hashie::Extensions::DeepMerge
34
34
  end
35
35
 
36
- set_const :GD_MAX_RETRY, (ENV['GD_MAX_RETRY'] && ENV['GD_MAX_RETRY'].to_i) || 3
36
+ set_const :GD_MAX_RETRY, (ENV['GD_MAX_RETRY'] && ENV['GD_MAX_RETRY'].to_i) || 12
37
37
 
38
38
  class << self
39
39
  def error(msg)
@@ -369,7 +369,7 @@ module GoodData
369
369
  def run_action(action, params)
370
370
  begin
371
371
  GoodData.gd_logger.start_action action, GoodData.gd_logger
372
- GoodData.logger.info("Running #{action.name} action ...")
372
+ GoodData.gd_logger.info("Running #{action.name} action ...")
373
373
  params.clear_filters
374
374
  # Check if all required parameters were passed
375
375
  BaseAction.check_params(action.const_get('PARAMS'), params)
@@ -57,7 +57,6 @@ module GoodData
57
57
  Timeout::Error
58
58
  ]
59
59
 
60
- RETRIES_ON_TOO_MANY_REQUESTS_ERROR = 12
61
60
  RETRY_TIME_INITIAL_VALUE = 1
62
61
  RETRY_TIME_COEFFICIENT = 1.5
63
62
  RETRYABLE_ERRORS << Net::ReadTimeout if Net.const_defined?(:ReadTimeout)
@@ -86,11 +85,10 @@ module GoodData
86
85
 
87
86
  # Retry block if exception thrown
88
87
  def retryable(options = {}, &_block)
89
- opts = { :tries => 1, :on => RETRYABLE_ERRORS }.merge(options)
88
+ opts = { :tries => 12, :on => RETRYABLE_ERRORS }.merge(options)
90
89
 
91
90
  retry_exception = opts[:on]
92
91
  retries = opts[:tries]
93
- too_many_requests_tries = RETRIES_ON_TOO_MANY_REQUESTS_ERROR
94
92
 
95
93
  unless retry_exception.is_a?(Array)
96
94
  retry_exception = [retry_exception]
@@ -102,17 +100,23 @@ module GoodData
102
100
  rescue RestClient::Unauthorized, RestClient::Forbidden => e # , RestClient::Unauthorized => e
103
101
  raise e unless options[:refresh_token]
104
102
  raise e if options[:dont_reauth]
103
+
105
104
  options[:refresh_token].call # (dont_reauth: true)
106
- retry if (retries -= 1) > 0
107
- rescue RestClient::TooManyRequests, RestClient::ServiceUnavailable
108
- GoodData.logger.warn "Too many requests, retrying in #{retry_time} seconds"
105
+ if (retries -= 1) > 0
106
+ retry
107
+ else
108
+ fail e
109
+ end
110
+ rescue RestClient::TooManyRequests, RestClient::ServiceUnavailable, *retry_exception => e
111
+ GoodData.logger.warn "#{e.message}, retrying in #{retry_time} seconds"
109
112
  sleep retry_time
110
113
  retry_time *= RETRY_TIME_COEFFICIENT
111
114
  # 10 requests with 1.5 coefficent should take ~ 3 mins to finish
112
- retry if (too_many_requests_tries -= 1) > 1
113
- rescue *retry_exception => e
114
- GoodData.logger.warn e.inspect
115
- retry if (retries -= 1) > 1
115
+ if (retries -= 1) > 0
116
+ retry
117
+ else
118
+ fail e
119
+ end
116
120
  end
117
121
  yield
118
122
  end
@@ -212,9 +216,14 @@ module GoodData
212
216
 
213
217
  begin
214
218
  clear_session_id
215
- delete(url, :x_gdc_authsst => sst_token) if url
219
+ delete(url, :x_gdc_authsst => sst_token, :tries => 0) if url
216
220
  rescue RestClient::Unauthorized
217
- GoodData.logger.info 'Already disconnected'
221
+ begin
222
+ refresh_token
223
+ delete(url, :x_gdc_authsst => sst_token, :tries => 0) if url
224
+ rescue RestClient::Unauthorized
225
+ GoodData.logger.info 'Already disconnected'
226
+ end
218
227
  end
219
228
 
220
229
  @auth = nil
@@ -337,20 +346,15 @@ module GoodData
337
346
  profile method.to_s.upcase, uri, request_id, stats_on do
338
347
  b = proc do
339
348
  params = fresh_request_params(request_id).merge(options)
340
- begin
341
- case method
342
- when :get
343
- @server[uri].get(params, &user_block)
344
- when :put
345
- @server[uri].put(payload, params)
346
- when :delete
347
- @server[uri].delete(params)
348
- when :post
349
- @server[uri].post(payload, params)
350
- end
351
- rescue RestClient::Exception => e
352
- log_error(e, uri, params, options)
353
- raise e
349
+ case method
350
+ when :get
351
+ @server[uri].get(params, &user_block)
352
+ when :put
353
+ @server[uri].put(payload, params)
354
+ when :delete
355
+ @server[uri].delete(params)
356
+ when :post
357
+ @server[uri].post(payload, params)
354
358
  end
355
359
  end
356
360
  process_response(options, &b)
@@ -589,9 +593,6 @@ ERR
589
593
  fail "Unsupported response content type '%s':\n%s" % [content_type, response.to_str[0..127]]
590
594
  end
591
595
  result
592
- rescue RestClient::Exception => e
593
- GoodData.logger.error "Response: #{e.response}"
594
- raise $ERROR_INFO
595
596
  end
596
597
 
597
598
  def profile(method, path, request_id, stats_on, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gooddata
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kolesnikov
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2019-02-14 00:00:00.000000000 Z
17
+ date: 2019-02-22 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: license_finder
@@ -558,6 +558,7 @@ executables:
558
558
  - release.sh
559
559
  - rollout.sh
560
560
  - run_brick.rb
561
+ - run_smoke_tests.sh
561
562
  - test_projects_cleanup.rb
562
563
  - user_filters.sh
563
564
  - users.sh
@@ -570,6 +571,7 @@ files:
570
571
  - ".document"
571
572
  - ".editorconfig"
572
573
  - ".flayignore"
574
+ - ".gdc-ii-config.yaml"
573
575
  - ".gitignore"
574
576
  - ".pronto.yml"
575
577
  - ".rspec"
@@ -604,6 +606,7 @@ files:
604
606
  - bin/release.sh
605
607
  - bin/rollout.sh
606
608
  - bin/run_brick.rb
609
+ - bin/run_smoke_tests.sh
607
610
  - bin/test_projects_cleanup.rb
608
611
  - bin/user_filters.sh
609
612
  - bin/users.sh
@@ -681,7 +684,7 @@ files:
681
684
  - lib/gooddata/core/nil_logger.rb
682
685
  - lib/gooddata/core/project.rb
683
686
  - lib/gooddata/core/rest.rb
684
- - lib/gooddata/core/splunk_logger.rb
687
+ - lib/gooddata/core/splunk_logger_decorator.rb
685
688
  - lib/gooddata/core/user.rb
686
689
  - lib/gooddata/data/data.rb
687
690
  - lib/gooddata/data/guesser.rb