Skip to content

Commit 67408c8

Browse files
authored
[synchronous-mode] Add template file for synchronous mode (#5644)
The orchagent and syncd need to have the same default synchronous mode configuration. This PR adds a template file to translate the default value in CONFIG_DB (empty field) to an explicit mode so that the orchagent and syncd could have the same default mode.
1 parent 15c59e1 commit 67408c8

File tree

11 files changed

+33
-15
lines changed

11 files changed

+33
-15
lines changed

dockers/docker-config-engine-buster/Dockerfile.j2

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ RUN pip install \
3939
{{ install_python_wheels(docker_config_engine_buster_whls.split(' ')) }}
4040
{% endif %}
4141

42+
# Copy files
43+
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
44+
4245
## Clean up
4346
RUN apt-get purge -y \
4447
python-pip \

dockers/docker-config-engine-stretch/Dockerfile.j2

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ RUN pip install \
3838
{{ install_python_wheels(docker_config_engine_stretch_whls.split(' ')) }}
3939
{% endif %}
4040

41+
# Copy files
42+
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
43+
4144
## Clean up
4245
RUN apt-get purge -y \
4346
python-pip \

dockers/docker-config-engine/Dockerfile.j2

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ python-wheels/{{ whl }}{{' '}}
4242
{%- endfor %}
4343
{%- endif -%}
4444

45+
# Copy files
46+
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
47+
4548
## Clean up
4649
RUN apt-get purge -y python-pip python-dev; apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
4750
RUN rm -rf /debs /python-wheels

dockers/docker-orchagent/orchagent.sh

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#!/usr/bin/env bash
22

3-
EXIT_SWSS_VARS_FILE_NOT_FOUND=1
43
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
54

6-
if [ ! -f "$SWSS_VARS_FILE" ]; then
7-
echo "SWSS vars template file not found"
8-
exit $EXIT_SWSS_VARS_FILE_NOT_FOUND
9-
fi
10-
115
# Retrieve SWSS vars from sonic-cfggen
12-
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE)
6+
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1
137
export platform=$(echo $SWSS_VARS | jq -r '.asic_type')
148

159
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')

dockers/docker-orchagent/swss_vars.j2 renamed to files/build_templates/swss_vars.j2

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
"asic_type": "{{ asic_type }}",
33
"asic_id": "{{ DEVICE_METADATA.localhost.asic_id }}",
44
"mac": "{{ DEVICE_METADATA.localhost.mac }}",
5-
"synchronous_mode": "{{ DEVICE_METADATA.localhost.synchronous_mode }}"
5+
"synchronous_mode": {% if DEVICE_METADATA.localhost.synchronous_mode == "enable" %}"enable"{% else %}"disable"{% endif %}
66
}
7-

platform/p4/docker-sonic-p4/orchagent.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/usr/bin/env bash
22

3-
MAC_ADDRESS=$(sonic-cfggen -d -v 'DEVICE_METADATA.localhost.mac')
3+
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
4+
5+
# Retrieve SWSS vars from sonic-cfggen
6+
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1
7+
8+
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')
49
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
510
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
611
logger "Mac address not found in Device Metadata, Falling back to eth0"
@@ -14,7 +19,7 @@ ORCHAGENT_ARGS="-d /var/log/swss "
1419
ORCHAGENT_ARGS+="-b 8192 "
1520

1621
# Set synchronous mode if it is enabled in CONFIG_DB
17-
SYNC_MODE=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.synchronous_mode)
22+
SYNC_MODE=$(echo $SWSS_VARS | jq -r '.synchronous_mode')
1823
if [ "$SYNC_MODE" == "enable" ]; then
1924
ORCHAGENT_ARGS+="-s "
2025
fi

platform/vs/docker-sonic-vs/orchagent.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ else
66
export platform=$fake_platform
77
fi
88

9-
CFG_VARS=$(sonic-cfggen -d --var-json 'DEVICE_METADATA')
10-
MAC_ADDRESS=$(echo $CFG_VARS | jq -r '.localhost.mac')
9+
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
10+
11+
# Retrieve SWSS vars from sonic-cfggen
12+
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1
13+
14+
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')
1115
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
1216
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
1317
logger "Mac address not found in Device Metadata, Falling back to eth0"
@@ -21,7 +25,7 @@ ORCHAGENT_ARGS="-d /var/log/swss "
2125
ORCHAGENT_ARGS+="-b 8192 "
2226

2327
# Set synchronous mode if it is enabled in CONFIG_DB
24-
SYNC_MODE=$(echo $CFG_VARS | jq -r '.localhost.synchronous_mode')
28+
SYNC_MODE=$(echo $SWSS_VARS | jq -r '.synchronous_mode')
2529
if [ "$SYNC_MODE" == "enable" ]; then
2630
ORCHAGENT_ARGS+="-s "
2731
fi

rules/docker-config-engine-buster.mk

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ $(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SWSSSDK_PY2)
77
$(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
88
$(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
99
$(DOCKER_CONFIG_ENGINE_BUSTER)_LOAD_DOCKERS += $(DOCKER_BASE_BUSTER)
10+
$(DOCKER_CONFIG_ENGINE_BUSTER)_FILES += $(SWSS_VARS_TEMPLATE)
1011

1112
$(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS = $($(DOCKER_BASE_BUSTER)_DBG_DEPENDS)
1213
$(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES = $($(DOCKER_BASE_BUSTER)_DBG_IMAGE_PACKAGES)

rules/docker-config-engine-stretch.mk

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SWSSSDK_PY2)
66
$(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
77
$(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
88
$(DOCKER_CONFIG_ENGINE_STRETCH)_LOAD_DOCKERS += $(DOCKER_BASE_STRETCH)
9+
$(DOCKER_CONFIG_ENGINE_STRETCH)_FILES += $(SWSS_VARS_TEMPLATE)
910

1011
$(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS = $($(DOCKER_BASE_STRETCH)_DBG_DEPENDS)
1112
$(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES = $($(DOCKER_BASE_STRETCH)_DBG_IMAGE_PACKAGES)

rules/docker-config-engine.mk

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ $(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SWSSSDK_PY2)
66
$(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
77
$(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
88
$(DOCKER_CONFIG_ENGINE)_LOAD_DOCKERS += $(DOCKER_BASE)
9+
$(DOCKER_CONFIG_ENGINE)_FILES += $(SWSS_VARS_TEMPLATE)
910
SONIC_DOCKER_IMAGES += $(DOCKER_CONFIG_ENGINE)

rules/scripts.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ $(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
2323
UPDATE_CHASSISDB_CONFIG_SCRIPT = update_chassisdb_config
2424
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
2525

26+
SWSS_VARS_TEMPLATE = swss_vars.j2
27+
$(SWSS_VARS_TEMPLATE)_PATH = files/build_templates
28+
2629
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
2730
$(ARP_UPDATE_SCRIPT) \
2831
$(ARP_UPDATE_VARS_TEMPLATE) \
2932
$(BUFFERS_CONFIG_TEMPLATE) \
3033
$(QOS_CONFIG_TEMPLATE) \
3134
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \
3235
$(SYSCTL_NET_CONFIG) \
33-
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)
36+
$(UPDATE_CHASSISDB_CONFIG_SCRIPT) \
37+
$(SWSS_VARS_TEMPLATE)

0 commit comments

Comments
 (0)