From 589521fd181658b1f5d3f1fb60a7e8579071956d Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 2 Apr 2020 10:16:47 -0500 Subject: [PATCH] Remove run_all.sh and ansible cron job Remove the script and the cronjob on bridge that runs it. Change-Id: I45e4d9713f3ba4760ba384d13487c6214d068800 --- playbooks/roles/ansible-cron/tasks/main.yaml | 17 +--- .../templates/clouds/bridge_clouds.yaml.j2 | 2 +- run_all.sh | 78 ------------------- testinfra/test_base.py | 3 - testinfra/test_bridge.py | 6 -- 5 files changed, 2 insertions(+), 104 deletions(-) delete mode 100755 run_all.sh diff --git a/playbooks/roles/ansible-cron/tasks/main.yaml b/playbooks/roles/ansible-cron/tasks/main.yaml index 7cddd9f547..8be8c98ebd 100644 --- a/playbooks/roles/ansible-cron/tasks/main.yaml +++ b/playbooks/roles/ansible-cron/tasks/main.yaml @@ -12,19 +12,4 @@ - name: Set up cron job for running run_all.sh 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' - minute: "{{ update_cron_interval.minute }}" - hour: "{{ update_cron_interval.hour }}" - day: "{{ update_cron_interval.day }}" - month: "{{ update_cron_interval.month }}" - weekday: "{{ update_cron_interval.weekday }}" - -- name: Setup log rotation - include_role: - name: logrotate - vars: - logrotate_file_name: /var/log/ansible/run_all_cron.log + state: absent diff --git a/playbooks/templates/clouds/bridge_clouds.yaml.j2 b/playbooks/templates/clouds/bridge_clouds.yaml.j2 index a020787e07..db430c523b 100644 --- a/playbooks/templates/clouds/bridge_clouds.yaml.j2 +++ b/playbooks/templates/clouds/bridge_clouds.yaml.j2 @@ -10,7 +10,7 @@ # the test-node tenants have hundreds of ephemeral nodes, whose # cache-evading behaviour would make enumerating their projects # unnecessarily slow when building an inventory for our default -# control-plane cron runs (run_all.sh). +# control-plane cron runs. # ansible: diff --git a/run_all.sh b/run_all.sh deleted file mode 100755 index 7004a4d3ff..0000000000 --- a/run_all.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -# Copyright 2014 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# If updating the puppet system-config repo or installing puppet modules -# fails then abort the puppet run as we will not get the results we -# expect. -set -e - -SYSTEM_CONFIG=/opt/system-config -ANSIBLE_PLAYBOOKS=$SYSTEM_CONFIG/playbooks - -# We only send stats if running under cron -UNDER_CRON=0 - -while getopts ":c" arg; do - case $arg in - c) - UNDER_CRON=1 - ;; - esac -done - -GLOBAL_START_TIME=$(date '+%s') - -# Send a timer stat to statsd -# send_timer metric [start_time] -# * uses timer metric bridge.ansible.run_all.<$1> -# * time will be taken from last call of start_timer, or $2 if set -function send_timer { - # Only send stats under cron conditions - if [[ ${UNDER_CRON} != 1 ]]; then - return - fi - - local current - current=$(date '+%s') - local name - name=$1 - local start - start=${2-$_START_TIME} - local elapsed_ms - elapsed_ms=$(( (current - start) * 1000 )) - - echo "bridge.ansible.run_all.${name}:${elapsed_ms}|ms" | nc -w 1 -u graphite.opendev.org 8125 - echo "End $name" -} -# See send_timer -function start_timer { - _START_TIME=$(date '+%s') -} - -echo "--- begin run @ $(date -Is) ---" - -# It's possible for connectivity to a server or manifest application to break -# for indeterminate periods of time, so the playbooks should be run without -# errexit -set +e - -# DO NOTHING!!! - -# Send the combined time for everything -send_timer total $GLOBAL_START_TIME - -echo "--- end run @ $(date -Is) ---" -echo diff --git a/testinfra/test_base.py b/testinfra/test_base.py index 1a99e6c345..3a86f0d826 100644 --- a/testinfra/test_base.py +++ b/testinfra/test_base.py @@ -158,9 +158,6 @@ def test_logrotate(host): cfg_file = host.file("/etc/logrotate.d/ansible.log.37237.conf") assert cfg_file.exists assert cfg_file.contains('/var/log/ansible/ansible.log') - cfg_file = host.file("/etc/logrotate.d/run_all_cron.log.1a953.conf") - assert cfg_file.exists - assert cfg_file.contains('/var/log/ansible/run_all_cron.log') def test_no_recommends(host): diff --git a/testinfra/test_bridge.py b/testinfra/test_bridge.py index 0a8d4c7484..b36a6247bd 100644 --- a/testinfra/test_bridge.py +++ b/testinfra/test_bridge.py @@ -45,12 +45,6 @@ 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')