Azure / Azure/WALinuxAgent

[BUG][RHEL8.2]WALA provision failed if no ifcfg file for primary NIC

Open
#1,720 0 comments 0 reactions 0 assignees View on GitHub
provisioning triaged
Dominant language
Python
Stars
581
Forks
397
Avg merge
2d 15h
Merged PRs (30d)
9

Description

Reference BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1776711

Version-Release number of selected component (if applicable):
WALinuxAgent-2.2.38-1.el8.noarch

RHEL Version:
RHEL8.2

How reproducible:
100%

Steps to Reproduce:
1. Create a VM in Azure with 2 NICs
2. Check /var/log/waagent.log

Actual results:
Provision failed.

/var/log/waagent.log:
2019/11/25 15:42:40.079388 INFO Daemon Examine /proc/net/route for primary interface
2019/11/25 15:42:40.087826 INFO Daemon Primary interface is [eth1]
2019/11/25 15:42:40.592966 ERROR Daemon Event: name=WALinuxAgent, op=UnhandledError, message=Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/azurelinuxagent/daemon/main.py", line 81, in run
self.daemon(child_args)
File "/usr/lib/python3.6/site-packages/azurelinuxagent/daemon/main.py", line 139, in daemon
self.provision_handler.run()
File "/usr/lib/python3.6/site-packages/azurelinuxagent/pa/provision/default.py", line 84, in run
self.provision(ovf_env)
File "/usr/lib/python3.6/site-packages/azurelinuxagent/pa/provision/default.py", line 226, in provision
self.osutil.publish_hostname(ovfenv.hostname)
File "/usr/lib/python3.6/site-packages/azurelinuxagent/common/osutil/redhat.py", line 118, in publish_hostname
super(RedhatOSUtil, self).publish_hostname(hostname)
File "/usr/lib/python3.6/site-packages/azurelinuxagent/common/osutil/default.py", line 1130, in publish_hostname
self.set_dhcp_hostname(hostname)
File "/usr/lib/python3.6/site-packages/azurelinuxagent/common/osutil/redhat.py", line 92, in set_dhcp_hostname
'DHCP_HOSTNAME={0}'.format(hostname))
File "/usr/lib/python3.6/site-packages/azurelinuxagent/common/utils/fileutil.py", line 162, in update_conf_file
conf = read_file(path).split('\n')
File "/usr/lib/python3.6/site-packages/azurelinuxagent/common/utils/fileutil.py", line 53, in read_file
with open(filepath, mode) as in_file:
FileNotFoundError: [Errno 2] No such file or directory: '/etc/sysconfig/network-scripts/ifcfg-eth1'
, duration=0
2019/11/25 15:42:40.681755 WARNING Daemon Daemon ended with exception -- Sleep 15 seconds and restart daemon

Expected results:
Provision successfully

Additional info:
Seems the root cause is in RHEL-8.2 if there're more than 1 NIC, the primary NIC becomes eth1 but not eth0(it's very rare now). By default there's no ifcfg-eth1 file. WALA detects that the primary interface is eth1, and run "ifdown eth1 && ifup eth1" command. This command fails because of no ifcfg-eth1 file.
Suggest to use "ip link set ethx down && ip link set ethx up" or "systemctl restart NetworkManager" instead.

Contributor guide

Open the contributing guide

Research direction

Start in azurelinuxagent/common/osutil/redhat.py at set_dhcp_hostname and trace the call from publish_hostname; the traceback also identifies default.py and fileutil.py. Reproduce on RHEL8.2 with two NICs and inspect /var/log/waagent.log. Done means provisioning succeeds when the primary interface has no ifcfg file.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, linux, python
Domain
networking, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.