Disable cloud launcher cron job during CI
This takes a similar approach to the extant ansible_cron_install_cron variable to disable the cron job for the cloud launcher when running under CI. If you happen to have your CI jobs when the cron job decides to fire, you end up with a harmless but confusing failed run of the cloud launcher (that has tried to contact real clouds) in the ARA results. Use the "disbaled" flag to ensure the cron job doesn't run. Using "disabled" means we can still check that the job was installed via testinfra however. Convert ansible_cron_install_cron to a similar method using disable, document the variable in the README and add a test for the run_all.sh script in crontab too. Change-Id: If4911a5fa4116130c39b5a9717d610867ada7eb1
This commit is contained in:
parent
482abf3bf0
commit
82c6dec4fa
@ -19,3 +19,10 @@ bridge.o.o and all hosts.
|
||||
|
||||
.. zuul:rolevar:: weekday
|
||||
:default: *
|
||||
|
||||
.. zuul:rolevar:: ansible_cron_disable_job
|
||||
:default: false
|
||||
|
||||
Disabled installed cron job. This is only useful for CI jobs
|
||||
testing bridge.o.o so that the test host does not randomly run
|
||||
the script during CI tests that fall during the interval.
|
||||
|
@ -5,4 +5,4 @@ update_cron_interval:
|
||||
month: '*'
|
||||
weekday: '*'
|
||||
# Flag that can be set in tests to ensure cron is not run
|
||||
ansible_cron_install_cron: true
|
||||
ansible_cron_disable_job: false
|
||||
|
@ -13,6 +13,7 @@
|
||||
cron:
|
||||
name: run_all.sh
|
||||
state: present
|
||||
disabled: "{{ ansible_cron_disable_job }}"
|
||||
# Note /var/run is ephemeral; so after a reboot we need to
|
||||
# ensure the lockfile dir is there before we run...
|
||||
job: 'mkdir -p /var/run/ansible; flock -n /var/run/ansible/run_all.lock bash /opt/system-config/run_all.sh -c >> /var/log/ansible/run_all_cron.log 2>&1'
|
||||
@ -21,7 +22,6 @@
|
||||
day: "{{ update_cron_interval.day }}"
|
||||
month: "{{ update_cron_interval.month }}"
|
||||
weekday: "{{ update_cron_interval.weekday }}"
|
||||
when: ansible_cron_install_cron
|
||||
|
||||
- name: Setup log rotation
|
||||
include_role:
|
||||
|
@ -24,3 +24,10 @@ with.
|
||||
|
||||
.. zuul:rolevar:: weekday
|
||||
:default: *
|
||||
|
||||
.. zuul:rolevar:: cloud_launcher_disable_job
|
||||
:default: false
|
||||
|
||||
Prevent installation of cron job. This is only useful for CI
|
||||
jobs testing bridge.o.o so that the test host does not randomly
|
||||
run the script during CI tests that fall during the interval.
|
||||
|
@ -4,3 +4,4 @@ cloud_launcher_cron_interval:
|
||||
day: '*'
|
||||
month: '*'
|
||||
weekday: '*'
|
||||
cloud_launcher_disable_job: false
|
@ -7,6 +7,7 @@
|
||||
cron:
|
||||
name: run_cloud_launcher.sh
|
||||
state: present
|
||||
disabled: "{{ cloud_launcher_disable_job }}"
|
||||
job: '/usr/bin/flock -n /var/run/ansible/run_cloud_launcher.lock /bin/bash /opt/system-config/run_cloud_launcher.sh -c >> /var/log/ansible/run_cloud_launcher_cron.log 2>&1'
|
||||
minute: "{{ cloud_launcher_cron_interval.minute }}"
|
||||
hour: "{{ cloud_launcher_cron_interval.hour }}"
|
||||
|
@ -1,7 +1,8 @@
|
||||
- import_playbook: ../bridge.yaml
|
||||
vars:
|
||||
root_rsa_key: "{{ lookup('file', zuul.executor.work_root + '/' + zuul.build + '_id_rsa') }}"
|
||||
ansible_cron_install_cron: false
|
||||
ansible_cron_disable_job: true
|
||||
cloud_launcher_disable_job: true
|
||||
|
||||
- hosts: bridge.openstack.org
|
||||
become: true
|
||||
|
@ -65,4 +65,6 @@ clouds:
|
||||
openstackzuul_fortnebula_password: password
|
||||
openstackzuul_fortnebula_project_name: project
|
||||
gitea_kube_key: Z2l0ZWFfazhzX2tleQ==
|
||||
ansible_cron_install_cron: false
|
||||
|
||||
ansible_cron_disable_job: true
|
||||
cloud_launcher_disable_job: true
|
||||
|
@ -45,6 +45,12 @@ def test_openstacksdk_config(host):
|
||||
assert f.mode == 0o640
|
||||
|
||||
|
||||
def test_ansible_run_all_cron(host):
|
||||
with host.sudo():
|
||||
crontab = host.check_output('crontab -l')
|
||||
assert 'run_all.sh' in crontab
|
||||
|
||||
|
||||
def test_cloud_launcher_cron(host):
|
||||
with host.sudo():
|
||||
crontab = host.check_output('crontab -l')
|
||||
|
Loading…
Reference in New Issue
Block a user