[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.
This commit is contained in:
Shi Su 2020-10-23 13:08:35 -07:00 committed by GitHub
parent 15c59e1d8c
commit 67408c85aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 15 deletions

View File

@ -39,6 +39,9 @@ RUN pip install \
{{ install_python_wheels(docker_config_engine_buster_whls.split(' ')) }}
{% endif %}
# Copy files
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
## Clean up
RUN apt-get purge -y \
python-pip \

View File

@ -38,6 +38,9 @@ RUN pip install \
{{ install_python_wheels(docker_config_engine_stretch_whls.split(' ')) }}
{% endif %}
# Copy files
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
## Clean up
RUN apt-get purge -y \
python-pip \

View File

@ -42,6 +42,9 @@ python-wheels/{{ whl }}{{' '}}
{%- endfor %}
{%- endif -%}
# Copy files
COPY ["files/swss_vars.j2", "/usr/share/sonic/templates/"]
## Clean up
RUN apt-get purge -y python-pip python-dev; apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
RUN rm -rf /debs /python-wheels

View File

@ -1,15 +1,9 @@
#!/usr/bin/env bash
EXIT_SWSS_VARS_FILE_NOT_FOUND=1
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
if [ ! -f "$SWSS_VARS_FILE" ]; then
echo "SWSS vars template file not found"
exit $EXIT_SWSS_VARS_FILE_NOT_FOUND
fi
# Retrieve SWSS vars from sonic-cfggen
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE)
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1
export platform=$(echo $SWSS_VARS | jq -r '.asic_type')
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')

View File

@ -2,6 +2,5 @@
"asic_type": "{{ asic_type }}",
"asic_id": "{{ DEVICE_METADATA.localhost.asic_id }}",
"mac": "{{ DEVICE_METADATA.localhost.mac }}",
"synchronous_mode": "{{ DEVICE_METADATA.localhost.synchronous_mode }}"
"synchronous_mode": {% if DEVICE_METADATA.localhost.synchronous_mode == "enable" %}"enable"{% else %}"disable"{% endif %}
}

View File

@ -1,6 +1,11 @@
#!/usr/bin/env bash
MAC_ADDRESS=$(sonic-cfggen -d -v 'DEVICE_METADATA.localhost.mac')
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
# Retrieve SWSS vars from sonic-cfggen
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
logger "Mac address not found in Device Metadata, Falling back to eth0"
@ -14,7 +19,7 @@ ORCHAGENT_ARGS="-d /var/log/swss "
ORCHAGENT_ARGS+="-b 8192 "
# Set synchronous mode if it is enabled in CONFIG_DB
SYNC_MODE=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.synchronous_mode)
SYNC_MODE=$(echo $SWSS_VARS | jq -r '.synchronous_mode')
if [ "$SYNC_MODE" == "enable" ]; then
ORCHAGENT_ARGS+="-s "
fi

View File

@ -6,8 +6,12 @@ else
export platform=$fake_platform
fi
CFG_VARS=$(sonic-cfggen -d --var-json 'DEVICE_METADATA')
MAC_ADDRESS=$(echo $CFG_VARS | jq -r '.localhost.mac')
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
# Retrieve SWSS vars from sonic-cfggen
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE) || exit 1
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
logger "Mac address not found in Device Metadata, Falling back to eth0"
@ -21,7 +25,7 @@ ORCHAGENT_ARGS="-d /var/log/swss "
ORCHAGENT_ARGS+="-b 8192 "
# Set synchronous mode if it is enabled in CONFIG_DB
SYNC_MODE=$(echo $CFG_VARS | jq -r '.localhost.synchronous_mode')
SYNC_MODE=$(echo $SWSS_VARS | jq -r '.synchronous_mode')
if [ "$SYNC_MODE" == "enable" ]; then
ORCHAGENT_ARGS+="-s "
fi

View File

@ -7,6 +7,7 @@ $(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SWSSSDK_PY2)
$(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
$(DOCKER_CONFIG_ENGINE_BUSTER)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
$(DOCKER_CONFIG_ENGINE_BUSTER)_LOAD_DOCKERS += $(DOCKER_BASE_BUSTER)
$(DOCKER_CONFIG_ENGINE_BUSTER)_FILES += $(SWSS_VARS_TEMPLATE)
$(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_DEPENDS = $($(DOCKER_BASE_BUSTER)_DBG_DEPENDS)
$(DOCKER_CONFIG_ENGINE_BUSTER)_DBG_IMAGE_PACKAGES = $($(DOCKER_BASE_BUSTER)_DBG_IMAGE_PACKAGES)

View File

@ -6,6 +6,7 @@ $(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SWSSSDK_PY2)
$(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
$(DOCKER_CONFIG_ENGINE_STRETCH)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
$(DOCKER_CONFIG_ENGINE_STRETCH)_LOAD_DOCKERS += $(DOCKER_BASE_STRETCH)
$(DOCKER_CONFIG_ENGINE_STRETCH)_FILES += $(SWSS_VARS_TEMPLATE)
$(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS = $($(DOCKER_BASE_STRETCH)_DBG_DEPENDS)
$(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES = $($(DOCKER_BASE_STRETCH)_DBG_IMAGE_PACKAGES)

View File

@ -6,4 +6,5 @@ $(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SWSSSDK_PY2)
$(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SONIC_PY_COMMON_PY2)
$(DOCKER_CONFIG_ENGINE)_PYTHON_WHEELS += $(SONIC_CONFIG_ENGINE_PY2)
$(DOCKER_CONFIG_ENGINE)_LOAD_DOCKERS += $(DOCKER_BASE)
$(DOCKER_CONFIG_ENGINE)_FILES += $(SWSS_VARS_TEMPLATE)
SONIC_DOCKER_IMAGES += $(DOCKER_CONFIG_ENGINE)

View File

@ -23,6 +23,9 @@ $(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
UPDATE_CHASSISDB_CONFIG_SCRIPT = update_chassisdb_config
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts
SWSS_VARS_TEMPLATE = swss_vars.j2
$(SWSS_VARS_TEMPLATE)_PATH = files/build_templates
SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(ARP_UPDATE_SCRIPT) \
$(ARP_UPDATE_VARS_TEMPLATE) \
@ -30,4 +33,5 @@ SONIC_COPY_FILES += $(CONFIGDB_LOAD_SCRIPT) \
$(QOS_CONFIG_TEMPLATE) \
$(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT) \
$(SYSCTL_NET_CONFIG) \
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)
$(UPDATE_CHASSISDB_CONFIG_SCRIPT) \
$(SWSS_VARS_TEMPLATE)