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

[JENKINS-61193] Export no_proxy hosts when using HTTP proxy #516

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

Gyanesha
Copy link

@Gyanesha Gyanesha commented Feb 26, 2020

JENKINS-61193 - Export no_proxy hosts when using HTTP proxy

I have added an ArrayList containing all the hosts which don't need any proxy. Then at the time of setting environment variables for proxy I have also set the hosts(e.g. 169.254.169.254) which will not require any proxy.

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have referenced the Jira issue related to my changes in one or more commit messages
  • I have added tests that verify my changes
  • Unit tests pass locally with my changes
  • I have added documentation as necessary
  • No Javadoc warnings were introduced with my changes
  • No spotbugs warnings were introduced with my changes
  • I have interactively tested my changes

Types of changes

What types of changes does your code introduce? Put an x in the boxes that apply

  • Infrastructure change (non-breaking change which updates dependencies or improves infrastructure)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Further comments

If this is a relatively large or complex change, start the discussion by explaining why you chose the solution you did and what alternatives you considered.

@Gyanesha Gyanesha changed the title Added no-proxy hosts when using proxy in CliGitAPIImpl Added no-proxy hosts when using proxy in CliGitAPIImpl [JENKINS-61193] Feb 26, 2020
@codingtim
Copy link

You're not supposed to make the list of non proxy hosts hard coded, these should be retrieved from the configuration on the proxy object.
env.put("no_proxy", getNoProxyHosts());
with implemeation of method:

private String getNoProxyHosts() {
   String noProxyHost = proxy.noProxyHost;
   List<String> noProxyHosts = Lists.newArrayList(Arrays.asList(noProxyHost.split("[ \t\n,|]+")));
   return String.join(",", noProxyHosts);
}

The proxy object is of type hudson.ProxyConfiguration. This class already has some utility methods to retrieve the no proxy hosts as a list of Patterns but that is not usable here.

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Must use the values of NO_PROXY as provided by the Jenkins interface. Must have automated tests that show the NO_PROXY setting is honored.

@MarkEWaite MarkEWaite added the enhancement Improvement or new feature label Mar 2, 2020
@Gyanesha
Copy link
Author

Gyanesha commented Mar 2, 2020

Thanks @codingtim for the help. @MarkEWaite can you tell me whether I should make automated test for checking if the no proxy hosts have been added as no_proxy in the environment variable or something else.

@Gyanesha
Copy link
Author

Gyanesha commented Mar 3, 2020

How will I check whether the NO_PROXY setting is being honored ? Do I have to make some http request to no_proxy host ?

@MarkEWaite
Copy link
Contributor

How will I check whether the NO_PROXY setting is being honored ? Do I have to make some http request to no_proxy host ?

I should have been more clear when I said "NO_PROXY is honored". In this case, I think the reasonable effort task is to place a NO_PROXY into the environment and then confirm that the expected value is in the environment.

As far as I understand it, there are many different ways to configure proxies and each has its own set of common mistakes and challenges. We can't test more than the most basic "is it set" functionality in the test automation.

@Gyanesha
Copy link
Author

Gyanesha commented Mar 3, 2020

I wanted to ask one more question, like why we are not putting the proxy settings in global environment (EnvVar) variable, rather than local env (EnvVar) variable. In the function launchCommandWithCredentials(), we are overwriting env with itself, which in the very begining of the function represented global environment.
env = new EnvVars(env);
Don't we want to reflect the changes in our setting to the global variable.

Copy link
Author

@Gyanesha Gyanesha left a comment

Choose a reason for hiding this comment

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

I have made the required changes in new commit.

@MarkEWaite MarkEWaite changed the title Added no-proxy hosts when using proxy in CliGitAPIImpl [JENKINS-61193] [JENKINS-61193] Add no-proxy hosts when using proxy in CliGitAPIImpl May 25, 2023
@MarkEWaite MarkEWaite requested a review from a team as a code owner September 13, 2023 12:02
@github-actions github-actions bot added the tests Automated test addition or improvement label Jan 17, 2024
@MarkEWaite MarkEWaite changed the title [JENKINS-61193] Add no-proxy hosts when using proxy in CliGitAPIImpl [JENKINS-61193] Export no_proxy hosts when using HTTP proxy Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement or new feature tests Automated test addition or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants