-
Notifications
You must be signed in to change notification settings - Fork 403
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
Add chrony for time sync for Azure image #240
Conversation
images/capi/packer/azure/packer.json
Outdated
{ | ||
"type": "shell", | ||
"inline": [ | ||
"sudo apt-get -qq update && sudo apt-get -qqy install chrony && sudo systemctl restart chrony.service" |
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.
Could this be moved to the Ansible code instead? I suspect there will also need to be some additional modifications to the chrony config to configure the ptp time source, as described in https://docs.microsoft.com/en-us/azure/virtual-machines/linux/time-sync#chrony.
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.
ok, will look into how to do that using ansible instead
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.
also, if there was a daemon already present, need to make sure that's disabled and removed.
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.
The ubuntu bionic docs say to install it https://ubuntu.com/blog/ubuntu-bionic-using-chrony-to-configure-ntp but I will double check
@nader-ziada how do you plan on testing this change? We should at least make sure the result is what we want before changing image builder (ie. building an image with these changes and using that to build a CAPZ cluster). |
- name: fix chrony drift | ||
shell: chronyc makestep 1.0 -1 | ||
args: | ||
executable: /bin/bash |
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.
This step isn't relevant at the point of creating an image, as new machines are going to be created anyway with a completely different time.
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.
Does chronyc actually change the config, or just the current process config?
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.
Just checked locally on Fedora 32:
cluster-api on master [⇡$] at ☸️ kind-kind took 5s
➜ sudo chronyc makestep 1.0 -1
200 OK
cluster-api on master [⇡$] at ☸️ kind-kind
➜ cat /etc/chrony.conf
# These servers were defined in the installation:
pool time.google.com iburst
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
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.
might be actually changing the current process, i need to double 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.
Probably want to add something like
- name: Configure PTP
lineinfile:
path: /etc/chrony/chrony.conf
create: yes
line: refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0
- name: Ensure makestep parameter set as per Azure recommendation
lineinfile:
path: /etc/chrony/chrony.conf
regexp: '^makestep'
line: makestep 1.0 -1
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.
Thank you, I was just trying to to figure out how to do this in ansible!
|
||
- name: restart chrony.service to pick up config changes | ||
systemd: | ||
state: restarted |
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.
state: restarted | |
enabled: yes | |
state: restarted |
Better to be explicit that we want it enabled on boot. The restart isn't technically necessary because of image creation.
@CecileRobertMichon yes, I build the image and created a vm with it manually, next will try it with a cluster |
/cc @jackfrancis (related to Azure/aks-engine#2552) |
@CecileRobertMichon: GitHub didn't allow me to request PR reviews from the following users: jackfrancis. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
created the image and VM from it and this is what I see:
|
I created a few Azure clusters using the image I generated from here and everything is working fine, not sure if there is a special test we need to check on the cluster, but at least this doesn't break anything and |
@CecileRobertMichon is it possible for you to try this out? |
@detiber @randomvariable do we have plans to include E2E testing as a presubmit for image-buidler PRs? Seems like it would be useful in cases like this |
@nader-ziada this looks good to me, but we really need a way to be able to test changes to the image in a non-manual way in the future :) /lgtm |
@CecileRobertMichon i can work on tests but better if we can discuss what scope to cover |
@detiber ready for another look, Thanks |
/cc @codenrhoden to speak to testing plans for image-builder |
@detiber: GitHub didn't allow me to request PR reviews from the following users: image-builder, to, speak, testing, for. Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
- name: Ansible apt install chrony | ||
apt: | ||
name: chrony | ||
state: present |
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.
This should probably be wrapped in a conditional to only run when the OS is Ubuntu similar to:
image-builder/images/capi/ansible/roles/providers/tasks/aws.yml
Lines 38 to 40 in c680d2c
- name: install aws agents Ubuntu | |
shell: snap install amazon-ssm-agent --classic | |
when: ansible_distribution == "Ubuntu" |
Relatively minor nit, but would have an impact if/when other OS images are supported for Azure images.
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.
updated to add check for Ubuntu
Chrony is the only way to sync time from host using PTP source according to the azure team
/lgtm |
Hi @codenrhoden , do you have any concerns with this change? |
/approve Thanks for this @nader-ziada! And for trying out clusters with CAPZ first since there are no blocking PR tests still...
Short answer is "yes". 😆 But definitely lacking on details so far. But I am in 100% agreement that this is necessary. It's in my near-term plans to start to focus on this. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: codenrhoden, nader-ziada The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Chrony is the only way to sync time from host using PTP source according to the azure team
Related to issue 539 in cluster-api-provider-azure