sonic-buildimage icon indicating copy to clipboard operation
sonic-buildimage copied to clipboard

[NTP] 🐞 Fix config template to init default parameters

Open fastiuk opened this issue 1 year ago • 11 comments
trafficstars

fixes #17906

Why I did it

To fix NTP config generation from the minigraph and save backward compatability

Work item tracking
  • Microsoft ADO (number only):

How I did it

Align ntp.conf.j2 template to generate config out of empty NTP_SERVER DB configuration

How to verify it

Out of that NTP_SERVER configuration:

{
  "10.210.25.32": {},
  "10.75.202.2": {}
}

The next config in ntp.conf file should be produced:

server 10.210.25.32
restrict 10.210.25.32 kod limited nomodify notrap noquery nopeer

server 10.75.202.2
restrict 10.75.202.2 kod limited nomodify notrap noquery nopeer

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

  • [ ] 201811
  • [ ] 201911
  • [ ] 202006
  • [ ] 202012
  • [ ] 202106
  • [ ] 202111
  • [ ] 202205
  • [ ] 202211
  • [ ] 202305
  • [x] 202311

Tested branch (Please provide the tested image version)

  • [ ]
  • [ ]

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (it is my cat Finn)

PXL_20230413_140941610 PORTRAIT

fastiuk avatar Apr 21 '24 00:04 fastiuk

You mentioned "The NTP_SERVER configuration generated from the minigraph doesn't meet the new schema requirements" in the issue. To solve the problem, it is better to fix the schema (https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-ntp.yang) instead of fixing the config generation behavior. The behavior is old from 2017. Any new schema design should be backward-compatible. #Closed

qiluo-msft avatar Apr 21 '24 23:04 qiluo-msft

Please check db_migrator, https://github.com/sonic-net/sonic-utilities/blob/master/scripts/db_migrator.py Do we need to update db_migrator to migrate old ntp config to new schema?

ganglyu avatar Apr 22 '24 00:04 ganglyu

You mentioned "The NTP_SERVER configuration generated from the minigraph doesn't meet the new schema requirements" in the issue. To solve the problem, it is better to fix the schema (https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-ntp.yang) instead of fixing the config generation behavior. The behavior is old from 2017. Any new schema design should be backward-compatible.

Minigraph doesn't use YANG to generate config, because there are default values in YANG. Anyway I already changed ntp.conf.j2 template according to your request, so it will preserve backward compatibility

fastiuk avatar Apr 22 '24 08:04 fastiuk

Please check db_migrator, https://github.com/sonic-net/sonic-utilities/blob/master/scripts/db_migrator.py Do we need to update db_migrator to migrate old ntp config to new schema?

No need according to changes @qiluo-msft requested

fastiuk avatar Apr 22 '24 08:04 fastiuk

/azpw run Azure.sonic-buildimage

fastiuk avatar Apr 27 '24 21:04 fastiuk

/AzurePipelines run Azure.sonic-buildimage

mssonicbld avatar Apr 27 '24 21:04 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 27 '24 21:04 azure-pipelines[bot]

The PR checker was failed because ntpsec does not support nopeer and notrap flags anymore: https://docs.ntpsec.org/latest/accopt.html Fixed it by removing nopeer and notrap flags.

fastiuk avatar Apr 28 '24 17:04 fastiuk

/azpw run Azure.sonic-buildimage

fastiuk avatar Apr 30 '24 12:04 fastiuk

/AzurePipelines run Azure.sonic-buildimage

mssonicbld avatar Apr 30 '24 12:04 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar Apr 30 '24 12:04 azure-pipelines[bot]

How do we configure some of the config params like config.iburst, config.resolve_as, etc. for NTP server used in this j2 file via sonic-mgmt? Is there any document to refer to?

anamehra avatar May 06 '24 02:05 anamehra

@oleksandrivantsiv @dgsudharsan could you please help to review this fix?

liat-grozovik avatar May 07 '24 10:05 liat-grozovik

/azpw run Azure.sonic-buildimage

liat-grozovik avatar May 07 '24 10:05 liat-grozovik

/azpw run Azure.sonic-buildimage

fastiuk avatar May 08 '24 21:05 fastiuk

/AzurePipelines run Azure.sonic-buildimage

mssonicbld avatar May 08 '24 21:05 mssonicbld

Azure Pipelines successfully started running 1 pipeline(s).

azure-pipelines[bot] avatar May 08 '24 21:05 azure-pipelines[bot]

How do we configure some of the config params like config.iburst, config.resolve_as, etc. for NTP server used in this j2 file via sonic-mgmt? Is there any document to refer to?

config.iburst only trough the DB. So far only server can be added via SONiC CLI. config.resolve_as is internal option for a NTP server and shouldn't be configured directly. It used to save resolved address, because when you configure time.google.com for example it changes address every time. So now config.resolve_as is configured via SONiC CLI when new NTP server is added.

fastiuk avatar May 09 '24 07:05 fastiuk

@oleksandrivantsiv @dgsudharsan could you please help to review this fix?

@oleksandrivantsiv @dgsudharsan : checkers are passed. All comments handled, please approve if looks good

fastiuk avatar May 09 '24 07:05 fastiuk

@qiluo-msft the PR was approved. Could you please merge it?

fastiuk avatar May 14 '24 20:05 fastiuk