• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • p4-plugin
    • Jenkins ver. 1.488
      Perforce 1.3.17, ws isn't managed by perforce plugin

      I have lots of Perforce warnings in log.
      Perforce settings are atteched.

      WARNING: Could not get hostname for slave rusbuilder-ims
      Nov 2, 2012 10:12:26 AM hudson.plugins.perforce.PerforceSCM getEffectiveClientName
      WARNING: Could not get hostname for slave rusbuilder-ims
      Nov 2, 2012 10:12:26 AM hudson.plugins.perforce.PerforceSCM getEffectiveClientName
      WARNING: Could not get hostname for slave rusbuilder-ims
      Nov 2, 2012 10:12:26 AM hudson.plugins.perforce.PerforceSCM getEffectiveClientName
      WARNING: Could not get hostname for slave rusbuilder-ims
      Nov 2, 2012 10:12:26 AM hudson.plugins.perforce.PerforceSCM getEffectiveClientName
      WARNING: Could not get hostname for slave rusbuilder-ims

          [JENKINS-15698] Perforce can't get hostname for slaves

          Rob Petti added a comment -

          This is a problem with core, unfortunately. Getting the hostname of a machine using java is actually quite difficult, so it doesn't work 100% of the time. Check that the hostname is resolvable in DNS, and that the slave isn't running more than one networking interface. Apart from that, there's really nothing else that can be done.

          Rob Petti added a comment - This is a problem with core, unfortunately. Getting the hostname of a machine using java is actually quite difficult, so it doesn't work 100% of the time. Check that the hostname is resolvable in DNS, and that the slave isn't running more than one networking interface. Apart from that, there's really nothing else that can be done.

          Alexey Larsky added a comment - - edited

          Hostname is resolvable, network interface is only one. I also added to etc\hosts self address.
          Warning still present.

          PS. OS Windows 7 Pro x64 SP1 on master and slave.

          Alexey Larsky added a comment - - edited Hostname is resolvable, network interface is only one. I also added to etc\hosts self address. Warning still present. PS. OS Windows 7 Pro x64 SP1 on master and slave.

          James Howe added a comment -

          What version of java is on the slave?

          James Howe added a comment - What version of java is on the slave?

          Alexey Larsky added a comment -

          jre-6u45-windows-i586

          Alexey Larsky added a comment - jre-6u45-windows-i586

          James Howe added a comment -

          Try updating to Java 7. I find only my Java 6 slaves have this issue.

          James Howe added a comment - Try updating to Java 7. I find only my Java 6 slaves have this issue.

          Alexey Larsky added a comment -

          After updating Java to jre-7u60-windows-x64.exe on master and slave the issue still present.
          Strange what it happens only with one of 5 slaves.

          Jun 26, 2014 3:54:15 PM WARNING hudson.plugins.perforce.PerforceSCM getEffectiveClientName
          Could not get hostname for slave builder-slave-1

          Alexey Larsky added a comment - After updating Java to jre-7u60-windows-x64.exe on master and slave the issue still present. Strange what it happens only with one of 5 slaves. Jun 26, 2014 3:54:15 PM WARNING hudson.plugins.perforce.PerforceSCM getEffectiveClientName Could not get hostname for slave builder-slave-1

          Rodrigo Russo added a comment -

          I have the same problem.
          I noticed that Perforce Plugin is using gethostname() from Computer class that is from Jenkins Core code as Rob said.
          Then, I got the method getHostName() from perforce plugin and execute it on script console in Jenkins Master.
          I also got the code snippet from Computer class (jenkins/core/src/main/java/hudson/model/Computer.java) that get the hostname using InetAddress class
          and execute it on script console in the Slave that have this problem.

          Code snippet executed in Master:

          String getHostName(Node node) {
          String host = null;
          try {
          Computer c = node.toComputer();
          if (c != null)

          { host = c.getHostName(); }

          } catch (Exception ex)

          { // fallback to finally }

          finally {
          if (host == null)

          { println "Could not get hostname for slave " << node.getDisplayName(); host = "UNKNOWNHOST"; }

          }
          if (host.contains("."))

          { host = String.valueOf(host.subSequence(0, host.indexOf('.'))); }

          return host;
          }

          Jenkins h = Jenkins.getInstance();
          for (Node n : h.getNodes()) {
          println "Slave: " << n.name;
          println "Hostname: " << getHostName( n);
          println "--------------------------------"
          }

          Result

          Slave: Linux_Slave_1
          Hostname: server01
          --------------------------------
          Slave: Windows_Slave_1
          Could not get hostname for slave Windows_Slave_1
          Hostname: UNKNOWNHOST

          Code snippet executed in Slave that the hostname is unknow (http://jenkins.xpto.net/computer/Windows_Slave_1/script):

          import java.net.InetAddress;

          println "Get hostname by dns"
          InetAddress ia = InetAddress.getByName("server02.xpto.net");
          println ia.getCanonicalHostName();
          println "----------------------------------"
          println "Get hostname by name"
          ia = InetAddress.getByName("server02");
          println ia.getCanonicalHostName();
          println "----------------------------------"
          println "Get hostname by ip"
          ia = InetAddress.getByName("10.0.0.2");
          println ia.getCanonicalHostName();

          Result

          Get hostname by dns
          server02.xpto.net
          ----------------------------------
          Get hostname by name
          server02.xpto.net
          ----------------------------------
          Get hostname by ip
          server02.xpto.net

          So, for my surprise in the slave it can resolve the hostname.

          The firewall in this windows machine is disabled.

          Do you thing that it could be because of the network interface ?
          Do you thing that this menssage "WARNING: Could not get hostname for slave ..." is a warning log?
          What do you think if we change the log level to FINE, due to it spam the jenkins log and don't bring any relevant information ?

          Rodrigo Russo added a comment - I have the same problem. I noticed that Perforce Plugin is using gethostname() from Computer class that is from Jenkins Core code as Rob said. Then, I got the method getHostName() from perforce plugin and execute it on script console in Jenkins Master. I also got the code snippet from Computer class (jenkins/core/src/main/java/hudson/model/Computer.java) that get the hostname using InetAddress class and execute it on script console in the Slave that have this problem. Code snippet executed in Master: String getHostName(Node node) { String host = null; try { Computer c = node.toComputer(); if (c != null) { host = c.getHostName(); } } catch (Exception ex) { // fallback to finally } finally { if (host == null) { println "Could not get hostname for slave " << node.getDisplayName(); host = "UNKNOWNHOST"; } } if (host.contains(".")) { host = String.valueOf(host.subSequence(0, host.indexOf('.'))); } return host; } Jenkins h = Jenkins.getInstance(); for (Node n : h.getNodes()) { println "Slave: " << n.name; println "Hostname: " << getHostName( n); println "--------------------------------" } Result Slave: Linux_Slave_1 Hostname: server01 -------------------------------- Slave: Windows_Slave_1 Could not get hostname for slave Windows_Slave_1 Hostname: UNKNOWNHOST Code snippet executed in Slave that the hostname is unknow ( http://jenkins.xpto.net/computer/Windows_Slave_1/script): import java.net.InetAddress; println "Get hostname by dns" InetAddress ia = InetAddress.getByName("server02.xpto.net"); println ia.getCanonicalHostName(); println "----------------------------------" println "Get hostname by name" ia = InetAddress.getByName("server02"); println ia.getCanonicalHostName(); println "----------------------------------" println "Get hostname by ip" ia = InetAddress.getByName("10.0.0.2"); println ia.getCanonicalHostName(); Result Get hostname by dns server02.xpto.net ---------------------------------- Get hostname by name server02.xpto.net ---------------------------------- Get hostname by ip server02.xpto.net So, for my surprise in the slave it can resolve the hostname. The firewall in this windows machine is disabled. Do you thing that it could be because of the network interface ? Do you thing that this menssage "WARNING: Could not get hostname for slave ..." is a warning log? What do you think if we change the log level to FINE, due to it spam the jenkins log and don't bring any relevant information ?

          Oleg Nenashev added a comment -

          According to Javadoc, hostname is null if...
          > ... if the host name cannot be computed (for example because this computer is offline, because the slave is behind the firewall, etc.)

          The hostname is being calculated using java.net.InetAddress::getCanonicalHostName(), so the real result depends on the implementation in JVM. I see a glitch in Perforce Plugin code, which may cause an NPE. However, it should not cause the described behavior.

          Currently, the most of plugin EnvVar substitutions will fail if they really need ${hostname}.
          I would vote for merging https://github.com/jenkinsci/perforce-plugin/pull/66

          Oleg Nenashev added a comment - According to Javadoc, hostname is null if... > ... if the host name cannot be computed (for example because this computer is offline, because the slave is behind the firewall, etc.) The hostname is being calculated using java.net.InetAddress::getCanonicalHostName(), so the real result depends on the implementation in JVM. I see a glitch in Perforce Plugin code, which may cause an NPE. However, it should not cause the described behavior. Currently, the most of plugin EnvVar substitutions will fail if they really need ${hostname}. I would vote for merging https://github.com/jenkinsci/perforce-plugin/pull/66

          Alex Java added a comment -

          IMHO reducing log prints for unresolvable hostnames is hardly a solution if Perforce Plugin fails to checkout code to a new workspace when hostname cannot be resolved...
          I submitted a proposal to use IP addresses: JENKINS-29734

          Alex Java added a comment - IMHO reducing log prints for unresolvable hostnames is hardly a solution if Perforce Plugin fails to checkout code to a new workspace when hostname cannot be resolved... I submitted a proposal to use IP addresses: JENKINS-29734

          James Howe added a comment -

          Alexey, it doesn't fail to checkout. Everything else is fine.

          James Howe added a comment - Alexey, it doesn't fail to checkout. Everything else is fine.

            Unassigned Unassigned
            alexey_larsky Alexey Larsky
            Votes:
            3 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated: