0285bfe42e
What/Why I did: Issue1: By setting up of ipvlan interface in interface-config.sh we are not tolerant to failures. Reason being interface-config.service is one-shot and do not have restart capability. Scenario: For example if let's say database service goes in fail state then interface-services also gets failed because of dependency check but later database service gets restart but interface service will remain in stuck state and the ipvlan interface nevers get created. Solution: Moved all the logic in database service from interface-config service which looks more align logically also since the namespace is created here and all the network setting (sysctl) are happening here.With this if database starts we recreate the interface. Issue 2: Use of IPVLAN vs MACVLAN Currently we are using ipvlan mode. However above failure scenario is not handle correctly by ipvlan mode. Once the ipvlan interface is created and ip address assign to it and if we restart interface-config or database (new PR) service Linux Kernel gives error "Error: Address already assigned to an ipvlan device." based on this:https://github.com/torvalds/linux/blob/master/drivers/net/ipvlan/ipvlan_main.c#L978Reason being if we do not do cleanup of ip address assignment (need to be unique for IPVLAN) it remains in Kernel Database and never goes to free pool even though namespace is deleted. Solution: Considering this hard dependency of unique ip macvlan mode is better for us and since everything is managed by Linux Kernel and no dependency for on user configured IP address. Issue3: Namespace database Service do not check reachability to Supervisor Redis Chassis Server. Currently there is no explicit check as we never do Redis PING from namespace to Supervisor Redis Chassis Server. With this check it's possible we will start database and all other docker even though there is no connectivity and will hit the error/failure late in cycle Solution: Added explicit PING from namespace that will check this reachability. Issue 4:flushdb give exception when trying to accces Chassis Server DB over Unix Sokcet. Solution: Handle gracefully via try..except and log the message.
70 lines
2.4 KiB
Bash
Executable File
70 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
function wait_networking_service_done() {
|
|
local -i _WDOG_CNT="1"
|
|
local -ir _WDOG_MAX="30"
|
|
|
|
local -r _TIMEOUT="1s"
|
|
|
|
while [[ "${_WDOG_CNT}" -le "${_WDOG_MAX}" ]]; do
|
|
networking_status="$(systemctl is-active networking 2>&1)"
|
|
|
|
if [[ "${networking_status}" == active || "${networking_status}" == inactive || "${networking_status}" == failed ]] ; then
|
|
return
|
|
fi
|
|
|
|
echo "interfaces-config: networking service is running, wait for it done"
|
|
|
|
let "_WDOG_CNT++"
|
|
sleep "${_TIMEOUT}"
|
|
done
|
|
|
|
echo "interfaces-config: networking service is still running after 30 seconds, killing it"
|
|
systemctl kill networking 2>&1
|
|
}
|
|
|
|
if [[ $(ifquery --running eth0) ]]; then
|
|
wait_networking_service_done
|
|
ifdown --force eth0
|
|
fi
|
|
|
|
# Check if ZTP DHCP policy has been installed
|
|
if [[ -e /etc/network/ifupdown2/policy.d/ztp_dhcp.json ]]; then
|
|
# Obtain port operational state information
|
|
redis-dump -d 0 -k "PORT_TABLE:Ethernet*" -y > /tmp/ztp_port_data.json
|
|
|
|
if [[ $? -ne 0 || ! -e /tmp/ztp_port_data.json || "$(cat /tmp/ztp_port_data.json)" = "" ]]; then
|
|
echo "{}" > /tmp/ztp_port_data.json
|
|
fi
|
|
|
|
# Create an input file with ztp input information
|
|
echo "{ \"PORT_DATA\" : $(cat /tmp/ztp_port_data.json) }" > \
|
|
/tmp/ztp_input.json
|
|
else
|
|
echo "{ \"ZTP_DHCP_DISABLED\" : \"true\" }" > /tmp/ztp_input.json
|
|
fi
|
|
|
|
# Create /e/n/i file for existing and active interfaces, dhcp6 sytcl.conf and dhclient.conf
|
|
CFGGEN_PARAMS=" \
|
|
-d -j /tmp/ztp_input.json \
|
|
-t /usr/share/sonic/templates/interfaces.j2,/etc/network/interfaces \
|
|
-t /usr/share/sonic/templates/90-dhcp6-systcl.conf.j2,/etc/sysctl.d/90-dhcp6-systcl.conf \
|
|
-t /usr/share/sonic/templates/dhclient.conf.j2,/etc/dhcp/dhclient.conf \
|
|
"
|
|
sonic-cfggen $CFGGEN_PARAMS
|
|
|
|
[[ -f /var/run/dhclient.eth0.pid ]] && kill `cat /var/run/dhclient.eth0.pid` && rm -f /var/run/dhclient.eth0.pid
|
|
[[ -f /var/run/dhclient6.eth0.pid ]] && kill `cat /var/run/dhclient6.eth0.pid` && rm -f /var/run/dhclient6.eth0.pid
|
|
|
|
for intf_pid in $(ls -1 /var/run/dhclient*.Ethernet*.pid 2> /dev/null); do
|
|
[[ -f ${intf_pid} ]] && kill `cat ${intf_pid}` && rm -f ${intf_pid}
|
|
done
|
|
|
|
# Read sysctl conf files again
|
|
sysctl -p /etc/sysctl.d/90-dhcp6-systcl.conf
|
|
|
|
systemctl restart networking
|
|
|
|
# Clean-up created files
|
|
rm -f /tmp/ztp_input.json /tmp/ztp_port_data.json
|