Skip to content

Commit 2ed6e17

Browse files
Smartswitch support for container checker and frr (sonic-net#19729)
[Smartswitch] support for container checker and frr
1 parent 856fcc9 commit 2ed6e17

File tree

8 files changed

+63
-5
lines changed

8 files changed

+63
-5
lines changed

dockers/docker-fpm-frr/base_image_files/TSA

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/bin/bash
22

3+
# Source the platform_utils script
4+
source "$(dirname "$0")/platform_utils"
5+
36
# Restrict command to sudo users
47
if [ "$EUID" -ne 0 ] ; then
58
echo "Root priveleges are needed for this operation"
69
exit 1
710
fi
811

9-
if [ -f /etc/sonic/chassisdb.conf ]; then
12+
if [ -f /etc/sonic/chassisdb.conf ] && [ "$SMARTSWITCH" = false ] ; then
1013
CHASSIS_TSA_STATE_UPDATE="CHASSIS_APP_DB HMSET "BGP_DEVICE_GLOBAL\|STATE" tsa_enabled "true""
1114
CONFIG_DB_TSA_STATE_UPDATE='{"BGP_DEVICE_GLOBAL":{"STATE":{"tsa_enabled": "true"}}}'
1215
current_tsa_state="$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)"

dockers/docker-fpm-frr/base_image_files/TSB

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/bin/bash
22

3+
# Source the platform_utils script
4+
source "$(dirname "$0")/platform_utils"
5+
36
# Restrict command to sudo users
47
if [ "$EUID" -ne 0 ] ; then
58
echo "Root priveleges are needed for this operation"
69
exit 1
710
fi
811

9-
if [ -f /etc/sonic/chassisdb.conf ]; then
12+
if [ -f /etc/sonic/chassisdb.conf ] && [ "$SMARTSWITCH" = false ] ; then
1013
CHASSIS_TSA_STATE_UPDATE="CHASSIS_APP_DB HMSET "BGP_DEVICE_GLOBAL\|STATE" tsa_enabled "false""
1114
CONFIG_DB_TSA_STATE_UPDATE='{"BGP_DEVICE_GLOBAL":{"STATE":{"tsa_enabled": "false"}}}'
1215
current_tsa_state="$(sonic-cfggen -d -v BGP_DEVICE_GLOBAL.STATE.tsa_enabled)"

dockers/docker-fpm-frr/base_image_files/TSC

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/bin/bash
22

3+
# Source the platform_utils script
4+
source "$(dirname "$0")/platform_utils"
5+
36
# Restrict command to sudo users
47
if [ "$EUID" -ne 0 ] ; then
58
echo "Root priveleges are needed for this operation"
69
exit 1
710
fi
811

9-
if [ -f /etc/sonic/chassisdb.conf ]; then
12+
if [ -f /etc/sonic/chassisdb.conf ] && [ "$SMARTSWITCH" = false ] ; then
1013
if [[ $1 == "no-stats" ]]; then
1114
rexec all -c "sudo TSC no-stats"
1215
else
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# platform_utils
4+
5+
# Determine platform and is smartswitch
6+
PLATFORM="$(sonic-cfggen -d -v DEVICE_METADATA.localhost.platform)"
7+
SMARTSWITCH=false
8+
PLATFORM_JSON=/usr/share/sonic/device/$PLATFORM/platform.json
9+
10+
if [ -f "$PLATFORM_JSON" ]; then
11+
NUM_DPU=$(jq -r '.DPUS | length' $PLATFORM_JSON 2>/dev/null)
12+
if [[ $NUM_DPU -gt 0 ]]; then
13+
SMARTSWITCH=true
14+
fi
15+
fi
16+
17+
# Export SMARTSWITCH for other scripts
18+
export SMARTSWITCH

dockers/docker-platform-monitor/docker-pmon.supervisord.conf.j2

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ stdout_logfile=syslog
2828
stderr_logfile=syslog
2929
dependent_startup=true
3030

31-
{% if not skip_chassisd and IS_MODULAR_CHASSIS == 1 %}
31+
{% if not skip_chassisd and (IS_MODULAR_CHASSIS == 1 or is_smartswitch) %}
3232
[program:chassisd]
3333
command=/usr/local/bin/chassisd
3434
priority=3

files/image_config/monit/container_checker

+8-1
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,15 @@ def get_expected_running_containers():
109109
else:
110110
always_running_containers.add(container_name)
111111

112-
if device_info.is_supervisor():
112+
if device_info.is_supervisor() or device_info.is_smartswitch():
113113
always_running_containers.add("database-chassis")
114+
115+
if device_info.is_smartswitch():
116+
raw_dpustable = config_db.get_table("DPUS")
117+
for dpu_name in raw_dpustable:
118+
container_name = f"databasedpu{dpu_name.replace('dpu', '')}"
119+
always_running_containers.add(container_name)
120+
114121
return expected_running_containers, always_running_containers
115122

116123
def get_current_running_from_DB(always_running_containers):

rules/config

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ DEFAULT_BUILD_LOG_TIMESTAMP = none
4242
# CHANGE_DEFAULT_PASSWORD - enforce default user/users to change password on 1st login
4343
CHANGE_DEFAULT_PASSWORD ?= n
4444

45+
# Default value for SMARTSWITCH
46+
SMARTSWITCH ?= 0
47+
4548
# DEFAULT_USERNAME - default username for installer build
4649
DEFAULT_USERNAME = admin
4750

@@ -152,6 +155,11 @@ INCLUDE_DHCP_RELAY = y
152155
# INCLUDE_DHCP_SERVER - build and install dhcp-server package
153156
INCLUDE_DHCP_SERVER ?= n
154157

158+
# Conditionally enable DHCP_SERVER when SMARTSWITCH is set to 1
159+
ifeq ($(SMARTSWITCH), 1)
160+
INCLUDE_DHCP_SERVER = y
161+
endif
162+
155163
# INCLUDE_P4RT - build docker-p4rt for P4RT support
156164
INCLUDE_P4RT = n
157165

src/sonic-py-common/sonic_py_common/device_info.py

+16
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,22 @@ def is_chassis():
576576
return is_voq_chassis() or is_packet_chassis()
577577

578578

579+
def is_smartswitch():
580+
# Get platform
581+
platform = get_platform()
582+
if not platform:
583+
return False
584+
585+
# get platform.json file path
586+
platform_json = os.path.join(HOST_DEVICE_PATH, platform, "platform.json")
587+
try:
588+
with open(platform_json, 'r') as f:
589+
platform_cfg = json.loads(f.read())
590+
return "DPUS" in platform_cfg
591+
except IOError:
592+
return False
593+
594+
579595
def is_supervisor():
580596
platform_env_conf_file_path = get_platform_env_conf_file_path()
581597
if platform_env_conf_file_path is None:

0 commit comments

Comments
 (0)