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

Perforce can't get hostname for slaves

    Details

    • Similar Issues:

      Description

      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

        Attachments

          Issue Links

            Activity

            Hide
            alexey_larsky 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

            Show
            alexey_larsky 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
            Hide
            rodrigozrusso 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 ?

            Show
            rodrigozrusso 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 ?
            Hide
            oleg_nenashev 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

            Show
            oleg_nenashev 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
            Hide
            alskor 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

            Show
            alskor 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
            Hide
            jameshowe James Howe added a comment -

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

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

              People

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

                Dates

                • Created:
                  Updated: