Exit network config apply if puppet provides empty configuration

It was observed that if sysinv-conductor generates, for some reason,
hieradata for controller-1 (or other nodes) between the host-add
operation but before the new node's sysinv-agent send the first
inventory report an empty network config will be generated.

The script apply_network_config.sh isn't prepared for this case and
was removing existing configuration without adding another one,
isolating the node.

This change adds protection for this case, if an empty configuration
is detected (only contains the loopback) it will exit with success,
preserving the current configuration.

To simulate the problem, after controller-1 was added (with
system host-update 2 personality=controller) an empty controller-1
hieradata was generated with "/usr/bin/sysinv-puppet
 create-host-config" in /opt/platform/puppet/24.09/hieradata/. This
file contained a "network_config" with just the loopback interface.

Test Plan:

[PASS] with the empty network_config hieradata observe that the
        network config left by kickstart is preserved, no network
        interruption is detected
[PASS] after sysinv-agent inventory report proceed with
        controller-1 configuration and unlock the system, the unlock
        operation finishes with success.

Closes-Bug: 2071619

Change-Id: Ibb732d1f57e036740a7140c6014328f8a6de0fe5
Signed-off-by: Andre Kantek <andrefernandozanella.kantek@windriver.com>
This commit is contained in:
Andre Kantek 2024-07-01 09:23:58 -03:00
parent 10fefdbec9
commit bbc2000448

View File

@ -358,18 +358,27 @@ else
exit 1
fi
log_network_info
parse_interface_stanzas
auto_intf=$(grep -v HEADER ${PUPPET_DIR}/auto)
log_it info "auto interfaces='${auto_intf}'"
if [ "${auto_intf}" == "auto lo" ]; then
# if an empty configuration is provided by puppet we should ignore it, otherwise
# it will remove the present network configuration and put nothing back in its place
log_it info "generated ${PUPPET_FILE} with empty configuration:'${auto_intf}', exiting"
exit 0
fi
if [ -f /etc/network/interfaces.d/ifcfg-pxeboot ]; then
iface_name=$( cat /etc/network/interfaces.d/ifcfg-pxeboot | grep iface | awk '{print $2}' )
log_it "turn off pxeboot install config, will be turned on later"
log_it "turn off pxeboot install config for ${iface_name}, will be turned on later"
do_if_down ${iface_name}
log_it "remove ifcfg-pxeboot, left from pxeboot install phase"
rm /etc/network/interfaces.d/ifcfg-pxeboot
fi
log_network_info
parse_interface_stanzas
upgr_bootstrap=1
if [ -f /var/run/.network_upgrade_bootstrap ]; then