[frr] Reduce Calls to SONiC Cfggen (#5176)

Calls to sonic-cfggen is CPU expensive. This PR reduces calls to
sonic-cfggen to two calls during startup when starting frr service.

singed-off-by: Tamer Ahmed <tamer.ahmed@microsoft.com>
This commit is contained in:
Tamer Ahmed 2020-08-17 15:47:42 -07:00 committed by GitHub
parent 3a10e9c6fa
commit a10c5bfd02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 17 deletions

View File

@ -3,9 +3,19 @@
mkdir -p /etc/frr mkdir -p /etc/frr
mkdir -p /etc/supervisor/conf.d mkdir -p /etc/supervisor/conf.d
sonic-cfggen -d -t /usr/share/sonic/templates/supervisord/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf CFGGEN_PARAMS=" \
-d \
CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'` -y /etc/sonic/constants.yml \
-t /usr/share/sonic/templates/supervisord/frr_vars.j2 \
-t /usr/share/sonic/templates/supervisord/supervisord.conf.j2,/etc/supervisor/conf.d/supervisord.conf \
-t /usr/share/sonic/templates/bgpd/bgpd.conf.j2,/etc/frr/bgpd.conf \
-t /usr/share/sonic/templates/zebra/zebra.conf.j2,/etc/frr/zebra.conf \
-t /usr/share/sonic/templates/staticd/staticd.conf.j2,/etc/frr/staticd.conf \
-t /usr/share/sonic/templates/frr.conf.j2,/etc/frr/frr.conf \
-t /usr/share/sonic/templates/isolate.j2,/usr/sbin/bgp-isolate \
-t /usr/share/sonic/templates/unisolate.j2,/usr/sbin/bgp-unisolate \
"
CONFIG_TYPE=$(sonic-cfggen $CFGGEN_PARAMS)
if [[ ! -z "$NAMESPACE_ID" ]]; then if [[ ! -z "$NAMESPACE_ID" ]]; then
# FRR is not running in host namespace so we need to delete # FRR is not running in host namespace so we need to delete
@ -31,24 +41,18 @@ if [[ ! -z "$NAMESPACE_ID" ]]; then
fi fi
if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then if [ -z "$CONFIG_TYPE" ] || [ "$CONFIG_TYPE" == "separated" ]; then
sonic-cfggen -d -t /usr/share/sonic/templates/bgpd/bgpd.conf.j2 -y /etc/sonic/constants.yml > /etc/frr/bgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra/zebra.conf.j2 > /etc/frr/zebra.conf
sonic-cfggen -d -t /usr/share/sonic/templates/staticd/staticd.conf.j2 > /etc/frr/staticd.conf
echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf echo "no service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/frr.conf rm -f /etc/frr/frr.conf
elif [ "$CONFIG_TYPE" == "unified" ]; then elif [ "$CONFIG_TYPE" == "unified" ]; then
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/frr.conf.j2 >/etc/frr/frr.conf
echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf echo "service integrated-vtysh-config" > /etc/frr/vtysh.conf
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
fi fi
chown -R frr:frr /etc/frr/ chown -R frr:frr /etc/frr/
sonic-cfggen -d -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate
chown root:root /usr/sbin/bgp-isolate chown root:root /usr/sbin/bgp-isolate
chmod 0755 /usr/sbin/bgp-isolate chmod 0755 /usr/sbin/bgp-isolate
sonic-cfggen -d -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate
chown root:root /usr/sbin/bgp-unisolate chown root:root /usr/sbin/bgp-unisolate
chmod 0755 /usr/sbin/bgp-unisolate chmod 0755 /usr/sbin/bgp-unisolate

View File

@ -0,0 +1 @@
{{ DEVICE_METADATA["localhost"]["docker_routing_config_mode"] }}

View File

@ -1,14 +1,19 @@
#!/usr/bin/env bash #!/usr/bin/env bash
mkdir -p /etc/quagga mkdir -p /etc/quagga
sonic-cfggen -d -t /usr/share/sonic/templates/gobgpd.conf.j2 > /etc/gobgp/gobgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf
sonic-cfggen -d -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate CFGGEN_PARAMS=" \
-d \
-t /usr/share/sonic/templates/gobgpd.conf.j2,/etc/gobgp/gobgpd.conf \
-t /usr/share/sonic/templates/zebra.conf.j2,/etc/quagga/zebra.conf \
-t /usr/share/sonic/templates/isolate.j2,/usr/sbin/bgp-isolate \
-t /usr/share/sonic/templates/unisolate.j2,/usr/sbin/bgp-unisolate \
"
sonic-cfggen $CFGGEN_PARAMS
chown root:root /usr/sbin/bgp-isolate chown root:root /usr/sbin/bgp-isolate
chmod 0755 /usr/sbin/bgp-isolate chmod 0755 /usr/sbin/bgp-isolate
sonic-cfggen -d -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate
chown root:root /usr/sbin/bgp-unisolate chown root:root /usr/sbin/bgp-unisolate
chmod 0755 /usr/sbin/bgp-unisolate chmod 0755 /usr/sbin/bgp-unisolate

View File

@ -1,15 +1,20 @@
#!/usr/bin/env bash #!/usr/bin/env bash
mkdir -p /etc/quagga mkdir -p /etc/quagga
sonic-cfggen -d -y /etc/sonic/constants.yml -t /usr/share/sonic/templates/bgpd.conf.j2 > /etc/quagga/bgpd.conf
sonic-cfggen -d -t /usr/share/sonic/templates/zebra.conf.j2 > /etc/quagga/zebra.conf CFGGEN_PARAMS=" \
-d \
-y /etc/sonic/constants.yml \
-t /usr/share/sonic/templates/bgpd.conf.j2,/etc/quagga/bgpd.conf \
-t /usr/share/sonic/templates/zebra.conf.j2,/etc/quagga/zebra.conf \
-t /usr/share/sonic/templates/isolate.j2,/usr/sbin/bgp-isolate \
-t /usr/share/sonic/templates/unisolate.j2,/usr/sbin/bgp-unisolate \
"
sonic-cfggen $CFGGEN_PARAMS
sonic-cfggen -d -t /usr/share/sonic/templates/isolate.j2 > /usr/sbin/bgp-isolate
chown root:root /usr/sbin/bgp-isolate chown root:root /usr/sbin/bgp-isolate
chmod 0755 /usr/sbin/bgp-isolate chmod 0755 /usr/sbin/bgp-isolate
sonic-cfggen -d -t /usr/share/sonic/templates/unisolate.j2 > /usr/sbin/bgp-unisolate
chown root:root /usr/sbin/bgp-unisolate chown root:root /usr/sbin/bgp-unisolate
chmod 0755 /usr/sbin/bgp-unisolate chmod 0755 /usr/sbin/bgp-unisolate