sonic-buildimage/files
Junchao-Mellanox 4f326e8779
Fix race condition between networking service and interface-config service (#10573) (#10766)
Backport https://github.com/Azure/sonic-buildimage/pull/10573 to 202012.

#### Why I did it

The PR is aimed to fix a bug that mgmt port eth0 may loss IP even if user configured static IP of eth0. This is not a always reproduceable issue, the reproducing flow is like:

1.	Systemd starts networking service, which runs a dhcp based configuration and assigned an ip from dhcp.
2.	Systemd starts interface-config service who depends on networking service
3.	Interface-config service runs command  “ifdown –force eth0”, check [line](16717d2dc5/files/image_config/interfaces/interfaces-config.sh (L4)). but networking service is still running so that this [line](ac32bec0e2/ifupdown2/ifupdown/main.py (L74)) failed with error: “error: Another instance of this program is already running.”. This error is printed by ifupdown2 lib who is the main process of networking service. So, ifdown actually does not work here, the ip of eth0 is not down.
4.	Interface-config service updates /etc/networking/interface to static configuration.
5.	Interface-config service runs command “systemctl restart networking”. This command kills the previous networking related processes (log: networking.service: Main process exited, code=killed, status=15/TERM), and try to reconfigure the ip address with static configuration. But it detects that the configured IP and the existing IP are the same, and it does not really configure the ip to kernel. Hence, the ip is still getting from dhcp. (this could be a bug of ifupdown2: previous ip is from dhcp, new ip is a static ip, it treats them as same instead of re-configuring the IP)
6.	When the lease of the ip expires, the ip of eth0 is removed by kernel and the issue reproduces.

The issue is not always reproduceable because networking service usually runs fast so that it won't hit step#3.

#### How I did it

Check networking service state before running "ifdown –force eth0", wait for it done if it is activating.

#### How to verify it

Manual test.
2022-05-14 14:58:24 -07:00
..
Aboot [202012] Run tune2fs during initramfs instead of image install (#10558) 2022-04-12 19:59:24 -07:00
apt Add mirrors for reproducible build (#6813) 2021-02-19 11:51:34 -08:00
build/versions [ci/build]: Upgrade SONiC package versions (#10594) 2022-04-27 15:25:14 +00:00
build_scripts [hostcfgd]: Add Ability To Configure Feature During Run-time (#6700) 2021-03-15 19:09:31 -07:00
build_templates Reduce image size for lazy installation packages (#10775) 2022-05-10 06:44:40 +00:00
dhcp ZTP infrastructure changes to support DHCP discovery provisioning data (#3298) 2019-12-10 08:16:56 -08:00
docker Enabling ipv6 support on docker container network. This is needed (#5418) 2020-09-22 08:32:17 -07:00
image_config Fix race condition between networking service and interface-config service (#10573) (#10766) 2022-05-14 14:58:24 -07:00
initramfs-tools [Arista] Fix arista-net initramfs hook (#10626) 2022-04-20 10:03:37 -07:00
scripts [services] kill container on stop in warm/fast mode (#10511) 2022-04-18 14:27:48 -07:00
sshd [sshd]: Create /run/sshd under systemd using RuntimeDirectory 2020-04-17 04:51:51 +00:00