Bug 1471805

Summary: ethmonitor reports 'WARNING: Interface xxx does not exist' for existing interfaces
Product: Red Hat Enterprise Linux 7 Reporter: Ondrej Faměra <ofamera>
Component: resource-agentsAssignee: Oyvind Albrigtsen <oalbrigt>
Status: CLOSED DUPLICATE QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: agk, cluster-maint, fdinitto
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-07-17 14:35:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
proposed fix none

Description Ondrej Faměra 2017-07-17 13:23:10 UTC
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
case.

=== Version-Release number of selected component (if applicable):
resource-agents-3.9.5-82.el7_3.11.x86_64

=== How reproducible:
always

=== 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:
/usr/lib/ocf/resource.d/heartbeat/ethmonitor

### 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
535
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 14:35:38 UTC
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 ***