Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

newrelic_deployment: updated code to use v2 api #1501

Closed

Conversation

116davinder
Copy link

@116davinder 116davinder commented Dec 16, 2020

SUMMARY

Added support for NewRelic Deployment V2 Api

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

newrelic_deployment

ADDITIONAL INFORMATION
ansible 2.5.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/davinderp/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]

After checking NewRelic Website, as they have depricated v1 api with xml format and they also exposed new v2 api with json/xml so i start this PR to support new v2 api and remove old version.

Original PR on Main Ansible Repoistory: ansible/ansible#40029 [ closed ]
Old PR: #876 [ closed ]

If this PR doesn't get merged than anyone can download same code from my personal repository: https://github.com/116davinder/ansible.missing_collection

@ansibullbot
Copy link
Collaborator

cc @mcodd
click here for bot help

@ansibullbot ansibullbot added affects_2.10 community_review feature This issue/PR relates to a feature request module module monitoring needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) labels Dec 16, 2020
@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI stale_ci CI is older than 7 days, rerun before merging labels Dec 16, 2020
@116davinder
Copy link
Author

@felixfontein , can you review this PR?
I have closed last one because somehow I *** up with git rebase.

@ansibullbot ansibullbot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI stale_ci CI is older than 7 days, rerun before merging labels Dec 16, 2020
@felixfontein felixfontein changed the title updated code to use v2 api nenwrelic_deployment: updated code to use v2 api Dec 17, 2020
changelogs/fragments/1501_newrelic_v2_api_change.yml Outdated Show resolved Hide resolved
plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
are defined")

if module.params['app_name']:
data = 'filter[name]=' + str(module.params['app_name'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use a proper encoding function for forms. Since you are using fetch_url, you can simply pass a dictionary and it will take care of encoding automatically (see https://github.com/ansible-collections/community.hrobot/blob/main/plugins/module_utils/failover.py#L64).

Copy link
Author

Choose a reason for hiding this comment

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

Now, I don't have access to NewRelic so I can't test it.
is this a mandatory change?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to fix a proper method which will encode values correctly. Simple string concatenation is a disaster waiting to happen (in the worst case, a security vulnerability).

Copy link
Author

@116davinder 116davinder Dec 19, 2020

Choose a reason for hiding this comment

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

I can't modify something which I can't test, module created back in 2018 and was tested and still in use as per my knowledge.
If you say, without modify this it can't be merged than so let it be. I will modify in couple of years once I got access to NewRelic again.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's unfortunate. In case you don't change this to use urlencode or simply provide a dict, I will not merge this. Sorry.

Copy link
Author

@116davinder 116davinder Dec 20, 2020

Choose a reason for hiding this comment

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

if this was so important change, Others/You as Reviewer should have pointed out in my first PR & second PR which was there from 2018 but None.
Now you want this to changed. Hell No!

I will not change any working piece of code which can break the new module implementation. As I don't have access to newrelic to test your enforced changes which means deadend.

Have Fun!

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a very trivial change to make, which does not affect the whole module. So I see absolutely no need to point out such problems as early as possible in the review process. And if you don't want to make any changes to the code's behavior, well, then I don't see why a review makes sense anyway.

I've now spend quite some time reviewing your code and changes in my free time. If you are not interested in getting this included, then I guess I totally wasted that time.

Copy link
Author

Choose a reason for hiding this comment

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

what about my time man? do you understand the level of patience from my side ( 2 years ) ?

it's not about trivial change, it's about basic testing, if I can't confirm as maintainer that it will work or not with urlencode/dict then I how i can even make a change, I don't understand that part.

If you have access to NewRelic please make the test with urlencode/dict and suggest the actual code change, I happy to update the code.

Just for your knowledge, half of module will stop working if this data is passed in wrong format as the search api will return none and anyone using app_name as parameter will never work until someone fix it in future.

let's assume your case where it cause some security Issue then it will on NewRelic Side why you/ansible need to worry. NewRelic should not prevent/fix this in there API as a validation and later Ansible Community should fix as part of bugfix process.
Now when I don't have testing resources/credentials, On what base you will merge it even if I change it?

plugins/modules/monitoring/newrelic_deployment.py Outdated Show resolved Hide resolved
@gundalow gundalow added the pr_day Has been reviewed during a PR review Day. https://github.com/ansible/community/issues/407 label Dec 17, 2020
@ansibullbot

This comment has been minimized.

@ansibullbot ansibullbot added the ci_verified Push fixes to PR branch to re-run CI label Dec 17, 2020
@ansibullbot ansibullbot removed the ci_verified Push fixes to PR branch to re-run CI label Dec 17, 2020
@felixfontein felixfontein changed the title nenwrelic_deployment: updated code to use v2 api newrelic_deployment: updated code to use v2 api Dec 19, 2020
changelogs/fragments/1501_newrelic_v2_api_change.yml Outdated Show resolved Hide resolved
are defined")

if module.params['app_name']:
data = 'filter[name]=' + str(module.params['app_name'])
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to fix a proper method which will encode values correctly. Simple string concatenation is a disaster waiting to happen (in the worst case, a security vulnerability).

@ansibullbot ansibullbot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI stale_ci CI is older than 7 days, rerun before merging labels Dec 19, 2020
@ansibullbot ansibullbot removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI stale_ci CI is older than 7 days, rerun before merging labels Dec 20, 2020
@felixfontein felixfontein added the waiting_on_contributor Needs help. Feel free to engage to get things unblocked label May 1, 2021
@ansibullbot ansibullbot added the stale_ci CI is older than 7 days, rerun before merging label May 1, 2021
@ansibullbot ansibullbot added the needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI label Jun 26, 2021
@ansibullbot
Copy link
Collaborator

@116davinder this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@ansibullbot ansibullbot added merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html and removed community_review labels Jun 26, 2021
@ansibullbot
Copy link
Collaborator

@116davinder this PR contains the following merge commits:

Please rebase your branch to remove these commits.

click here for bot help

@aminvakil
Copy link
Contributor

Do not use merge commits to rebase, use this document to add this repository as upstream of your repository.

You can then use this commands to rebase your branch:
git pull --rebase upstream main
Then you can push your local branch to github.

@116davinder
Copy link
Author

As the Ansible community reviewer is forcing me to add a code that I can't test and verify.

I am closing this PR as it doesn't make any sense to keep it open as nothing will happen in future as nothing happened on my original PR ansible/ansible#40029 which was open for 2+ years, It is just a waste of my time and reviewer time.

Last Notes
Anyone interested in using my code, please head to the below collection or create your custom module from the below collection: https://github.com/116davinder/ansible.missing_collection

@116davinder 116davinder deleted the newrelic_deployment_v2 branch June 27, 2021 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request merge_commit This PR contains at least one merge commit. Please resolve! module module monitoring needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html new_contributor Help guide this first time contributor plugins plugin (any type) pr_day Has been reviewed during a PR review Day. https://github.com/ansible/community/issues/407 stale_ci CI is older than 7 days, rerun before merging waiting_on_contributor Needs help. Feel free to engage to get things unblocked
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants