Bug 628755 - system profile Overview tab not guaranteed to show right IP address if system has more than one address
Summary: system profile Overview tab not guaranteed to show right IP address if system...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Server
Version: 530
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tomas Lestach
QA Contact: Jan Hutař
URL:
Whiteboard:
Depends On:
Blocks: sat54-errata
TreeView+ depends on / blocked
 
Reported: 2010-08-30 23:22 UTC by Xixi
Modified: 2018-11-14 17:26 UTC (History)
5 users (show)

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.
Clone Of:
Environment:
Last Closed: 2011-03-17 14:12:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0362 0 normal SHIPPED_LIVE Red Hat Network Satellite bug fix and enhancement update 2011-03-17 14:10:26 UTC

Description Xixi 2010-08-30 23:22:25 UTC
Description of problem:
System profile of Satellite client shows the incorrect IP Address in the System Details > Overview tab, if the client has more than one IP address. 
Refreshing the System Overview tab shows changing "IP Address" values, alternating between the NICs. It should be consistent and show the same IP addr as shown on the System Details -> Hardware tab.

Version-Release number of selected component (if applicable):
Red Hat Network (RHN) Satellite 5.3.0

How reproducible:
Always.

Steps to Reproduce:
1. Register a system with multiple NIC/ipaddrs (eth0, eth1, etc.) to 5.3 Satellite.
2. Go to System Details.
3. Refresh Overview tab a few times, and compare the IP Address shown with expected ip and vs. what's shown on the Hardware tab.

Actual results:
IP Address shown on Overview tab is either incorrect / changes when refreshing the tab.

Expected results:
IP Address shown on Overview tab is incorrect / does not change when refreshing the tab, and should be consistent with the IP Address shown on Hardware page tab.

Additional info:

Comment 2 Xixi 2010-08-30 23:34:18 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;
   }
...

Comment 4 Tomas Lestach 2011-01-06 17:13:30 UTC
spacewalk.git: fedf9076caf9d6e8c269239c4ccb4fb4cd3b40f0

Comment 8 Tomas Lestach 2011-02-14 13:40:59 UTC
    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.

Comment 14 errata-xmlrpc 2011-03-17 14:12:19 UTC
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


Note You need to log in before you can comment on or make changes to this bug.