Bug 1471805 - ethmonitor reports 'WARNING: Interface xxx does not exist' for existing interfaces
ethmonitor reports 'WARNING: Interface xxx does not exist' for existing inter...
Status: CLOSED DUPLICATE of bug 1408656
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: resource-agents (Show other bugs)
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Oyvind Albrigtsen
Depends On:
  Show dependency treegraph
Reported: 2017-07-17 09:23 EDT by Ondrej Faměra
Modified: 2017-07-17 10:35 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2017-07-17 10:35:38 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
proposed fix (550 bytes, patch)
2017-07-17 09:23 EDT, Ondrej Faměra
no flags Details | Diff

  None (edit)
Description Ondrej Faměra 2017-07-17 09:23:10 EDT
Created attachment 1299859 [details]
proposed fix

=== Description of problem:
'ethmonitor' resource agents reports warning 'WARNING: Interface xxx does not exist' if the
interface specified for it doesn't contain any IP addresses. This message is both misleading
and not true. See attachment for proposed patch on fixing the correct detection in this special

=== Version-Release number of selected component (if applicable):

=== How reproducible:

=== Steps to Reproduce:
1. Ensure that interface 'eth2' exists on the system and that it doesn't
have any IP address assigned. Output from 'ip addr show' below.
  2: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
      link/ether 52:54:00:dc:dc:7b brd ff:ff:ff:ff:ff:ff
Note that 'eth2' is not seen in output of 'ip -o -f inet addr show'.

2. Create resource 'ethmonitor' and give it following attributes.
  # pcs resource create ethmonitor interface=eth2 link_status_only=1

3. Observe the logs.

=== Actual results:
Logs contain following warning after each monitoring cycle of the resource.
  ethmonitor(eth)[xxxx]: WARNING: Interface eth2 does not exist

=== Expected results:
No WARNING should be reported in logs as the interface exists.

=== Additional info:

### Resource agent executes 'if_validate' on each call except of meta-data, usage and help
528 case $__OCF_ACTION in
529 meta-data)      meta_data
530                 ;;
531 usage|help)     if_usage
532                 exit $OCF_SUCCESS
533                 ;;
534 esac
536 if_validate

### 'if_validate' calls 'if_init'
522 if_validate() {
523         check_binary $IP2UTIL
524         check_binary arping
525         if_init
526 }

### 'if_init' calls to 'is_interface' to validate the interface and if it fails it prodduces warnign on line 251
237         if is_interface $NIC
238         then
239                 case "$NIC" in
240                         *:*) ocf_exit_reason "Do not specify a virtual interface : $OCF_RESKEY_interface"
241                                  exit $OCF_ERR_CONFIGURED;;
242                         *)   ;;
243                 esac
244         else
245                 case $__OCF_ACTION in
246                         validate-all)
247                                 ocf_exit_reason "Interface $NIC does not exist"
248                                 exit $OCF_ERR_CONFIGURED;;
249                         *)
250                                 ## It might be a bond interface which is temporarily not available, therefore we want to continue here
251                                 ocf_log warn "Interface $NIC does not exist"
252                                 ;;
253                 esac
254         fi

### Valid interface numbers are determined in functions 'is_interface' that doesn't shows any interface without IP addresses.
205 is_interface() {
206	#
207	# List interfaces but exclude FreeS/WAN ipsecN virtual interfaces
208	#
209	local iface=`$IP2UTIL -o -f inet addr show | grep " $1 " \
210		| cut -d ' ' -f2 | sort -u | grep -v '^ipsec[0-9][0-9]*$'`
211		[ "$iface" != "" ]
212 }

Proposed patch to 'ethmonitor' attached to this bugzilla.

Patch changes the family that 'ip' searches for the interfaces.
Instead of '-f inet' it uses '-f link'.
Due to change of family all interfaces have now ':' (colon) at the end.
Still interfaces are separated by spaces around so the code is made to account
that in 2 places. 1st when grep-ing for the requested interface and 2nd when we have
results it is removing the ':' from results to produce same type of output as previous
version of this command.
Patch seems to work well for scenario described in the 'Steps to reproduce' and also
works well in scenario when we use it for interfaces with IP addresses. 
However based on what are other accepted inputs as interface names more testing would be
probably needed.
Comment 2 Oyvind Albrigtsen 2017-07-17 10:35:38 EDT
This is being taken care of in https://bugzilla.redhat.com/show_bug.cgi?id=1408656

*** This bug has been marked as a duplicate of bug 1408656 ***

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