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

Added no_proxy autoconfiguration from rhsm conf and tests #3507

Merged
merged 1 commit into from
Sep 1, 2022
Merged

Added no_proxy autoconfiguration from rhsm conf and tests #3507

merged 1 commit into from
Sep 1, 2022

Conversation

ahitacat
Copy link
Contributor

@ahitacat ahitacat commented Aug 26, 2022

Signed-off-by: ahitacat [email protected]

All Pull Requests:

Check all that apply:

  • Have you followed the guidelines in our Contributing document, including the instructions about commit messages?
  • Is this PR to correct an issue?
  • Is this PR an enhancement?

Complete Description of Additions/Changes:

Insights-client wasn't honoring the no_proxy configuration of /etc/rhsm/rhsm.conf file.

This PR adds the no_proxy value to the auto-configuration module, to retrieve the value of the rhsm configuration file. It provides some tests related to this.

This fix is related to: [rhbz#2065233]((https://bugzilla.redhat.com/show_bug.cgi?id=2065233)

@ahitacat ahitacat added the client These issues represent work to be done by the "client" team. label Aug 26, 2022
@ahitacat ahitacat requested review from subpop, strider and Glutexo August 26, 2022 11:56
@ahitacat ahitacat self-assigned this Aug 29, 2022
@ahitacat ahitacat marked this pull request as ready for review August 29, 2022 16:09
@ahitacat ahitacat removed request for subpop and Glutexo August 30, 2022 10:24
saved_base_url = config.base_url
if ca_cert is not None:
saved_cert_verify = config.cert_verify
config.cert_verify = ca_cert
if proxy is not None:
saved_proxy = config.proxy
config.proxy = proxy
rhsm_no_proxy = None
if rhsm_no_proxy is not None or not '':
config.no_proxy = rhsm_no_proxy
Copy link
Contributor

Choose a reason for hiding this comment

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

The default value of rhsm_no_proxy is None in the function parameters. So why resetting it to None again here? And it looks like we will always pass in the conditional here.

I guess the condition should be this one:

if rhsm_no_proxy and rhsm_no_proxy != '':

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right

@@ -128,6 +132,9 @@ def _try_satellite6_configuration(config):
rhsm_proxy_port = rhsm_config.get('server', 'proxy_port').strip()
rhsm_proxy_user = rhsm_config.get('server', 'proxy_user').strip()
rhsm_proxy_pass = rhsm_config.get('server', 'proxy_password').strip()
rhsm_no_proxy = rhsm_config.get('server', 'no_proxy').strip()
if rhsm_no_proxy.lower() == 'None' or rhsm_no_proxy == '':
Copy link
Contributor

Choose a reason for hiding this comment

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

str.lower() is supposed to return a copy of the string converted to lowercase and you compare it to None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh my mistake, it needs to be compare with 'none'

Resolves: rhbz#2065233

Signed-off-by: ahitacat <[email protected]>
@ahitacat ahitacat requested a review from strider August 30, 2022 11:37
Copy link
Contributor

@strider strider left a comment

Choose a reason for hiding this comment

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

Tested and it works, LGTM.

@@ -128,6 +131,9 @@ def _try_satellite6_configuration(config):
rhsm_proxy_port = rhsm_config.get('server', 'proxy_port').strip()
rhsm_proxy_user = rhsm_config.get('server', 'proxy_user').strip()
rhsm_proxy_pass = rhsm_config.get('server', 'proxy_password').strip()
rhsm_no_proxy = rhsm_config.get('server', 'no_proxy').strip()
if rhsm_no_proxy.lower() == 'none' or rhsm_no_proxy == '':
Copy link
Contributor

Choose a reason for hiding this comment

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

May be simplified as:

if rhsm_no_proxy.lower() in ['none', '']:

But it is just nitpicking here.

@ahitacat
Copy link
Contributor Author

test me

@xiangce xiangce merged commit 894484a into RedHatInsights:master Sep 1, 2022
xiangce pushed a commit that referenced this pull request Sep 1, 2022
Resolves: rhbz#2065233

Signed-off-by: ahitacat <[email protected]>
(cherry picked from commit 894484a)
xiangce pushed a commit that referenced this pull request Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client These issues represent work to be done by the "client" team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants