Skip to content
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

[NTP] 🐞 Fix config template to init default parameters #18736

Merged
merged 1 commit into from
May 15, 2024

Conversation

fastiuk
Copy link
Contributor

@fastiuk fastiuk commented Apr 21, 2024

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
  • 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 fastiuk changed the title 🐞 NTP: Fix minigraph config generation [NTP] 🐞 Fix minigraph config generation Apr 21, 2024
@fastiuk fastiuk self-assigned this Apr 21, 2024
@qiluo-msft
Copy link
Collaborator

qiluo-msft commented Apr 21, 2024

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

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.

Block as above comment.

@qiluo-msft qiluo-msft requested review from wen587 and ganglyu April 21, 2024 23:39
@ganglyu
Copy link
Contributor

ganglyu commented Apr 22, 2024

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?

@fastiuk
Copy link
Contributor Author

fastiuk commented Apr 22, 2024

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
Copy link
Contributor Author

fastiuk commented Apr 22, 2024

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 fastiuk changed the title [NTP] 🐞 Fix minigraph config generation [NTP] 🐞 Fix config template to init default parameters Apr 22, 2024
@fastiuk fastiuk closed this Apr 22, 2024
@fastiuk fastiuk reopened this Apr 22, 2024
@fastiuk
Copy link
Contributor Author

fastiuk commented Apr 27, 2024

/azpw run Azure.sonic-buildimage

@fastiuk fastiuk closed this Apr 27, 2024
@fastiuk fastiuk reopened this Apr 27, 2024
@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@fastiuk
Copy link
Contributor Author

fastiuk commented Apr 28, 2024

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
Copy link
Contributor Author

fastiuk commented Apr 30, 2024

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@fastiuk fastiuk force-pushed the dev-ntp-fix branch 2 times, most recently from 5210cce to 214d453 Compare May 4, 2024 20:37
@anamehra
Copy link
Contributor

anamehra commented May 6, 2024

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?

@liat-grozovik
Copy link
Collaborator

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

@liat-grozovik
Copy link
Collaborator

/azpw run Azure.sonic-buildimage

{% if global.server_role == 'disabled' %}
restrict {{ config_as }} kod limited nomodify notrap noquery{{ aoptions }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please clarify why notrap and aoptions are removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nopeer and notrap is not supported by ntp-sec anymore. You can check its reference here: https://docs.ntpsec.org/latest/accopt.html
aoptions was used to add nopeer based on condition (if server is not a pool), but now it is not needed anymore.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@fastiuk Then we may need to raise a separate PR for 202311 as 202311 doesn't use bookworm. @saiarcot895 FYI

@abdosi abdosi added the P0 Priority of the issue label May 8, 2024
@fastiuk
Copy link
Contributor Author

fastiuk commented May 8, 2024

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@fastiuk
Copy link
Contributor Author

fastiuk commented May 9, 2024

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
Copy link
Contributor Author

fastiuk commented May 9, 2024

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

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

@fastiuk
Copy link
Contributor Author

fastiuk commented May 14, 2024

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

@qiluo-msft qiluo-msft merged commit b952caa into sonic-net:master May 15, 2024
19 checks passed
fastiuk added a commit to fastiuk/sonic-buildimage that referenced this pull request May 16, 2024
fixes sonic-net#17906

#### Why I did it
To fix NTP config generation from the minigraph and save backward compatability

#### 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:
```json
{
  "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
```
fastiuk added a commit to fastiuk/sonic-buildimage that referenced this pull request May 16, 2024
fixes sonic-net#17906

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

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

Out of that NTP_SERVER configuration:
```json
{
  "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
```

Signed-off-by: Yevhen Fastiuk <[email protected]>
yxieca pushed a commit that referenced this pull request May 28, 2024
fixes #17906

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

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

Out of that NTP_SERVER configuration:
```json
{
  "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
```

Signed-off-by: Yevhen Fastiuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Archived in project
Development

Successfully merging this pull request may close these issues.

The NTP_SERVER configuration generated from the minigraph doesn't meet the new schema requirements.