Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frr] Reduce Calls to SONiC Cfggen #5176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions dockers/docker-fpm-frr/docker_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
mkdir -p /etc/frr
mkdir -p /etc/supervisor/conf.d

sonic-cfggen -d -t /usr/share/sonic/templates/supervisord/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf

CONFIG_TYPE=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["docker_routing_config_mode"]'`
CFGGEN_PARAMS=" \
-d \
-y /etc/sonic/constants.yml \
-t /usr/share/sonic/templates/supervisord/frr_vars.j2 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need frr_vars?
Also why you have only source after -t?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the frr_vars is a template file that pulls information about the config_type. This variable later decides if BGP service is integrate into vtysh or not. The content of the frr_vars is retreiving single variable for now:
{{ DEVICE_METADATA["localhost"]["docker_routing_config_mode"] }}
Lack of destination after the first argument, means this template is going to be rendered to stdout.

In comparison, commit a5f2de does docker initialization with two calls to cfggen. The time difference between the two approaches is about 1sec.

-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
# FRR is not running in host namespace so we need to delete
Expand All @@ -31,24 +41,18 @@ if [[ ! -z "$NAMESPACE_ID" ]]; then
fi

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
rm -f /etc/frr/frr.conf
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
rm -f /etc/frr/bgpd.conf /etc/frr/zebra.conf /etc/frr/staticd.conf
fi

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
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
chmod 0755 /usr/sbin/bgp-unisolate

Expand Down
1 change: 1 addition & 0 deletions dockers/docker-fpm-frr/frr/frr_vars.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ DEVICE_METADATA["localhost"]["docker_routing_config_mode"] }}
13 changes: 9 additions & 4 deletions dockers/docker-fpm-gobgp/start.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/usr/bin/env bash

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
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
chmod 0755 /usr/sbin/bgp-unisolate

Expand Down
13 changes: 9 additions & 4 deletions dockers/docker-fpm-quagga/start.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#!/usr/bin/env bash

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
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
chmod 0755 /usr/sbin/bgp-unisolate

Expand Down