Skip to content

Commit 11767d3

Browse files
committed
mirror_ocp_release: fixes for concurrent jobs
1 parent bc73091 commit 11767d3

File tree

4 files changed

+33
-32
lines changed

4 files changed

+33
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: Remove temporary directory
2+
ansible.builtin.file:
3+
path: "{{ _mor_tmp.path }}"
4+
state: absent

roles/mirror_ocp_release/tasks/artifacts.yml

+17-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@
1111
when:
1212
- mor_force or not _mor_target.stat.exists
1313
block:
14-
- name: "Extract installer and metadata from release image"
15-
ansible.builtin.shell: >
16-
flock -x {{ mor_cache_dir }}/{{ mor_version }}/release_extract.lock -c '
17-
set -e;
14+
- name: "Extract metadata from release image"
15+
ansible.builtin.command: >
1816
{{ mor_oc }} adm release extract
1917
--registry-config {{ mor_auths_file }}
2018
--command={{ mor_installer }}
2119
--from {{ mor_pull_url }}
22-
--to "{{ mor_cache_dir }}/{{ mor_version }}";
20+
--to "{{ _mor_tmp.path }}";
21+
register: _mor_extract_res
22+
retries: 9
23+
delay: 10
24+
until: _mor_extract_res is not failed
25+
changed_when: false
26+
27+
- name: "Extract installer from release image"
28+
ansible.builtin.command: >
2329
{{ mor_oc }} adm release extract
2430
--registry-config {{ mor_auths_file }}
2531
--tools
2632
--from {{ mor_pull_url }}
27-
--to "{{ mor_cache_dir }}/{{ mor_version }}"'
33+
--to "{{ _mor_tmp.path }}"
2834
register: _mor_extract_res
2935
retries: 9
3036
delay: 10
@@ -34,11 +40,9 @@
3440
- name: "Extract rhcos.json if version >= 4.8"
3541
when:
3642
- mor_version is version("4.8", ">=")
37-
ansible.builtin.shell: >
38-
flock -x "{{ mor_cache_dir }}/{{ mor_version }}/release_extract.lock" -c '{
39-
"{{ mor_cache_dir }}/{{ mor_version }}/{{ mor_installer }}" coreos print-stream-json >
40-
"{{ mor_cache_dir }}/{{ mor_version }}/rhcos.json";
41-
}'
43+
ansible.builtin.command: >
44+
"{{ _mor_tmp.path }}/{{ mor_installer }}" coreos print-stream-json >
45+
"{{ _mor_tmp.path }}/rhcos.json";
4246
4347
- name: "Download rhcos.json (< 4.8)"
4448
when:
@@ -47,7 +51,7 @@
4751
- name: "Get Git SHA from installer"
4852
ansible.builtin.shell: >
4953
set -e -o pipefail;
50-
{{ mor_cache_dir }}/{{ mor_version }}/openshift-baremetal-install version |
54+
{{ _mor_tmp.path }}/openshift-baremetal-install version |
5155
grep "^built from" |
5256
awk '{ print $NF }'
5357
register: _mor_commit_id
@@ -57,7 +61,7 @@
5761
ansible.builtin.include_tasks: fetch.yml
5862
vars:
5963
mor_uri: "https://raw.githubusercontent.com/openshift/installer/{{ _mor_commit_id.stdout }}/data/data/rhcos.json"
60-
mor_dir: "{{ mor_cache_dir }}/{{ mor_version }}"
64+
mor_dir: "{{ _mor_tmp.path }}"
6165

6266
- name: "Figure out status of SELinux"
6367
ansible.builtin.command: /usr/sbin/selinuxenabled
-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
---
2-
- name: "Check if target file exists"
3-
ansible.builtin.stat:
4-
path: "{{ mor_dir }}/{{ mor_uri | basename }}"
5-
get_checksum: false
6-
register: target
7-
when:
8-
- not mor_force
9-
102
- name: "Fetch file from URL"
113
ansible.builtin.get_url:
124
url: "{{ mor_uri }}"
@@ -24,15 +16,4 @@
2416
until: downloaded is not failed
2517
when:
2618
- mor_force or not target.stat.exists
27-
28-
- name: "Figure out status of SELinux"
29-
ansible.builtin.command: /usr/sbin/selinuxenabled
30-
ignore_errors: true
31-
register: _mor_selinux
32-
changed_when: false
33-
34-
- name: "Apply new SELinux file context to file"
35-
ansible.builtin.command: /usr/sbin/restorecon -R "{{ mor_dir }}/{{ mor_uri | basename }}"
36-
become: true
37-
when: _mor_selinux.rc == 0
3819
...

roles/mirror_ocp_release/tasks/main.yml

+12
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
ansible.builtin.debug:
5151
var: mor_version
5252

53+
- name: Create temporary working directory
54+
ansible.builtin.tempfile:
55+
state: directory
56+
prefix: mor-
57+
register: _mor_tmp
58+
notify: "Remove temporary directory"
59+
5360
- name: "Set list of OS images to mirror"
5461
ansible.builtin.include_tasks: image-list.yml
5562
when:
@@ -78,4 +85,9 @@
7885
ansible.builtin.include_tasks: registry.yml
7986
when:
8087
- mor_mirror_container_images | bool
88+
89+
- name: Copy artifacts to release directory
90+
ansible.builtin.copy:
91+
src: "{{ _mor_tmp.path }}/"
92+
dest: "{{ mor_cache_dir }}/{{ mor_version }}"
8193
...

0 commit comments

Comments
 (0)