zuul-jobs/roles/test-upload-logs-swift/tasks/main.yaml
Felix Edel 2f8439148a
Return upload_results in test-upload-logs-swift role
This will only change the test role and can be used for validation.

We are facing some issues where the log upload to swift fails, but the
role is always succeeding. To get some more information about the
upload failures, we let the upload() method return those to the Ansible
module and provide them in the module's JSON result.

Change-Id: Ic54b877cd5ea58031e21e514eb3a7c50ea735795
2020-06-15 08:19:11 +02:00

44 lines
1.5 KiB
YAML

- name: Set zuul-log-path fact
include_role:
name: set-zuul-log-path-fact
when: zuul_log_path is not defined
# Always upload (true), never upload (false) or only on failure ('failure')
- when: zuul_site_upload_logs | default(true) | bool or
(zuul_site_upload_logs == 'failure' and not zuul_success | bool)
block:
# Use chmod instead of file because ansible 2.5 file with recurse and
# follow can't really handle symlinks to .
- name: Ensure logs are readable before uploading
delegate_to: localhost
command: "chmod -R u=rwX,g=rX,o=rX {{ zuul.executor.log_root }}/"
# ANSIBLE0007 chmod used in place of argument mode to file
tags:
- skip_ansible_lint
- name: Upload logs to swift
delegate_to: localhost
zuul_swift_upload:
cloud: "{{ zuul_log_cloud_config }}"
partition: "{{ zuul_log_partition }}"
container: "{{ zuul_log_container }}"
public: "{{ zuul_log_container_public }}"
prefix: "{{ zuul_log_path }}"
indexes: "{{ zuul_log_create_indexes }}"
files:
- "{{ zuul.executor.log_root }}/"
delete_after: "{{ zuul_log_delete_after | default(omit) }}"
register: upload_results
- block:
- name: Return log URL to Zuul
delegate_to: localhost
zuul_return:
data:
zuul:
log_url: "{{ upload_results.url }}/"
- name: Print upload failures
debug:
var: upload_results.upload_failures
when: upload_results is defined