Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-22107

Bamboo not honouring http.nonProxyHosts when fetching list of Bitbucket mirrors

    XMLWordPrintable

Details

    Description

      Issue Summary

      Bamboo is not honouring the http.nonProxyHosts property (whether it's inside setenv.sh, catalina.properties, and etc) when fetching the list of mirrors from Bitbucket Server and/or Data Center. In other words, Bamboo is using the proxy to try and fetch the list of mirrors even when it shouldn't.

      This is reproducible on Data Center:

      Steps to Reproduce

      Make sure you have a Bitbucket Server or Data Center instance up & running and with at least one mirror synchronized before going through the steps below.

      1. Set up Bamboo to start with the following Java properties:
        -Dhttps.proxyHost=197.17.128.205 -Dhttps.proxyPort=80 -Dhttp.proxyHost=197.17.128.205 -Dhttp.proxyPort=80 -DproxyHost=197.17.128.205 -DproxyPort=80 -Dhttp.nonProxyHosts=
        
      2. Update the -Dhttp.nonProxyHosts property to include the hostname(s) of your Bitbucket instance and mirror(s). Here are some examples:
        -Dhttp.nonProxyHosts="my-bitbucket.com|mirror1.somehostname.com|localhost|127.0.0.1"
        
      3. Restart Bamboo.
      4. You should be able to create an application link to Bitbucket if you don't have one already - if you do, check the app link connection. It should be successful. This means Bamboo is not using the proxy when talking to Bitbucket (due to the Dhttp.nonProxyHosts property) and the connection can be established.
      5. Create a linked repository inside Bamboo from the Bamboo administration > Linked repositories page pointing to a Bitbucket repository.
      6. Expand the Advanced options section in your linked repository configuration and attempt to load the list of mirrors from the Mirror field.
        • Remember to create a repository inside Bitbucket first. Make sure that the project the repository belongs to has been synced to at least one of the mirrors.

      Expected Results

      The Mirror drop-down button will display the list of mirrors.

      Actual Results

      Only the primary mirror shows up in the Mirror drop-down button.

      By default you won't see any exceptions in the <bamboo-home>/logs/atlassian-bamboo.log files. You must set the following classes to DEBUG inside the Bamboo administration > Overview > System > Log settings page if you want to see more details:

      • org.apache.http.client
      • com.atlassian.bamboo.plugins.stash

      The below exception is thrown in the <bamboo-home>/logs/atlassian-bamboo.log file:

      2023-02-20 16:43:03,102 DEBUG [http-nio-8085-exec-23] [BitbucketSeverMirrorClient] Error connecting to mirror: Cloud Deployments Bitbucket Mirror Node
      java.lang.RuntimeException: org.apache.http.conn.ConnectTimeoutException: Connect to 197.17.128.205:80 [/197.17.128.205] failed: connect timed out
      	at com.atlassian.bamboo.rest.utils.RESTCall.execute(RESTCall.java:187)
      	at com.atlassian.bamboo.plugins.stash.BitbucketSeverMirrorClient.readSSHHrefFromUrl(BitbucketSeverMirrorClient.java:46)
      	at com.atlassian.bamboo.plugins.stash.BitbucketSeverMirrorClient.enrichWithSshUrl(BitbucketSeverMirrorClient.java:34)
      	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
      	at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177)
      	at java.base/java.util.Collections$2.tryAdvance(Collections.java:4747)
      	at java.base/java.util.Collections$2.forEachRemaining(Collections.java:4755)
      	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658)
      	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:274)
      	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
      	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
      	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
      	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
      	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
      	at com.atlassian.bamboo.plugins.stash.BitbucketSeverMirrorHelper.getRepositoryMirrors(BitbucketSeverMirrorHelper.java:101)
      	at com.atlassian.bamboo.plugins.stash.BitbucketSeverMirrorHelper.getRepositoryMirrors(BitbucketSeverMirrorHelper.java:76)
      	at com.atlassian.bamboo.plugins.stash.rest.resource.StashResource.lambda$null$11(StashResource.java:396)
      	at com.atlassian.bamboo.plugins.stash.rest.resource.StashResource.buildResponseWithExceptionsHandling(StashResource.java:227)
      	at com.atlassian.bamboo.plugins.stash.rest.resource.StashResource.buildResponseWithExceptionsHandling(StashResource.java:238)
      	at com.atlassian.bamboo.plugins.stash.rest.resource.StashResource.lambda$getRepositoryMirrors$12(StashResource.java:393)
      	at io.atlassian.fugue.Either$RightProjection.map(Either.java:923)
      	at io.atlassian.fugue.Either.map(Either.java:217)
      	at com.atlassian.bamboo.plugins.stash.rest.resource.StashResource.getRepositoryMirrors(StashResource.java:392)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      	at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper$ResponseOutInvoker.lambda$_dispatch$0(DispatchProviderHelper.java:181)
      	at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper.lambda$invokeMethodWithInterceptors$0(DispatchProviderHelper.java:81)
      	at com.atlassian.plugins.rest.common.interceptor.impl.DefaultMethodInvocation.invoke(DefaultMethodInvocation.java:53)
      	at com.atlassian.bamboo.plugins.stash.rest.interceptor.ProfilingInterceptor.intercept(ProfilingInterceptor.java:21)
      	at com.atlassian.plugins.rest.common.interceptor.impl.DefaultMethodInvocation.invoke(DefaultMethodInvocation.java:53)
      	at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper.invokeMethodWithInterceptors(DispatchProviderHelper.java:106)
      	at com.atlassian.plugins.rest.common.interceptor.impl.DispatchProviderHelper$ResponseOutInvoker._dispatch(DispatchProviderHelper.java:180)
      	at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
              ...
      Caused by: org.apache.http.conn.ConnectTimeoutException: Connect to 197.17.128.205:80 [/197.17.128.205] failed: connect timed out
      	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:151)
      	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
      	at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:401)
      	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
      	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
      	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
      	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
      	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
      	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
      	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
      	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
      	at com.atlassian.bamboo.rest.utils.RESTCall.execute(RESTCall.java:175)
      	... 244 more
      Caused by: java.net.SocketTimeoutException: connect timed out
      	at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
      	at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:412)
      	at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:255)
      	at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:237)
      	at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      	at java.base/java.net.Socket.connect(Socket.java:609)
      	at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
      	at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
      	... 255 more
      

      You'll see a connection timeout because the proxy doesn't really exist. This is expected. We're using fake proxy settings to demonstrate the issue. The point is that Bamboo is attempting to use the proxy to talk to the mirror when it shouldn't.

      Workaround

      Run a local proxy on the local host and create custom rules to forward the traffic to the desired upstream proxy if necessary. You will need to run software such as TinyProxy, Squid, Delegated, etc. Then, configure Bamboo to use that proxy and do not specify the http.nonProxyHosts property.

      Here's a configuration example with TinyProxy that will forward all the traffic to the 197.17.128.205 proxy host on port 80 and will ignore local addresses, local domains and any hosts within a Bitbucket mirror domain name.

      tinyproxy.conf
      ##
      ## tinyproxy.conf -- tinyproxy daemon configuration file
      ##
      User tinyproxy 
      Group tinyproxy
      Port 8888
      Timeout 600
      DefaultErrorFile "/usr/share/tinyproxy/default.html"
      StatFile "/usr/share/tinyproxy/stats.html"
      LogLevel Notice
      Listen 127.0.0.1
      Allow 127.0.0.1
      
      ##
      ## Upstream:
      ##
      
      # Disables upstream forwarding on local domains and CIDRs
      # -Dhttp.nonProxyHosts="mydomain.net|mirror.mybitbucket.com|localhost|127.0.0.1|197.17.128.*" 
      upstream none "localhost"
      upstream none "127.0.0.1"
      upstream none "197.17.128.0/24"
      upstream none ".mydomain.net"
      upstream none ".mirror.mybitbucket.com"
      
      # Generic upstream to forward proxy
      # -Dhttps.proxyHost=197.17.128.205 -Dhttps.proxyPort=80
      # -Dhttp.proxyHost=197.17.128.205 -Dhttp.proxyPort=80
      upstream http 197.17.128.205:80
      

      Then on Bamboo, specify the following proxy properties and restart it.

      -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888
      

      Bamboo will then use the local proxy server which will handle the Proxy ACLs correctly.

      Attachments

        Issue Links

          Activity

            People

              72548a1cec6d Wioletta Dys
              brosa Bruno Rosa
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: