-
Notifications
You must be signed in to change notification settings - Fork 292
CP-54471 Configure Dom0 NTP via XAPI #6689
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
base: feature/config-ntp-timezone-maxcstate
Are you sure you want to change the base?
CP-54471 Configure Dom0 NTP via XAPI #6689
Conversation
- write ntp servers to chrony.conf - interaction with dhclient - handle /run/chrony-dhcp/$interface.sources - handle chrony.sh - restart chrony Signed-off-by: Changlei Li <changlei.li@cloud.com>
Signed-off-by: Changlei Li <changlei.li@cloud.com>
Signed-off-by: Changlei Li <changlei.li@cloud.com>
Examles:
|
Did you mean |
|
||
let chrony_conf = "/etc/chrony.conf" | ||
|
||
let chrony_script = "/etc/dhcp/dhclient.d/chrony.sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually scripts are added to the list of requited commands in ocaml/idl
so xapi will refuse to run if any of them are missing. Is there any reason this shouldn't be the case here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I am not aware of this. Let me check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean xapi_globs.ml
right?
let chrony_dhcp_server_path interface = | ||
Printf.sprintf "%s/%s.sources" chrony_dhcp_dir interface | ||
|
||
let chrony_conf = "/etc/chrony.conf" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to use /etc/chrony.conf.d/99-xapi.conf
instead? we don't want a situation where installing a new verison of the package overwrites the values that the user has set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Dom0 system, it is suggested to use xapi manage the service if xapi has the API. If there is the case that the user configures chrony via ssh to Dom0 and modify the chrony.conf directly, then it is designed to overwrite it. For example, use ntp_mode_dhcp will remove all the server items in chrony.conf, even added by the user.
And it is designed in dbsync when XAPI starts (in following PRs), will read the chrony.conf and chrony.sh to sync the host.ntp_mode and host.ntp_custom_servers. The dbsync will aslo resolve the upgrade case.
I think using /etc/chrony.conf
here is OK. (Also follow the current xsconsole behavior).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is the case that the user configures chrony via ssh to Dom0 and modify the chrony.conf directly
This is not the situation I'm exposing, I'm talking about the case where a user has used xapi to configure chrony.conf, and later a chrony rpm installs a new chrony.conf and overwrites the current contents of the file, maybe because whoever releases the new version of chrony is not aware that users can use xapi to change the contents of chrony.conf
Please use the custom /etc/chrony.conf.d/99-xapi.conf
to avoid future problems
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand now. But you know, in the existing Dom0 system, many other components cooperate to handle the rpm install, update, host upgrade to keep Dom0 running. It's not easy to change the convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can try to make the path configurable in xapi config, then you have chance to replace it with another path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's why I asked? the convention is usually to load configuration from /etc/SERVICE.conf
and /etc/SERVICE.conf.d/*
How about Active Directory? IIUC that relies on a working clock synchronization with the AD servers (which may be out of sync with NTP, e.g. we've had situations where they were 30m off). |
New filed:
host.ntp_mode
,host.ntp_custom_servers
New API:
host.set_ntp_mode
,host.set_ntp_custom_servers
,host.get_ntp_mode
,host.get_ntp_custom_servers
.ntp_mode_dhcp: In this mode, ntp uses the dhcp assigned ntp servers as sources. In Dom0, dhclient triggers
chrony.sh
to update the ntp servers when network event happens. It writes ntp servers to/run/chrony-dhcp/$interface.sources
and the dir/run/chrony-dhcp
is included inchrony.conf
. The dhclient also stores dhcp lease in/var/lib/xcp/dhclient-$interface.leases
, see https://github.com/xapi-project/xen-api/blob/v25.31.0/ocaml/networkd/lib/network_utils.ml#L925. When switch ntp mode to dhcp, XAPI checks the lease file and finds ntp server then fills chrony-dhcp file. The exec permission ofchrony.sh
is added. When swith ntp mode from dhcp to others, XAPI removes the chrony-dhcp files and the exec permission ofchrony.sh
. The operation is same with xsconsole https://github.com/xapi-project/xsconsole/blob/v11.1.1/XSConsoleData.py#L593. In this feature, xsconsole will change to use XenAPI to manage ntp later to avoid conflict.ntp_mode_custom: In this mode, ntp uses
host.ntp_custom_servers
as sources. This is implemented by changingchrony.conf
and restart chronyd.host.ntp_custom_servers
is set by the user.ntp_mode_default: In this mode, ntp uses default-ntp-servers in XAPI config file.
The dbsync, more APIs about NTP will be in following PRs.