Skip to content

FEATURE:TMA-1610 - Update metric for client localization and bump LCM version#1800

Merged
2 commits merged intogooddata:masterfrom
sangtm:TMA-1601-localize-metric-master
Sep 22, 2021
Merged

FEATURE:TMA-1610 - Update metric for client localization and bump LCM version#1800
2 commits merged intogooddata:masterfrom
sangtm:TMA-1601-localize-metric-master

Conversation

@sangtm
Copy link
Copy Markdown

@sangtm sangtm commented Aug 23, 2021

No description provided.

@sangtm sangtm requested a review from danh-ung August 23, 2021 11:46
@sangtm sangtm added the do not merge Do not merge this yet label Aug 23, 2021
@ghost
Copy link
Copy Markdown

ghost commented Aug 23, 2021

@ghost
Copy link
Copy Markdown

ghost commented Aug 24, 2021

Build in pipeline check aborted.

@ghost
Copy link
Copy Markdown

ghost commented Aug 24, 2021

@sangtm
Copy link
Copy Markdown
Author

sangtm commented Aug 24, 2021

ok to test

@ghost
Copy link
Copy Markdown

ghost commented Aug 24, 2021

@ghost
Copy link
Copy Markdown

ghost commented Aug 27, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 1, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 1, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 1, 2021

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.')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not log this warning message

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it, thanks

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'] = {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws_client is deprecated, we should rewrite it opposite to s3_client instea.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use s3_client instead. Thanks

@ghost
Copy link
Copy Markdown

ghost commented Sep 2, 2021

Build in pipeline check aborted.

@ghost
Copy link
Copy Markdown

ghost commented Sep 2, 2021

@sangtm sangtm force-pushed the TMA-1601-localize-metric-master branch from ba6dd35 to fbb2259 Compare September 3, 2021 10:29
@ghost
Copy link
Copy Markdown

ghost commented Sep 3, 2021

Build in pipeline check aborted.

@sangtm sangtm force-pushed the TMA-1601-localize-metric-master branch from fbb2259 to 7843cb8 Compare September 3, 2021 10:31
@ghost
Copy link
Copy Markdown

ghost commented Sep 3, 2021

Build in pipeline check aborted.

@ghost
Copy link
Copy Markdown

ghost commented Sep 3, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 6, 2021

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']
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this redundant? We already have condition if params.key?('aws_client') ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the code, thanks

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}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to get metric input source, skip updating metric formats. Error: ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this log.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we require all {expected_keys} or just one key? I suppose required all {expected_keys}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add execution log:

  • begin and end updating metrics formats.
  • begin and end of each project

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added logs, thanks

if params.key?('aws_client')
params['s3_client'] = {}
elsif params['input_source'] && params['input_source']['bucket'].blank?
if params['s3_client']['bucket'].present?
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we don't move bucket into get_s3_config(...), similar to the other fields.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still read bucket from input source?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this log. Thanks

@ghost
Copy link
Copy Markdown

ghost commented Sep 9, 2021

Build in pipeline check aborted.

@trung-le-quoc
Copy link
Copy Markdown
Contributor

ok to test

@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

@danh-ung danh-ung removed the do not merge Do not merge this yet label Sep 10, 2021
@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

Build in pipeline check aborted.

@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

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.

@sangtm sangtm force-pushed the TMA-1601-localize-metric-master branch from 04ed476 to 11df70a Compare September 10, 2021 10:50
@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

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.

@sangtm sangtm force-pushed the TMA-1601-localize-metric-master branch from 11df70a to 8a1a525 Compare September 10, 2021 10:55
@ghost
Copy link
Copy Markdown

ghost commented Sep 10, 2021

@sangtm sangtm force-pushed the TMA-1601-localize-metric-master branch from 5baa948 to 9da563d Compare September 13, 2021 02:26
@ghost
Copy link
Copy Markdown

ghost commented Sep 13, 2021

Build in pipeline check aborted.

@ghost
Copy link
Copy Markdown

ghost commented Sep 13, 2021

@sangtm
Copy link
Copy Markdown
Author

sangtm commented Sep 13, 2021

ok to test

@ghost
Copy link
Copy Markdown

ghost commented Sep 13, 2021

@danh-ung danh-ung added the do not merge Do not merge this yet label Sep 14, 2021
@sangtm sangtm changed the title FEATURE:TMA-1601 - Update metric for client localization and bump LCM version FEATURE:TMA-1061 - Update metric for client localization and bump LCM version Sep 22, 2021
@sangtm sangtm changed the title FEATURE:TMA-1061 - Update metric for client localization and bump LCM version FEATURE:TMA-1610 - Update metric for client localization and bump LCM version Sep 22, 2021
@danh-ung danh-ung removed the do not merge Do not merge this yet label Sep 22, 2021
@sangtm sangtm force-pushed the TMA-1601-localize-metric-master branch from 9da563d to f095ec8 Compare September 22, 2021 03:25
@ghost
Copy link
Copy Markdown

ghost commented Sep 22, 2021

@ghost
Copy link
Copy Markdown

ghost commented Sep 22, 2021

@danh-ung danh-ung added the merge label Sep 22, 2021
@yenkins
Copy link
Copy Markdown

yenkins commented Sep 22, 2021

Sonar scan result

More 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'.

@ghost ghost removed the merge label Sep 22, 2021
@ghost ghost merged commit 3beaa51 into gooddata:master Sep 22, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants