Select a valid management gateway

During IPv6 installation this script was generating an invalid mgmt_gw
value, due to an awk rule tuned for IPv4. This created an invalid
"gateway=1" in the ifupdown script, generating a parser error.

In a bonding setup with management as a vlan, the parsing error was
preventing the vlan interface over the ethernet port removal. The port
will be a slave on the bonding. Since the removal failed it cannot
add the vlan interface on top of the bonding interface.

The change uses the active controller floating value as a suitable
gateway, since at this stage the management network is the only
outside world option. If the value was not provided on API request
a valid IP is created (IPv4 or IPv6) to not generate parsing error.

For now there is no real case for the gateway to be used as all mgmt
traffic during kickstart and up to the first puppet manifest execution
is local, so in principle the gateway is just there for future use.
That is why it is not blocking installation.

Test Plan:
[PASS] Install AIO-DX (IPv4 and IPv6)
[PASS] Install Standard (IPv4 and IPv6)

Closes-Bug: 2070036

Change-Id: I4e76d878fecf589972bf93fdd75453a277c03d6a
Signed-off-by: Andre Kantek <andrefernandozanella.kantek@windriver.com>
This commit is contained in:
Andre Kantek 2024-06-20 12:57:24 -03:00
parent 94b9761011
commit 77d1aaaf8e

View File

@ -2623,7 +2623,22 @@ if [ -n "${BOOTIF}" ] ; then
if [ -z "${mgmt_ip}" -o "${mgmt_ip}" == "None" -o -z "${mgmt_nm}" -o "${mgmt_nm}" = "None" ] ; then
report_failure_with_msg "Unable to parse management ip and netmask from sysinv queried mgmt_ip info : value:${host_info}. Aborting Installation."
else
mgmt_gw=$(echo "${mgmt_ip}" | awk -F'.' -v OFS='.' '{$NF=1}1')
# the mgmt floating address is running on the active controller, so it is our gateway
mgmt_gw=$(echo "${host_info}" | grep -o '"floating": "[^"]*' | cut -d'"' -f4)
if [ -z "${mgmt_gw}" -o "${mgmt_gw}" == "None" ] ; then
ilog "invalid mgmt_gw=${mgmt_gw}, extrapolate gateway from ${mgmt_ip}"
# this step is done only to have a valid address value for mgmt_gw, to not create
# parsing errors for ifupdown, no need to interrupt installation, as all traffic
# post install will run locally on the management network until puppet executes
# the manifest and with it the definitive network configuration is applied.
if [[ ${mgmt_ip} =~ ^([0-9a-fA-F]{0,4}:){1,7}[0-9a-fA-F]{0,4}$ ]]; then
# IPv6
mgmt_gw=$(echo "${mgmt_ip}" | awk -F':' -v OFS=':' '{$NF=1}1')
else
# IPv4
mgmt_gw=$(echo "${mgmt_ip}" | awk -F'.' -v OFS='.' '{$NF=1}1')
fi
fi
ilog "... mgmt_gw=${mgmt_gw}"
fi