infra-prod: save run logs even if being published

If infra_prod_playbook_collect_log is set, then we copy and publish
the playbook log in the job results.

Currently we skip renaming the log file on bridge in this case,
meaning that we don't keep logs of old runs on bridge.  Also, there is
a bug in the bit that resets the timestamp on the logfile (so it is
timestamped by the time it started, no ended) that it isn't checking
this flag, so we end up with a bunch of zero-length files in this
case.

I guess the thinking here was that since the log is published, there's
no need to keep it on bridge as well.

The abstract case here is really only instantiated for
manage-projects, which is the only job we publish the log for.  Today
we wanted an older log, but it had already been purged from object
storage.

It seems worth keeping this on-disk as well as publishing it.  Remove
the checks around the rename/cleanup.  This will also fix the bug of
zero-sized files being created, because the renamed file will be there
now.

Change-Id: Ic5ab52797fef880ae3ec3d92c071ef802e63b778
This commit is contained in:
Ian Wienand 2023-01-12 15:50:48 +11:00
parent 9344d8c046
commit 00f6d27561
No known key found for this signature in database

View File

@ -85,7 +85,6 @@
_log_timestamp: '{{ _log_timestamp.stdout | trim }}' _log_timestamp: '{{ _log_timestamp.stdout | trim }}'
- name: Rename playbook log on bridge - name: Rename playbook log on bridge
when: not infra_prod_playbook_collect_log
become: yes become: yes
copy: copy:
remote_src: yes remote_src: yes
@ -105,7 +104,6 @@
become: yes become: yes
- name: Cleanup old playbook logs on bridge - name: Cleanup old playbook logs on bridge
when: not infra_prod_playbook_collect_log
become: yes become: yes
shell: | shell: |
find /var/log/ansible -name '{{ playbook_name }}.log.*' -type f -mtime +30 -delete find /var/log/ansible -name '{{ playbook_name }}.log.*' -type f -mtime +30 -delete