[ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB#7586
[ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB#7586yxieca merged 2 commits intosonic-net:masterfrom
Conversation
|
can you add test in src/sonic-config-engine/tests to test the template? |
|
@lguohan To verify that we are on the same page I assume you are referring to a new test here (https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-config-engine/tests/test_j2files.py) that would validate the output of |
|
I would use https://github.com/Azure/sonic-buildimage/blob/master/src/sonic-config-engine/tests/test_j2files.py#L291 as a template, it seems to be a similar test to the one I would want to perform (i.e. provide a minimal config_db file and check that the desired template output matches a ground truth) One question would be that there are many branches within this template file. Is our desire to test all of these branches? That may be out of the scope of this pull request. I would propose just adding a test for the case of multiple valid IP addresses for a given Ethernet interface. |
|
i am ok with your proposal. |
…_DB (#7586) Why I did it Currently, there is a bug in the ntp.conf jinja2 template where it will ignore the src_intf directive in CONFIG_DB if there are multiple IP addresses associated with an interface. This code change fixes that bug and allows the template to select the correct source interface for NTP. How I did it I did this by modifying the macro in ntp.conf.j2 which determines if there is an ip address associated with an interface to set a state variable when it detects a valid interface entry in CONFIG_DB instead of outputting "true" directly (which could result in multiple "trues" outputted for interfaces with multiple valid IP addresses). How to verify it Add two ipv4 addresses to an interface in SONiC Add the following configuration to config_db.json { "NTP": { "global": { "src_intf": "Ethernet1" } } } Replace Ethernet1 with the interface name of the one you assigned the IP addresses to. Run sudo config reload -y Open /etc/ntp.conf and verify that the following line exists ... interface listen Ethernet1 ... The interface specified should be the one set in the previous steps. Description for the changelog [ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB
…_DB (sonic-net#7586) Why I did it Currently, there is a bug in the ntp.conf jinja2 template where it will ignore the src_intf directive in CONFIG_DB if there are multiple IP addresses associated with an interface. This code change fixes that bug and allows the template to select the correct source interface for NTP. How I did it I did this by modifying the macro in ntp.conf.j2 which determines if there is an ip address associated with an interface to set a state variable when it detects a valid interface entry in CONFIG_DB instead of outputting "true" directly (which could result in multiple "trues" outputted for interfaces with multiple valid IP addresses). How to verify it Add two ipv4 addresses to an interface in SONiC Add the following configuration to config_db.json { "NTP": { "global": { "src_intf": "Ethernet1" } } } Replace Ethernet1 with the interface name of the one you assigned the IP addresses to. Run sudo config reload -y Open /etc/ntp.conf and verify that the following line exists ... interface listen Ethernet1 ... The interface specified should be the one set in the previous steps. Description for the changelog [ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB
…_DB (sonic-net#7586) Why I did it Currently, there is a bug in the ntp.conf jinja2 template where it will ignore the src_intf directive in CONFIG_DB if there are multiple IP addresses associated with an interface. This code change fixes that bug and allows the template to select the correct source interface for NTP. How I did it I did this by modifying the macro in ntp.conf.j2 which determines if there is an ip address associated with an interface to set a state variable when it detects a valid interface entry in CONFIG_DB instead of outputting "true" directly (which could result in multiple "trues" outputted for interfaces with multiple valid IP addresses). How to verify it Add two ipv4 addresses to an interface in SONiC Add the following configuration to config_db.json { "NTP": { "global": { "src_intf": "Ethernet1" } } } Replace Ethernet1 with the interface name of the one you assigned the IP addresses to. Run sudo config reload -y Open /etc/ntp.conf and verify that the following line exists ... interface listen Ethernet1 ... The interface specified should be the one set in the previous steps. Description for the changelog [ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB
Why I did it
Currently, there is a bug in the ntp.conf jinja2 template where it will ignore the
src_intfdirective in CONFIG_DB if there are multiple IP addresses associated with an interface. This code change fixes that bug and allows the template to select the correct source interface for NTP.How I did it
I did this by modifying the macro in
ntp.conf.j2which determines if there is an ip address associated with an interface to set a state variable when it detects a valid interface entry in CONFIG_DB instead of outputting "true" directly (which could result in multiple "trues" outputted for interfaces with multiple valid IP addresses).How to verify it
Add two ipv4 addresses to an interface in SONiC
Add the following configuration to
config_db.jsonReplace
Ethernet1with the interface name of the one you assigned the IP addresses to.Run
sudo config reload -yOpen
/etc/ntp.confand verify that the following line existsThe interface specified should be the one set in the previous steps.
Description for the changelog
[ntp] Fix ntp.conf template to allow setting of source port in CONFIG_DB
A picture of a cute animal (not mandatory but encouraged)