Skip to content

[synchronous-mode] Add template file for synchronous mode #5644

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

Merged
merged 6 commits into from
Oct 23, 2020

Conversation

shi-su
Copy link
Contributor

@shi-su shi-su commented Oct 16, 2020

- Why I did it
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.

- How I did it
Add a template file to /etc/sonic/ directory so that both syncd and orchagent could access the same template file to determine the default mode.

- How to verify it
Verified with kvm and dvs locally

- Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@shi-su shi-su requested a review from qiluo-msft October 16, 2020 01:36
@@ -14,7 +14,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=$(sonic-cfggen -d -t /etc/sonic/synchronous_mode.j2 | jq -r '.synchronous_mode')
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 16, 2020

Choose a reason for hiding this comment

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

sonic-cfggen [](start = 12, length = 12)

sonic-cfggen is slow in the warm/fast reboot critical timeline. So we optimize them aggressively.
It is possible to limit only one call in each script to generate everything into a big variable, and extract each config from the variable. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reduced sonic-cfggen usage.

@shi-su shi-su marked this pull request as ready for review October 16, 2020 16:23
@shi-su
Copy link
Contributor Author

shi-su commented Oct 16, 2020

retest vsimage please

rules/scripts.mk Outdated
@@ -23,11 +23,15 @@ $(SYSCTL_NET_CONFIG)_PATH = files/image_config/sysctl
UPDATE_CHASSISDB_CONFIG_SCRIPT = update_chassisdb_config
$(UPDATE_CHASSISDB_CONFIG_SCRIPT)_PATH = files/scripts

SWSS_SYNCD_VARS_TEMPLATE = swss_syncd_vars.j2
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 16, 2020

Choose a reason for hiding this comment

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

SWSS_SYNCD_VARS_TEMPLATE [](start = 0, length = 24)

Wondering why original code don't need it. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is needed here to make the file available to be copied to dvs and p4 docker. The template file was not available in the platforms.

fi

# Retrieve SWSS vars from sonic-cfggen
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE)
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 16, 2020

Choose a reason for hiding this comment

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

$SWSS_VARS_FILE [](start = 63, length = 15)

If SWSS vars template file not found, the command substitution will fail, so you can catch the error and exit. It is too verbose to check every input files. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the verbose check for the template file.

@@ -1,7 +1,7 @@
#!/usr/bin/env bash

EXIT_SWSS_VARS_FILE_NOT_FOUND=1
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
SWSS_VARS_FILE=/etc/sonic/swss_syncd_vars.j2
Copy link
Collaborator

@qiluo-msft qiluo-msft Oct 16, 2020

Choose a reason for hiding this comment

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

/etc/sonic/swss_syncd_vars.j2 [](start = 15, length = 29)

Does it make more sense to keep it in original directory? User are not expected to modify this file.
BTW, keep the original filename still make sense to me. #Closed

Copy link
Contributor Author

@shi-su shi-su Oct 16, 2020

Choose a reason for hiding this comment

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

The original directory /usr/share/sonic/templates is only available in swss docker. The reason to move it to /etc/sonic is to make the same template file accessible to both swss and syncd. Also, as this template is going to be accessed by syncd as well, I renamed to reflect this.

qiluo-msft
qiluo-msft previously approved these changes Oct 16, 2020
Copy link
Collaborator

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

LGTM. Please wait @tahmed-dev review.

@shi-su
Copy link
Contributor Author

shi-su commented Oct 19, 2020

retest mellanox please

@lguohan
Copy link
Collaborator

lguohan commented Oct 20, 2020

@qiluo-msft, what do you need @tahmed-dev to review? can you mark it?

@qiluo-msft
Copy link
Collaborator

@tahmed-dev Could you help review sonic-cfggen related code changes?

@tahmed-dev
Copy link
Contributor

tahmed-dev commented Oct 20, 2020

@tahmed-dev Could you help review sonic-cfggen related code changes?

@qiluo-msft sure.

@tahmed-dev
Copy link
Contributor

The change LGTM, however I just find the case for the swss_vars.j2 template files residing in /etc/sonic to be an outlier.

@tahmed-dev
Copy link
Contributor

@shi-su wonder if symlink-ing the file in the source code base would be a viable solution.

@@ -23,11 +23,15 @@ $(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) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

SONIC_COPY_FILES [](start = 0, length = 16)

Why we don't need to change this before?

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 template file was previously put in the docker-orchagent directory, so it could be seen by orchagent docker. Since we want to put this file into more than one docker, I moved it into a shared place and added this change.

@shi-su
Copy link
Contributor Author

shi-su commented Oct 22, 2020

retest vs please

@shi-su
Copy link
Contributor Author

shi-su commented Oct 23, 2020

retest broadcom please

@shi-su
Copy link
Contributor Author

shi-su commented Oct 23, 2020

retest broadcom please

@shi-su shi-su merged commit 67408c8 into sonic-net:master Oct 23, 2020
santhosh-kt pushed a commit to santhosh-kt/sonic-buildimage that referenced this pull request Feb 25, 2021
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants