Merge "Disable cloud launcher cron job during CI"

This commit is contained in:
Zuul 2019-07-18 20:47:14 +00:00 committed by Gerrit Code Review
commit 1ee1e73c48
9 changed files with 29 additions and 4 deletions

View File

@ -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.

View File

@ -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

View File

@ -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:

View File

@ -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.

View File

@ -4,3 +4,4 @@ cloud_launcher_cron_interval:
day: '*'
month: '*'
weekday: '*'
cloud_launcher_disable_job: false

View File

@ -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 }}"

View File

@ -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

View File

@ -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

View File

@ -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')