stx-puppet: fix the unnecessary network configuration apply 34/3634/1
authorLitao Gao <litao.gao@windriver.com>
Fri, 8 May 2020 06:44:54 +0000 (02:44 -0400)
committerLitao Gao <litao.gao@windriver.com>
Fri, 8 May 2020 06:44:54 +0000 (02:44 -0400)
In AIO case, both controller and worker will run network puppet
to apply network configuration, need to check and avoid unnecessary
apply to avoid the potential conflicts.

Issue-ID: INF-94
Signed-off-by: Litao Gao <litao.gao@windriver.com>
Change-Id: I0372dd669b00a0969b5cddc0df3d9576092d564a

meta-stx/recipes-support/puppet/files/stx-puppet/apply_network_config_poky.sh

index 9d182be..8357378 100755 (executable)
@@ -280,16 +280,23 @@ function sysinv_agent_lock {
 # synchronize with sysinv-agent audit
 sysinv_agent_lock $ACQUIRE_LOCK
 
-# now copy the puppet changed interfaces to /etc/network/interfaces
-do_mv /var/run/interfaces.puppet /etc/network/interfaces
-
-# now restart networking service 
-/etc/init.d/networking restart
+# check if this is a duplicated configuration
+if ! diff -I '^#' "/var/run/interfaces.puppet" "/etc/network/interfaces" > /dev/null; then
+    # now copy the puppet changed interfaces to /etc/network/interfaces
+    do_mv /var/run/interfaces.puppet /etc/network/interfaces
+
+    # now restart networking service 
+    /etc/init.d/networking restart
+
+    sleep 5
+else
+    # need to remove this file also
+    do_rm /var/run/interfaces.puppet
+fi
 
-sleep 5
 
 # workaround the loopback label addresses cannot be configured as scope of host
-ip addr show lo | egrep "inet.*lo:" > /tmp/loop$$
+ip addr show lo | egrep "inet.*global.*lo:" > /tmp/loop$$
 
 while read addr_info; do 
        echo $addr_info