FEATURE:TMA-1610 - Update metric for client localization and bump LCM version#1800
Conversation
|
Build succeeded (check pipeline). |
|
Build in pipeline check aborted. |
|
Build succeeded (check pipeline). |
|
ok to test |
|
Build succeeded (check pipeline). |
|
Build succeeded (check pipeline). |
|
Build failed (check pipeline). |
|
Build failed (check pipeline). |
|
Build succeeded (check pipeline). |
| params = params.to_hash | ||
| if params.key?('aws_client') | ||
| GoodData.logger.info('Setting up AWS-S3 connection') | ||
| GoodData.logger.warn('The input_source: aws_client is predicated. Please use s3_client instead.') |
| raise 'Unable to connect to AWS. Parameter "accessKey" is missing' if params['s3_client']['accessKey'].blank? | ||
| raise 'Unable to connect to AWS. Parameter "secretKey" is missing' if params['s3_client']['secretKey'].blank? | ||
|
|
||
| params['aws_client'] = {} |
There was a problem hiding this comment.
aws_client is deprecated, we should rewrite it opposite to s3_client instea.
There was a problem hiding this comment.
Updated to use s3_client instead. Thanks
|
Build in pipeline check aborted. |
|
Build succeeded (check pipeline). |
ba6dd35 to
fbb2259
Compare
|
Build in pipeline check aborted. |
fbb2259 to
7843cb8
Compare
|
Build in pipeline check aborted. |
|
Build succeeded (check pipeline). |
|
Build succeeded (check pipeline). |
| def get_s3_config(params) | ||
| s3_config = {} | ||
| if params.key?('aws_client') | ||
| raise 'Unable to connect to AWS. Parameter "aws_client" seems to be empty' unless params['aws_client'] |
There was a problem hiding this comment.
Is this redundant? We already have condition if params.key?('aws_client') ?
There was a problem hiding this comment.
This error happen when the key aws_client is exist but params['aws_client'] is empty. This is old code acctually. Thank you.
| def load_metric_data(params) | ||
| metric_input_source = validate_input_source(params.input_source) | ||
| if metric_input_source.nil? | ||
| GoodData.logger.info('No metric config or it is incorrect, skip metric updating') |
There was a problem hiding this comment.
We should check and log 2 cases differently:
- No metrics config: do not log anything
- invalid config: log WARN message directly in validate_input_source with more information (e.g s3 metric input source missing property [file]).
| File.open(metric_data_source.realize(params), 'r:UTF-8') | ||
| end | ||
| rescue StandardError => e | ||
| GoodData.logger.warn("Unable to get metric data, skip updating: #{e.message}. Error: #{e}") |
There was a problem hiding this comment.
Unable to get metric input source, skip updating metric formats. Error: ...
| expected_keys = %w[tag client_id format] | ||
| unless expected_keys.map(&:to_sym).all? { |s| metrics_hash.first.key? s } | ||
| GoodData.logger.warn("The input metric data is incorrect, expecting at least the following fields: #{expected_keys}") | ||
| return nil |
There was a problem hiding this comment.
Do we require all {expected_keys} or just one key? I suppose required all {expected_keys}
There was a problem hiding this comment.
Yes, the current code is checking for all keys. I will remove "at least" to avoid confusing.
|
|
||
| updated_clients = params.synchronize.map { |segment| segment.to.map { |client| client[:client_id] } }.flatten.uniq | ||
| data_product = params.data_product | ||
| data_product_clients = data_product.clients |
There was a problem hiding this comment.
Add execution log:
- begin and end updating metrics formats.
- begin and end of each project
| if params.key?('aws_client') | ||
| params['s3_client'] = {} | ||
| elsif params['input_source'] && params['input_source']['bucket'].blank? | ||
| if params['s3_client']['bucket'].present? |
There was a problem hiding this comment.
why we don't move bucket into get_s3_config(...), similar to the other fields.
There was a problem hiding this comment.
The AWS connect step (Aws::S3::Resource.new(symbolized_config)) will failed if it contains 'bucket' in the parameters. Bucket shoud be specified when we download file.
| s3_client = params['aws_client'] && params['aws_client']['s3_client'] | ||
| s3_client = params['s3_client'] && params['s3_client']['client'] | ||
| raise 'AWS client not present. Perhaps S3Middleware is missing in the brick definition?' if !s3_client || !s3_client.respond_to?(:bucket) | ||
| bucket_name = @options[:bucket] |
There was a problem hiding this comment.
Do we still read bucket from input source?
There was a problem hiding this comment.
Yes, as in my previous answer, we have to use bucket in downloading file.
|
|
||
| def get_s3_config(params) | ||
| s3_config = {} | ||
| if params.key?('aws_client') |
There was a problem hiding this comment.
We should check if both aws_client and s3_client existing and log warning message: "Found two configuration aws_client and s3_client for S3 input source, use aws_client configuration".
|
Build in pipeline check aborted. |
|
ok to test |
|
Build succeeded (check pipeline). |
|
Build succeeded (check pipeline). |
|
Build failed (check pipeline). |
|
Build in pipeline check aborted. |
|
Merge Failed. Zuul merger could not merge this change into the base branch. This is most likely caused by merge conflicts. Please rebase the change and upload the rebased version. In case of further errors, contact the zuul administrator. |
04ed476 to
11df70a
Compare
|
Merge Failed. Zuul merger could not merge this change into the base branch. This is most likely caused by merge conflicts. Please rebase the change and upload the rebased version. In case of further errors, contact the zuul administrator. |
11df70a to
8a1a525
Compare
|
Build failed (check pipeline). |
5baa948 to
9da563d
Compare
|
Build in pipeline check aborted. |
|
Build succeeded (check pipeline). |
|
ok to test |
|
Build succeeded (check pipeline). |
9da563d to
f095ec8
Compare
|
Build failed (check pipeline). |
|
Build succeeded (check pipeline). |
Sonar scan resultMore detail, see in https://sonarqube-gate.intgdc.com/dashboard?id=gooddata-ruby-gate-PR1800 To scan for vulnerabilities in dependencies and run unit tests (to get coverage report in sonar) please comment your PR with 'extended check sonar'. |
|
Build succeeded (gate pipeline).
|
No description provided.