Bug 628755
Summary: | system profile Overview tab not guaranteed to show right IP address if system has more than one address | ||
---|---|---|---|
Product: | Red Hat Satellite 5 | Reporter: | Xixi <xdmoon> |
Component: | Server | Assignee: | Tomas Lestach <tlestach> |
Status: | CLOSED ERRATA | QA Contact: | Jan HutaĆ <jhutar> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 530 | CC: | cperry, jhutar, mpoole, tlestach, xdmoon |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: |
Cause
A bug in identifying of system primary network interface.
Consequence
System profile Overview page shows any of the system IP addresses, not the primary one.
Result
System profile Overview page shows the primary IP address.
|
Story Points: | --- |
Clone Of: | Environment: | ||
Last Closed: | 2011-03-17 14:12:19 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 646488 |
Description
Xixi
2010-08-30 23:22:25 UTC
Looking at the code, this appears to be due to rhn.domain.server.Server.getIpAddress() uses rhn.domain.server.Server.findPrimaryNetworkInterface() and findPrimaryNetworkInterface() to determine which IP Addr to return. Both of the latter methods tries to guess what the primary interface is by iterating the interfaces (which is unordered) and looks for eth0, eth1, localhost, etc. and returns the first interface that matches. This does not guarantee the same IP addr to be returned everytime if there's more than one match. Compare this to /usr/lib/perl5/vendor_perl/5.8.8/Sniglets/Servers.pm and /usr/lib/perl5/vendor_perl/5.8.8/RHN/DB/Server.pm - get_net_infos which returns the first one from the select (as far as I could tell, so it's the same everytime). So, the System Overview and Hardware tabs should agree what the IP addr for the system is, and the more important question is what's the "right" IP addr for a system with multiple NICs? Should we have eth0 always take precedence over eth1 etc.? Should we have user pick a Primary interface (with default being eth0)? spacewalk-java-0.5.44/code/src/com/redhat/rhn/domain/server/Server.java ... /** * Get the primary ip address for this server * @return Returns the primary ip for this server */ public String getIpAddress() { // First search networkInterfaces because they are // better defined (name and ip address) NetworkInterface ni = findPrimaryNetworkInterface(); if (ni != null) { log.debug("Found a NetworkInterface: " + ni.getIpaddr()); return ni.getIpaddr(); } Network n = findPrimaryNetwork(); if (n != null) { log.debug("Found a Network: " + n.getIpaddr()); return n.getIpaddr(); } return null; } /** * Return the NetworkInterface which Spacewalk is guessing is * the primary. Order of preference: * * eth0, eth0*, eth1, eth1*, after that its first match that is * not 127.0.0.1 * * @return NetworkInterface in order of preference: eth0, eth0*, * eth1, eth1*, after that its first match that is not 127.0.0.1 */ public NetworkInterface findPrimaryNetworkInterface() { if (!networkInterfaces.isEmpty()) { Iterator i = networkInterfaces.iterator(); // First pass look for names while (i.hasNext()) { NetworkInterface n = (NetworkInterface) i.next(); boolean notEmpty = !n.isDisabled(); if (n.getName().equals("eth0") && notEmpty) { log.debug("Found eth0"); return n; } if (n.getName().startsWith("eth0") && notEmpty) { log.debug("Found eth0*"); return n; } if (n.getName().equals("eth1") && notEmpty) { log.debug("Found eth1"); return n; } if (n.getName().startsWith("eth1") && notEmpty) { log.debug("Found eth1*"); return n; } } // Second pass look for localhost i = networkInterfaces.iterator(); while (i.hasNext()) { NetworkInterface n = (NetworkInterface) i.next(); String addr = n.getIpaddr(); if (addr != null && !addr.equals("127.0.0.1")) { log.debug("Found NetworkInterface !localhost"); return n; } } // If we didnt match any of the above criteria // just give up and return the 1st one. log.debug("just returning 1st network interface"); return (NetworkInterface) networkInterfaces.iterator().next(); } return null; } // Sometimes java really annoys me private Network findPrimaryNetwork() { if (!networks.isEmpty()) { Iterator i = networks.iterator(); while (i.hasNext()) { Network n = (Network) i.next(); String addr = n.getIpaddr(); if (addr != null && !addr.equals("127.0.0.1")) { log.debug("returning Network that is !localhost"); return n; } } log.debug("giving up, returning 1st Network"); return (Network) networks.iterator().next(); } return null; } ... spacewalk.git: fedf9076caf9d6e8c269239c4ccb4fb4cd3b40f0 Technical note added. If any revisions are required, please edit the "Technical Notes" field accordingly. All revisions will be proofread by the Engineering Content Services team. New Contents: Cause A bug in identifying of system primary network interface. Consequence System profile Overview page shows any of the system IP addresses, not the primary one. Result System profile Overview page shows the primary IP address. An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-0362.html |