promote-docker-image: improve failure debugability
Currently this no_logs the entire selection and delete loop, which is probably maximal efficiency but makes it very hard to debug on failure (which we are seeing). This extracts the list creation and uri call so we can see the tags it is trying to delete. Change-Id: I93fd19aedaa9fc328a1a347986a5f0c20439d476
This commit is contained in:
parent
1c85809ab1
commit
4340c8d473
12
roles/promote-docker-image/tasks/delete-tag.yaml
Normal file
12
roles/promote-docker-image/tasks/delete-tag.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
- name: Show the tag we are about to delete
|
||||||
|
debug:
|
||||||
|
var: zj_docker_tag
|
||||||
|
|
||||||
|
- name: Make delete call
|
||||||
|
no_log: true
|
||||||
|
uri:
|
||||||
|
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags/{{ zj_docker_tag.name }}/"
|
||||||
|
method: DELETE
|
||||||
|
status_code: [200, 204]
|
||||||
|
headers:
|
||||||
|
Authorization: "JWT {{ jwt_token.json.token }}"
|
@ -3,18 +3,24 @@
|
|||||||
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags?page_size=1000"
|
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags?page_size=1000"
|
||||||
status_code: 200
|
status_code: 200
|
||||||
register: tags
|
register: tags
|
||||||
- name: Delete all change tags older than the cutoff
|
|
||||||
no_log: true
|
- name: Create old tags list
|
||||||
|
set_fact:
|
||||||
|
_old_tags: []
|
||||||
|
|
||||||
|
- name: Build list of old tags
|
||||||
loop: "{{ tags.json.results }}"
|
loop: "{{ tags.json.results }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: zj_docker_tag
|
loop_var: zj_docker_tag
|
||||||
|
set_fact:
|
||||||
|
_old_tags: '{{ _old_tags.append(zj_docker_tag) }}'
|
||||||
when:
|
when:
|
||||||
- zj_docker_tag.name.startswith('change_') or zj_docker_tag.name.startswith(zuul.pipeline)
|
- zj_docker_tag.name.startswith('change_') or zj_docker_tag.name.startswith(zuul.pipeline)
|
||||||
# Was updated > 24 hours ago:
|
# Was updated > 24 hours ago:
|
||||||
- "((ansible_date_time.iso8601 | regex_replace('^(....-..-..)T(..:..:..).*Z', '\\\\1 \\\\2') | to_datetime) - (zj_docker_tag.last_updated | regex_replace('^(....-..-..)T(..:..:..).*Z', '\\\\1 \\\\2') | to_datetime)).seconds > 86400"
|
- "((ansible_date_time.iso8601 | regex_replace('^(....-..-..)T(..:..:..).*Z', '\\\\1 \\\\2') | to_datetime) - (zj_docker_tag.last_updated | regex_replace('^(....-..-..)T(..:..:..).*Z', '\\\\1 \\\\2') | to_datetime)).seconds > 86400"
|
||||||
uri:
|
|
||||||
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags/{{ zj_docker_tag.name }}/"
|
- name: Delete all change tags older than the cutoff
|
||||||
method: DELETE
|
loop: "{{ _old_tags }}"
|
||||||
status_code: [200, 204]
|
loop_control:
|
||||||
headers:
|
loop_var: zj_docker_tag
|
||||||
Authorization: "JWT {{ jwt_token.json.token }}"
|
include_tasks: delete-tag.yaml
|
||||||
|
Loading…
Reference in New Issue
Block a user