diff --git a/ansible/inventory/group_vars/all/time b/ansible/inventory/group_vars/all/time index 6a60b7c15..4f84ce60d 100644 --- a/ansible/inventory/group_vars/all/time +++ b/ansible/inventory/group_vars/all/time @@ -38,3 +38,17 @@ chrony_ntp_servers: # Synchronise hardware clock with system time. Default is true. chrony_rtcsync_enabled: true + +# Force synchronisation from NTP sources. This methods may jump the clock by +# large values which can cause issues with some software. Disabled by default. +ntp_force_sync: false + +# Maximum number of tries used by the `chronyc waitsync` command. Only used +# when ntp_force_sync is true. Default is 60 which waits for a maximum of 10 +# minutes (60 times 10 seconds). +chrony_waitsync_max_tries: 60 + +# Maximum correction used by the `chronyc waitsync` command. Only used when +# ntp_force_sync is true. Default is 0.01 which waits for the remaining +# correction to be less than 10 milliseconds. +chrony_waitsync_max_correction: 0.01 diff --git a/ansible/roles/ntp/tasks/sync.yml b/ansible/roles/ntp/tasks/sync.yml index e679d3915..f969936c3 100644 --- a/ansible/roles/ntp/tasks/sync.yml +++ b/ansible/roles/ntp/tasks/sync.yml @@ -1,4 +1,9 @@ --- +# NOTE(priteau): We need to run handlers to restart chronyd before forcing +# clock synchronisation, or the system clock could appear as not synchronised +# during CI jobs because the tests run too quickly after the chronyd restart. +- meta: flush_handlers + - name: Force time synchronisation become: True block: @@ -9,8 +14,7 @@ command: chronyc makestep - name: Wait before hardware clock synchronisation - pause: - seconds: 5 + command: "chronyc waitsync {{ chrony_waitsync_max_tries }} {{ chrony_waitsync_max_correction }}" - name: Force hardware clock synchronisation command: hwclock --systohc diff --git a/etc/kayobe/time.yml b/etc/kayobe/time.yml index 8bfbd3391..652844c8d 100644 --- a/etc/kayobe/time.yml +++ b/etc/kayobe/time.yml @@ -33,6 +33,20 @@ # Synchronise hardware clock with system time. Default is true. #chrony_rtcsync_enabled: +# Force synchronisation from NTP sources. This methods may jump the clock by +# large values which can cause issues with some software. Disabled by default. +#ntp_force_sync: + +# Maximum number of tries used by the `chronyc waitsync` command. Only used +# when ntp_force_sync is true. Default is 60 which waits for a maximum of 10 +# minutes (60 times 10 seconds). +#chrony_waitsync_max_tries: + +# Maximum correction used by the `chronyc waitsync` command. Only used when +# ntp_force_sync is true. Default is 0.01 which waits for the remaining +# correction to be less than 10 milliseconds. +#chrony_waitsync_max_correction: + ############################################################################### # Dummy variable to allow Ansible to accept this file. workaround_ansible_issue_8743: yes diff --git a/playbooks/kayobe-infra-vm-base/overrides.yml.j2 b/playbooks/kayobe-infra-vm-base/overrides.yml.j2 index 3493adab5..0c3865b48 100644 --- a/playbooks/kayobe-infra-vm-base/overrides.yml.j2 +++ b/playbooks/kayobe-infra-vm-base/overrides.yml.j2 @@ -15,6 +15,9 @@ pip_upper_constraints_file: "/tmp/upper-constraints.txt" # QEMU. libvirt_vm_engine: "qemu" +# Force system clock synchronisation +ntp_force_sync: True + # Use the CI infra's PyPI mirror. pip_local_mirror: true pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple" diff --git a/playbooks/kayobe-overcloud-base/overrides.yml.j2 b/playbooks/kayobe-overcloud-base/overrides.yml.j2 index cae26b818..7e4dbc5f6 100644 --- a/playbooks/kayobe-overcloud-base/overrides.yml.j2 +++ b/playbooks/kayobe-overcloud-base/overrides.yml.j2 @@ -15,6 +15,9 @@ kolla_ansible_requirements_yml: "/tmp/kolla-ansible-requirements.yml" kolla_openstack_logging_debug: True pip_upper_constraints_file: "/tmp/upper-constraints.txt" +# Force system clock synchronisation +ntp_force_sync: True + # Use the CI infra's PyPI mirror. pip_local_mirror: true pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple" diff --git a/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 b/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 index f3b459866..f37b46f1e 100644 --- a/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 +++ b/playbooks/kayobe-overcloud-host-configure-base/overrides.yml.j2 @@ -184,6 +184,9 @@ chrony_ntp_servers: - option: maxsources val: 2 +# Force system clock synchronisation +ntp_force_sync: True + # Enable firewalld controller_firewalld_enabled: true controller_firewalld_zones: diff --git a/playbooks/kayobe-overcloud-upgrade-base/overrides.yml.j2 b/playbooks/kayobe-overcloud-upgrade-base/overrides.yml.j2 index 84301ef94..1170a5ed9 100644 --- a/playbooks/kayobe-overcloud-upgrade-base/overrides.yml.j2 +++ b/playbooks/kayobe-overcloud-upgrade-base/overrides.yml.j2 @@ -19,6 +19,9 @@ kolla_ansible_requirements_yml: "/tmp/previous-kolla-ansible-requirements.yml" {% endif %} kolla_openstack_logging_debug: true +# Force system clock synchronisation +ntp_force_sync: True + # Use the CI infra's PyPI mirror. pip_local_mirror: true pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple" diff --git a/playbooks/kayobe-seed-base/overrides.yml.j2 b/playbooks/kayobe-seed-base/overrides.yml.j2 index 062ab6c15..91c09a698 100644 --- a/playbooks/kayobe-seed-base/overrides.yml.j2 +++ b/playbooks/kayobe-seed-base/overrides.yml.j2 @@ -17,6 +17,9 @@ kolla_ansible_requirements_yml: "/tmp/kolla-ansible-requirements.yml" kolla_openstack_logging_debug: True pip_upper_constraints_file: "/tmp/upper-constraints.txt" +# Force system clock synchronisation +ntp_force_sync: True + # Use the CI infra's PyPI mirror. pip_local_mirror: true pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple" diff --git a/playbooks/kayobe-seed-upgrade-base/overrides.yml.j2 b/playbooks/kayobe-seed-upgrade-base/overrides.yml.j2 index 185d42420..683833025 100644 --- a/playbooks/kayobe-seed-upgrade-base/overrides.yml.j2 +++ b/playbooks/kayobe-seed-upgrade-base/overrides.yml.j2 @@ -19,6 +19,9 @@ kolla_ansible_requirements_yml: "/tmp/previous-kolla-ansible-requirements.yml" {% endif %} kolla_openstack_logging_debug: True +# Force system clock synchronisation +ntp_force_sync: True + # Use the CI infra's PyPI mirror. pip_local_mirror: true pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple" diff --git a/playbooks/kayobe-seed-vm-base/overrides.yml.j2 b/playbooks/kayobe-seed-vm-base/overrides.yml.j2 index c7284ce5e..2413fcdf6 100644 --- a/playbooks/kayobe-seed-vm-base/overrides.yml.j2 +++ b/playbooks/kayobe-seed-vm-base/overrides.yml.j2 @@ -16,6 +16,9 @@ pip_upper_constraints_file: "/tmp/upper-constraints.txt" # QEMU. libvirt_vm_engine: "qemu" +# Force system clock synchronisation +ntp_force_sync: True + # Use the CI infra's PyPI mirror. pip_local_mirror: true pip_index_url: "http://{{ zuul_site_mirror_fqdn }}/pypi/simple"