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: add config to filter and set ntp interfaces #11066

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions roles/kubernetes/preinstall/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ ntp_servers:
ntp_restrict:
- "127.0.0.1"
- "::1"
# Specify whether to filter interfaces
Copy link
Member

Choose a reason for hiding this comment

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

HI @Pavan-Gunda

Because there is only one variable that needs to be config, so

# Some comments
# Uncomment `ntp_interfaces` if enable xxxx
# ntp_interfaces: 
#   - ignore wildcard
#   - isten xxx

Which Can be easier for the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you 👍

I made the change now and pushed the code :)

ntp_filter_interface: false
# Specify the interfaces
# Only takes effect when ntp_filter_interface is true
ntp_interfaces:
- ens3
Copy link
Contributor

Choose a reason for hiding this comment

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

It's risky. ens3 is an exact NIC name and is not applicable in most scenarios. I prefer to comment them out and suggest that when ntp_filter_interface is true, we should update the value of ntp_interfaces to match the node's NIC name.

But, do you think this still works for scenarios with inconsistent NIC names per node?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I will comment out the ntp_interfaces section and add your suggestion as a comment.

When having inconsistent NIC names per node, One can have all interfaces from all nodes listed under this list of interfaces and if the interface does not exist on a node, I did a quick test and NTP simply just listens on the set of interfaces that do exist.

interface listen ens3
interface listen test

The ntp server logs looked something like this when I restarted the service

systemd[1]: Started Network Time Service.
ntpd[252818]: proto: precision = 0.050 usec (-24)
ntpd[252818]: restrict: 'monitor' cannot be disabled while 'limited' is enabled
ntpd[252818]: Listen normally on 0 lo 127.0.0.1:123
ntpd[252818]: Listen normally on 1 ens3 xx.xx.xx.xx:123
ntpd[252818]: Listen normally on 2 lo [::1]:123
ntpd[252818]: Listen normally on 3 ens3 [xxx.xxx.xxx.xxx]:123
ntpd[252818]: Listen normally on 4 ens3 [xxx.xxx.xxx.xxx]:123
ntpd[252818]: Listening on routing socket on fd #21 for interface updates

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @Pavan-Gunda , It looks like the ntp_interfaces section is still not commented out. Is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi!

I commented ntp_interfaces section out now. :)

# The NTP driftfile path
# Only takes effect when ntp_manage_config is true.
ntp_driftfile: /var/lib/ntp/ntp.drift
Expand Down
7 changes: 7 additions & 0 deletions roles/kubernetes/preinstall/templates/ntp.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ restrict -6 default kod notrap nomodify nopeer noquery limited
restrict {{ item }}
{% endfor %}

{% if ntp_filter_interface %}
interface ignore wildcard
{% for item in ntp_listen %}
interface listen {{ item }}
{% endfor %}
{% endif %}

Copy link
Member

Choose a reason for hiding this comment

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

# Some comments
{% for item in ntp_interfaces %}
interface {{ item }}
{% endfor %}

# Needed for adding pool entries
restrict source notrap nomodify noquery

Expand Down