-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Multi-ASIC implementation #3888
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
Changes from 25 commits
504c632
8571864
2245ffe
193f182
aa44fda
f4844e8
a13a8d8
f99839b
9328339
04b4887
f3c48d6
d5c4a0d
83ca4de
6e3b519
87220d9
81b024e
1875e6b
3363c0d
95fb5f5
382f13e
c20bf43
a76eb01
d7ab64b
61971a7
81a8f74
4beb4ad
4ce974d
d754022
f935036
0dae0d8
173ba4e
3a8a68c
f2d02bc
d252a19
5ba42df
97d2643
01e9304
d83392a
9dddcff
e2a9e6c
5f8ffe6
bf7b0c4
42a3572
91af223
0e6033a
fe3ba83
f4d5d49
c2ce0b6
ab45a88
34f9213
cdb2fb3
0594d1a
45c0e73
b4d2071
030be0b
42c6db3
32c56c3
6c8e56f
27ea754
b4b557e
4d1204d
fa25e1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,15 @@ | ||
| #!/bin/bash | ||
|
|
||
| DOCKER_EXEC_FLAGS="i" | ||
|
|
||
| # Determine whether stdout is on a terminal | ||
| if [ -t 1 ] ; then | ||
| DOCKER_EXEC_FLAGS+="t" | ||
| NS="asic" #Network namespace | ||
| [ "$1" -eq "$1" ] 2> /dev/null # check if the first argument is a number | ||
| # if it's a number, set the database instance to | ||
| #operate on that instance | ||
| if [ $? -eq 0 ]; then | ||
| DEV="$1" | ||
| shift | ||
| fi | ||
| if [ -z "$DEV" ]; then | ||
| sonic-db-cli "$@" | ||
| else | ||
| ip netns exec $NS$DEV sonic-db-cli "$@" | ||
| fi | ||
|
|
||
| docker exec -$DOCKER_EXEC_FLAGS database redis-cli "$@" | ||
jleveque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,11 @@ link_namespace() { | |
| mkdir -p /var/run/netns | ||
| PID="$(docker inspect -f {{"'{{.State.Pid}}'"}} "{{docker_container_name}}$DEV")" | ||
|
|
||
| if `ip netns | grep --quiet -w "{{docker_container_name}}$DEV"`; then # namespace exists | ||
| if `ip netns | grep --quiet -w "$NET_NS$DEV"`; then # namespace exists | ||
| if [ $(readlink -f /var/run/netns/$NET_NS$DEV) = $(readlink -f /proc/$PID/ns/net) ]; then # namespace is correctly linked | ||
| return 0 | ||
| else # if it's incorrectly linked remove it | ||
| ip netns delete "{{docker_container_name}}$DEV" | ||
| ip netns delete $NET_NS$DEV | ||
| fi | ||
| fi | ||
|
|
||
|
|
@@ -82,14 +82,14 @@ function preStartAction() | |
| WARM_DIR=/host/warmboot | ||
| if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then | ||
| # Load redis content from /host/warmboot/dump.rdb | ||
| docker cp $WARM_DIR/dump.rdb database:/var/lib/redis/dump.rdb | ||
| docker cp $WARM_DIR/dump.rdb database$DEV:/var/lib/redis/dump.rdb | ||
| else | ||
| # Create an emtpy file and overwrite any RDB if already there | ||
| echo -n > /tmp/dump.rdb | ||
| docker cp /tmp/dump.rdb database:/var/lib/redis/ | ||
| docker cp /tmp/dump.rdb database$DEV:/var/lib/redis/ | ||
| fi | ||
| {%- elif docker_container_name == "snmp" %} | ||
| sonic-db-cli STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s) | ||
| /usr/bin/redis-cli $DEV STATE_DB HSET 'DEVICE_METADATA|localhost' chassis_serial_number $(decode-syseeprom -s) | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {%- else %} | ||
| : # nothing | ||
| {%- endif %} | ||
|
|
@@ -102,36 +102,43 @@ function postStartAction() | |
| link_namespace $DEV | ||
| fi | ||
| # Wait until redis starts | ||
| /usr/bin/docker exec database ping_pong_db_insts | ||
| /usr/bin/docker exec database$DEV ping_pong_db_insts | ||
| REDIS_SOCK="/var/run/redis/redis.sock" | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| EXT_REDIS_SOCK="/var/run/redis$DEV/redis.sock" # location of redis socket in the base image | ||
| if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast") && -f $WARM_DIR/dump.rdb ]]; then | ||
| rm -f $WARM_DIR/dump.rdb | ||
| else | ||
| # If there is a config db dump file, load it | ||
| if [ -r /etc/sonic/config_db.json ]; then | ||
| sonic-cfggen -j /etc/sonic/config_db.json --write-to-db | ||
| if [ -r /etc/sonic/config_db$DEV.json ]; then | ||
| /usr/bin/sonic-cfggen $DEV -j /etc/sonic/config_db$DEV.json --write-to-db | ||
| fi | ||
|
|
||
| if [[ "$BOOT_TYPE" == "fast" ]]; then | ||
| # set the key to expire in 3 minutes | ||
| sonic-db-cli STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180" | ||
| /usr/bin/redis-cli $DEV STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180" | ||
| fi | ||
|
|
||
| sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" | ||
| /usr/bin/redis-cli $DEV CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" | ||
| fi | ||
|
|
||
| if [[ -x /usr/bin/db_migrator.py ]]; then | ||
| # Migrate the DB to the latest schema version if needed | ||
| /usr/bin/db_migrator.py -o migrate | ||
| /usr/bin/db_migrator.py -o migrate -s $EXT_REDIS_SOCK | ||
|
|
||
| # Save in memory config_db to config_db.json for 2 reasons: | ||
| # 1. Persist the DB migration result. | ||
| # 2. Save in memory DB after warm reboot. | ||
| /usr/bin/config save -y | ||
|
||
| fi | ||
| {%- elif docker_container_name == "swss" %} | ||
| docker exec swss rm -f /ready # remove cruft | ||
| docker exec swss$DEV rm -f /ready # remove cruft | ||
| if [[ "$BOOT_TYPE" == "fast" ]] && [[ -d /host/fast-reboot ]]; then | ||
| test -e /host/fast-reboot/fdb.json && docker cp /host/fast-reboot/fdb.json swss:/ | ||
| test -e /host/fast-reboot/arp.json && docker cp /host/fast-reboot/arp.json swss:/ | ||
| test -e /host/fast-reboot/default_routes.json && docker cp /host/fast-reboot/default_routes.json swss:/ | ||
| test -e /host/fast-reboot/fdb.json && docker cp /host/fast-reboot/fdb.json swss$DEV:/ | ||
| test -e /host/fast-reboot/arp.json && docker cp /host/fast-reboot/arp.json swss$DEV:/ | ||
| test -e /host/fast-reboot/default_routes.json && docker cp /host/fast-reboot/default_routes.json swss$DEV:/ | ||
| rm -fr /host/fast-reboot | ||
| fi | ||
| docker exec swss touch /ready # signal swssconfig.sh to go | ||
| docker exec swss$DEV touch /ready # signal swssconfig.sh to go | ||
| {%- elif docker_container_name == "pmon" %} | ||
|
|
||
| DEVPATH="/usr/share/sonic/device" | ||
|
|
@@ -153,15 +160,15 @@ start() { | |
| BOOT_TYPE=`getBootType` | ||
|
|
||
| # Obtain our platform as we will mount directories with these names in each docker | ||
| PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` | ||
| PLATFORM=`/usr/bin/sonic-cfggen $DEV -H -v DEVICE_METADATA.localhost.platform` | ||
|
|
||
| {%- if docker_container_name == "database" %} | ||
| # Don't mount HWSKU in {{docker_container_name}} container. | ||
| HWSKU="" | ||
| {%- else %} | ||
| # Obtain our HWSKU as we will mount directories with these names in each docker | ||
| HWSKU=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'` | ||
| HOSTNAME=`sonic-cfggen -d -v 'DEVICE_METADATA["localhost"]["hostname"]'` | ||
| HWSKU=`/usr/bin/sonic-cfggen $DEV -d -v 'DEVICE_METADATA["localhost"]["hwsku"]'` | ||
| HOSTNAME=`/usr/bin/sonic-cfggen $DEV -d -v 'DEVICE_METADATA["localhost"]["hostname"]'` | ||
| {%- endif %} | ||
| if [ -z "$HOSTNAME" ] || ! [[ $HOSTNAME =~ ^[a-zA-Z0-9.\-]*$ ]]; then | ||
| HOSTNAME=`hostname` | ||
|
|
@@ -241,10 +248,13 @@ start() { | |
| --tmpfs /tmp \ | ||
| {%- endif %} | ||
| {%- endif %} | ||
| -v /var/run/redis:/var/run/redis:rw \ | ||
| {%- if docker_container_name == "bgp" %} | ||
| -v /etc/sonic/frr$DEV:/etc/frr:rw \ | ||
| {%- endif %} | ||
| -v /var/run/redis$DEV:/var/run/redis:rw \ | ||
| -v /usr/share/sonic/device/$PLATFORM:/usr/share/sonic/platform:ro \ | ||
| {%- if docker_container_name != "database" %} | ||
| -v /usr/share/sonic/device/$PLATFORM/$HWSKU:/usr/share/sonic/hwsku:ro \ | ||
| -v /usr/share/sonic/device/$PLATFORM/$HWSKU/$DEV:/usr/share/sonic/hwsku:ro \ | ||
| {%- endif %} | ||
| {%- if sonic_asic_platform != "mellanox" %} | ||
| --tmpfs /tmp \ | ||
|
|
@@ -256,7 +266,7 @@ start() { | |
| } | ||
|
|
||
| preStartAction | ||
| docker start {{docker_container_name}} | ||
| docker start {{docker_container_name}}$DEV | ||
| postStartAction | ||
| updateHostName "$HOSTNAME" | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [Unit] | ||
| Description=BGP container | ||
| #Requires=updategraph.service | ||
|
||
| #After=updategraph.service | ||
| After=database@%i.service | ||
| Requires=database@%i.service | ||
| Before=ntp-config.service | ||
|
|
||
| [Service] | ||
| User=root | ||
| ExecStartPre=/usr/bin/{{docker_container_name}}.sh start %i | ||
| ExecStart=/usr/bin/{{docker_container_name}}.sh wait %i | ||
| ExecStop=/usr/bin/{{docker_container_name}}.sh stop %i | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [Unit] | ||
| Description=Database container | ||
| Requires=docker.service database.service | ||
| After=docker.service database.service | ||
|
|
||
| [Service] | ||
| User=root | ||
| ExecStartPre=/usr/bin/{{docker_container_name}}.sh start %i | ||
| ExecStart=/usr/bin/{{docker_container_name}}.sh wait %i | ||
| ExecStop=/usr/bin/{{docker_container_name}}.sh stop %i | ||
| Restart=on-failure | ||
| TimeoutStartSec=120 | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| [Unit] | ||
| Description=LLDP container | ||
| #Requires=updategraph.service | ||
| #After=updategraph.service | ||
| After=database@%i.service | ||
| Requires=database@%i.service | ||
| Before=ntp-config.service | ||
|
|
||
| [Service] | ||
| User={{ sonicadmin_user }} | ||
| ExecStartPre=/usr/bin/{{docker_container_name}}.sh start %i | ||
| ExecStart=/usr/bin/{{docker_container_name}}.sh wait %i | ||
| ExecStop=/usr/bin/{{docker_container_name}}.sh stop %i | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| [Unit] | ||
| Description=switch state service | ||
| Requires=database@%i.service | ||
| #updategraph.service | ||
jleveque marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| {% if sonic_asic_platform == 'broadcom' %} | ||
| Requires=opennsl-modules.service | ||
| {% elif sonic_asic_platform == 'nephos' %} | ||
| Requires=nps-modules-4.9.0-9-2-amd64.service | ||
| {% elif sonic_asic_platform == 'vs' %} | ||
| Requires=topology.service | ||
| {% endif %} | ||
| After=database@%i.service | ||
| {% if sonic_asic_platform == 'vs' %} | ||
| After=topology.service | ||
| {% endif %} | ||
| #updategraph.service | ||
| After=interfaces-config@%i.service | ||
| Before=ntp-config.service | ||
| StartLimitIntervalSec=1200 | ||
| StartLimitBurst=3 | ||
|
|
||
| [Service] | ||
| User=root | ||
| Environment=sonic_asic_platform={{ sonic_asic_platform }} | ||
| ExecStartPre=/usr/local/bin/swss.sh start %i | ||
| ExecStart=/usr/local/bin/swss.sh wait %i | ||
| ExecStop=/usr/local/bin/swss.sh stop %i | ||
| Restart=always | ||
| RestartSec=30 | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| [Unit] | ||
| Description=syncd service | ||
| Requires=database@%i.service | ||
| #updategraph.service | ||
| {% if sonic_asic_platform == 'broadcom' %} | ||
| Requires=opennsl-modules.service | ||
| {% elif sonic_asic_platform == 'nephos' %} | ||
| Requires=nps-modules-4.9.0-8-2-amd64.service | ||
| {% elif sonic_asic_platform == 'vs' %} | ||
| Requires=topology.service | ||
| {% endif %} | ||
| After=database@%i.service | ||
| #updategraph.service | ||
| After=interfaces-config.service | ||
| {% if sonic_asic_platform == 'broadcom' %} | ||
| After=opennsl-modules.service | ||
| {% elif sonic_asic_platform == 'nephos' %} | ||
| After=nps-modules-4.9.0-8-2-amd64.service | ||
| {% elif sonic_asic_platform == 'vs' %} | ||
| After=topology.service | ||
| {% endif %} | ||
| After=swss@%i.service | ||
| Before=ntp-config.service | ||
|
|
||
| [Service] | ||
| User=root | ||
| Environment=sonic_asic_platform={{ sonic_asic_platform }} | ||
| ExecStartPre=/usr/local/bin/syncd.sh start %i | ||
| ExecStart=/usr/local/bin/syncd.sh wait %i | ||
| ExecStop=/usr/local/bin/syncd.sh stop %i | ||
| {% if sonic_asic_platform == 'mellanox' %} | ||
| TimeoutStartSec=150 | ||
| {% endif %} | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [Unit] | ||
| Description=TEAMD container | ||
| #Requires=updategraph.service | ||
| Requires=swss@%i.service | ||
| #After=updategraph.service | ||
| After=swss@%i.service | ||
| Before=ntp-config.service | ||
|
|
||
| [Service] | ||
| User=root | ||
| ExecStartPre=/usr/bin/{{docker_container_name}}.sh start %i | ||
| ExecStart=/usr/bin/{{docker_container_name}}.sh wait %i | ||
| ExecStop=/usr/bin/{{docker_container_name}}.sh stop %i | ||
|
|
||
| [Install] | ||
| WantedBy=swss@%i.service | ||
| RequiredBy=multi-user.target |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,10 +202,14 @@ echo "warmboot-finalizer.service" | sudo tee -a $GENERATED_SERVICE_FILE | |
|
|
||
| # Copy rsyslog configuration files and templates | ||
| sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.service $FILESYSTEM_ROOT/etc/systemd/system/ | ||
| sudo cp $IMAGE_CONFIGS/rsyslog/[email protected] $FILESYSTEM_ROOT/etc/systemd/system/ | ||
| sudo cp $IMAGE_CONFIGS/rsyslog/[email protected] $FILESYSTEM_ROOT/etc/systemd/system | ||
| sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog-config.sh $FILESYSTEM_ROOT/usr/bin/ | ||
| sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.conf.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ | ||
| sudo cp $IMAGE_CONFIGS/rsyslog/rsyslog.d/* $FILESYSTEM_ROOT/etc/rsyslog.d/ | ||
| echo "rsyslog-config.service" | sudo tee -a $GENERATED_SERVICE_FILE | ||
| echo "[email protected]" | sudo tee -a $GENERATED_SERVICE_FILE | ||
| echo "[email protected]" | sudo tee -a $GENERATED_SERVICE_FILE | ||
|
|
||
| # Copy logrotate.d configuration files | ||
| sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate.d/ | ||
|
|
@@ -214,9 +218,11 @@ sudo cp -f $IMAGE_CONFIGS/logrotate/logrotate.d/* $FILESYSTEM_ROOT/etc/logrotate | |
| sudo cp -f $IMAGE_CONFIGS/systemd/journald.conf $FILESYSTEM_ROOT/etc/systemd/ | ||
|
|
||
| # Copy interfaces configuration files and templates | ||
| sudo cp $IMAGE_CONFIGS/interfaces/[email protected] $FILESYSTEM_ROOT/etc/systemd/system/ | ||
| sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.service $FILESYSTEM_ROOT/etc/systemd/system/ | ||
| sudo cp $IMAGE_CONFIGS/interfaces/interfaces-config.sh $FILESYSTEM_ROOT/usr/bin/ | ||
| sudo cp $IMAGE_CONFIGS/interfaces/*.j2 $FILESYSTEM_ROOT_USR_SHARE_SONIC_TEMPLATES/ | ||
| echo "[email protected]" | sudo tee -a $GENERATED_SERVICE_FILE | ||
| echo "interfaces-config.service" | sudo tee -a $GENERATED_SERVICE_FILE | ||
jleveque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Copy dhcp client configuration template and create an initial configuration | ||
|
|
@@ -429,6 +435,7 @@ sudo LANG=C chroot $FILESYSTEM_ROOT umount -lf /sys | |
| # Copy swss and syncd service script | ||
| sudo LANG=C cp $SCRIPTS_DIR/swss.sh $FILESYSTEM_ROOT/usr/local/bin/swss.sh | ||
| sudo LANG=C cp $SCRIPTS_DIR/syncd.sh $FILESYSTEM_ROOT/usr/local/bin/syncd.sh | ||
| sudo LANG=C cp $SCRIPTS_DIR/sonic-cfggen $FILESYSTEM_ROOT/usr/bin/sonic-cfggen | ||
|
|
||
| # Copy systemd timer configuration | ||
| # It implements delayed start of services | ||
|
|
@@ -469,6 +476,14 @@ sudo rm -rf $FILESYSTEM_ROOT/$MLNX_PLATFORM_COMMON_PY2_WHEEL_NAME | |
| {% endif %} | ||
|
|
||
| {%- if SONIC_ROUTING_STACK == "frr" %} | ||
| {% for i in range(6) %} | ||
| sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr{{i}} | ||
| sudo touch $FILESYSTEM_ROOT/etc/sonic/frr{{i}}/frr.conf | ||
| sudo touch $FILESYSTEM_ROOT/etc/sonic/frr{{i}}/vtysh.conf | ||
| sudo chown -R $FRR_USER_UID:$FRR_USER_GID $FILESYSTEM_ROOT/etc/sonic/frr{{i}} | ||
| sudo chmod -R 640 $FILESYSTEM_ROOT/etc/sonic/frr{{i}}/ | ||
| sudo chmod 750 $FILESYSTEM_ROOT/etc/sonic/frr{{i}} | ||
| {%- endfor %} | ||
| sudo mkdir $FILESYSTEM_ROOT/etc/sonic/frr | ||
| sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/frr.conf | ||
| sudo touch $FILESYSTEM_ROOT/etc/sonic/frr/vtysh.conf | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.