Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-44782

Maven build job attempts to connect to 'dockerhost' even when not running in a docker container

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Labels:
      None
    • Environment:
      Jenkins Master: 2.19.4 LTS running on CentOS7
      Jenkins Slave: CentOS6
      docker-custom-build-environment-plugin 1.6.5
    • Similar Issues:

      Description

      When the docker-custom-build-environment-plugin is installed, and a DNS entry for 'dockerhost' exists, all Maven Build jobs believe they are running in a docker-ized slave node and attempt to run the maven-agent.jar with the argument 'dockerhost:<port>'

       

      This happens even when Jenkins Slaves are not running in containers, and appears to be caused by the logic in the file:

      MavenPluginHelper.java (com.cloudbees.jenkins.plugins.docker_build_env)

       

      I believe this only affects jobs of type 'Maven Build' (not Freestyle job), but I'm not totally sure.

       

      We discovered this because suddenly all of our Maven Build jobs were broken and started invoking maven in the following manner, as soon as a DNS CNAME alias for 'dockerhost' was created in our corporate DNS.  In this particular case, 'dockerhost' was created by a totally separate team of people on our network and not related to our Jenkins infrastructure in any way (and firewalled off from our Jenkins nodes).

       

      When 'dockerhost' is not defined in DNS, maven jobs work correctly:

      Checking out Revision c80a093175952e671c14d26ffaea259bf2772eb6 (refs/remotes/origin/master)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f c80a093175952e671c14d26ffaea259bf2772eb6
       > git rev-list e286a76a8086e96bec65c708f514556be03a882b # timeout=10
      Parsing POMs
      Replacing all maven server entries not found in credentials list is true
      Established TCP socket on 34538
      maven33-agent.jar already up to date
      maven33-interceptor.jar already up to date
      maven3-interceptor-commons.jar already up to date
      [cyberoptic-demo-core-messages] $ /etc/alternatives/java_sdk_1.8.0/bin/java -cp /var/lib/jenkins/slave-node/maven33-agent.jar:/opt/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/opt/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven33Main /opt/apache-maven-3.3.3 /var/lib/jenkins/slave-node/slave.jar /var/lib/jenkins/slave-node/maven33-interceptor.jar /var/lib/jenkins/slave-node/maven3-interceptor-commons.jar 34538
      <===[JENKINS REMOTING CAPACITY]===>channel started
      

      When 'dockerhost' is defined in DNS, maven jobs always seem so think they are running in a docker container, which causes a networking error

      Checking out Revision dec7b232c84c914cf3c4c7f0f18f3c85835b3097 (refs/remotes/origin/master)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f dec7b232c84c914cf3c4c7f0f18f3c85835b3097
       > git rev-list dec7b232c84c914cf3c4c7f0f18f3c85835b3097 # timeout=10
      Parsing POMs
      Replacing all maven server entries not found in credentials list is true
      Established TCP socket on dockerhost:57438
      maven33-agent.jar already up to date
      maven33-interceptor.jar already up to date
      maven3-interceptor-commons.jar already up to date
      [cyberoptic-demo-core-messages] $ /etc/alternatives/java_sdk_1.8.0/bin/java -cp /var/lib/jenkins/slave-node/maven33-agent.jar:/opt/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar:/opt/apache-maven-3.3.3/conf/logging jenkins.maven3.agent.Maven33Main /opt/apache-maven-3.3.3 /var/lib/jenkins/slave-node/slave.jar /var/lib/jenkins/slave-node/maven33-interceptor.jar /var/lib/jenkins/slave-node/maven3-interceptor-commons.jar dockerhost:57438
      Exception in thread "main" java.net.NoRouteToHostException: No route to host
      	at java.net.PlainSocketImpl.socketConnect(Native Method)
      	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      

       

        Attachments

          Issue Links

            Activity

            Hide
            jthornsen Jeff Thornsen added a comment -

            as a workaround, you can edit /etc/hosts on your non-dockerized slave nodes to define 'dockerhost 127.0.0.1', but ideally the plugin would use a better logic to try and determine whether the slave is containerized or not.

            Show
            jthornsen Jeff Thornsen added a comment - as a workaround, you can edit /etc/hosts on your non-dockerized slave nodes to define 'dockerhost 127.0.0.1', but ideally the plugin would use a better logic to try and determine whether the slave is containerized or not.

              People

              • Assignee:
                Unassigned
                Reporter:
                jthornsen Jeff Thornsen
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: