Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
# defaults file for tools_get_openshift_release
openshift_releasestream_url: "https://openshift-release.apps.ci.l2s4.p1.openshiftapps.com/api/v1/releasestream"
release_name: "{{ openshift_release_build_name | default('') }}"
openshift_download_url: "{{ 'https://openshift-release-artifacts.apps.ci.l2s4.p1.openshiftapps.com' + '/' + release_name }}"
openshift_mirror_url: "https://mirror.openshift.com/pub/openshift-v4/x86_64/clients/ocp"
ocp_build_info_file: "{{ controller_home_dir }}/latest_build.json"
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
---
# Extract OCP installer and/or client binaries directly from the release image
# using `oc adm release extract --tools` instead of the release-controller's
# file-cache (openshift-release-artifacts), which has no SLA and can get stuck
# indefinitely during tool extraction.
- name: Get the OCP installer and/or client binaries
vars:
installer_url: "{{ openshift_download_url }}/openshift-install-linux-{{ release_name }}.tar.gz"
client_url: "{{ openshift_download_url }}/openshift-client-linux-{{ release_name }}.tar.gz"
installer_tarball: "openshift-install-linux-{{ release_name }}.tar.gz"
client_tarball: "openshift-client-linux-{{ release_name }}.tar.gz"
pull_secret_file: "{{ home_dir }}/pull-secret.json"
block:
- name: Fail if release_name var is not defined
ansible.builtin.fail:
msg: "'release_name' variable must be defined and cannot be empty"
when: release_name == ''

- name: Wait for content to come up on {{ openshift_download_url }}
ansible.builtin.uri:
url: "{{ openshift_download_url }}"
method: GET
return_content: yes
status_code: 200
body_format: json
register: result
until: result.content.find("openshift-install-linux") != -1
retries: 20
delay: 60
- name: Fail if openshift_release_pull_spec is not defined
ansible.builtin.fail:
msg: "'openshift_release_pull_spec' must be set by get_openshift_release_build_name.yml"
when: openshift_release_pull_spec is not defined or openshift_release_pull_spec == ''

- name: Extract pull secret from host cluster
ansible.builtin.shell: >-

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pipeline is missing set -o pipefail - if oc get secret fails, base64 -d still exits 0 and creates an empty file, then oc adm release extract fails later with a confusing auth error. The same role's get_openshift_release_build_name.yml:68 already uses pipefail.

Also worth adding no_log: true here since it handles the decoded pull secret - same pattern as tools_install_custom_mce_catalog/tasks/main.yml.

@tusharjadhav3302 tusharjadhav3302 Jun 18, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both addressed:

Added set -o pipefail && at the start of the pipeline so a failure in oc get secret properly propagates instead of being masked by base64 -d.
Added no_log: true to suppress the decoded pull secret from appearing in logs, consistent with tools_install_custom_mce_catalog/tasks/main.yml

set -o pipefail &&
oc get secret pull-secret -n openshift-config
--kubeconfig={{ rhoso_kubeconfig }}
-o jsonpath='{.data.\.dockerconfigjson}'
| base64 -d > {{ pull_secret_file }}
changed_when: true
no_log: true

- name: Create the installer directory
ansible.builtin.file:
path: "{{ home_dir }}/{{ release_name }}"
state: directory
mode: u=rwx,g=rw,o=r

- name: Extract OCP tools from release image {{ openshift_release_pull_spec }}
ansible.builtin.command:
cmd: >-
oc adm release extract
--tools
--registry-config={{ pull_secret_file }}
--to={{ home_dir }}/{{ release_name }}
{{ openshift_release_pull_spec }}
register: extract_result
until: extract_result is not failed
retries: 3
delay: 30

- name: Get the installer binary and create a symlink
when: "'installer' in binaries"
block:
- name: Download and unarchive the installer from {{ installer_url }}
- name: Unarchive the installer from {{ installer_tarball }}
ansible.builtin.unarchive:
src: "{{ installer_url }}"
src: "{{ home_dir }}/{{ release_name }}/{{ installer_tarball }}"
dest: "{{ home_dir }}/{{ release_name }}"
remote_src: yes
register: result
until: result is not failed
retries: 3
delay: 10

- name: Create a symlink to the openshift-install binary from /usr/local/bin
ansible.builtin.file:
Expand All @@ -47,18 +64,14 @@
state: link
become: true

- name: Get the installer binary and create symlinks
- name: Get the client binary and create symlinks
when: "'client' in binaries"
block:
- name: Download and unarchive the client from {{ client_url }}
- name: Unarchive the client from {{ client_tarball }}
ansible.builtin.unarchive:
src: "{{ client_url }}"
src: "{{ home_dir }}/{{ release_name }}/{{ client_tarball }}"
dest: "{{ home_dir }}/{{ release_name }}"
remote_src: yes
register: result
until: result is not failed
retries: 3
delay: 10

- name: Create a symlink to the oc binary from /usr/local/bin
ansible.builtin.file:
Expand All @@ -73,3 +86,9 @@
dest: /usr/bin/kubectl
state: link
become: true

always:
- name: Remove pull secret file
ansible.builtin.file:
path: "{{ pull_secret_file }}"
state: absent
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,25 @@
ansible.builtin.set_fact:
openshift_release_build_name: "{{ latest_build_info.name }}"

- name: Set openshift_release_build_name when a specific build is given
ansible.builtin.set_fact:
openshift_release_build_name: "{{ build_name }}"
- name: Set openshift_release_pull_spec from release stream API response
ansible.builtin.set_fact:
openshift_release_pull_spec: "{{ latest_build_info.pullSpec }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set_fact is inside the when: build_name == '' block, so it only fires for nightly and 4-stable. The channel path (candidate/fast/stable/eus, lines 55-74) and the specific-build path (lines 46-51) don't set openshift_release_pull_spec, which means get_openshift_release_binaries.yml would fail for every job using openshift_build_name: "candidate" - that's 6 of 13 job definitions.

For channel builds, release.txt already has a Pull From: field (quay.io/openshift-release-dev/ocp-release@sha256:...) that could be parsed here. For specific builds, a fallback constructing the pull spec from openshift_release_build_name would cover the rest.

@tusharjadhav3302 tusharjadhav3302 Jun 18, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes , this was indeed a gap. Fixed in the latest push:

Channel builds (candidate/fast/stable/eus): The release.txt file already has a Pull From: field with a digest-pinned pull spec (e.g. quay.io/openshift-release-dev/ocp-release@sha256:...). Added a task to parse it with grep '^Pull From:' | awk '{print $3}' and set openshift_release_pull_spec from it.

Specific builds: Wrapped the existing set_fact in a block and added pull spec construction — nightly builds use registry.ci.openshift.org/ocp/release:<build_name>, GA builds use quay.io/openshift-release-dev/ocp-release:<build_name>-x86_64.

All three code paths now set openshift_release_pull_spec before get_openshift_release_binaries.yml runs.


- name: Set build name and pull spec when a specific build is given
when:
- release is not match("4-stable")
- build_name not in ['','candidate','fast','stable','eus']
block:
- name: Set openshift_release_build_name for specific build
ansible.builtin.set_fact:
openshift_release_build_name: "{{ build_name }}"

- name: Construct openshift_release_pull_spec for specific build
ansible.builtin.set_fact:
openshift_release_pull_spec: >-
{{ 'registry.ci.openshift.org/ocp/release:' + build_name
if build_name is search('nightly')
else 'quay.io/openshift-release-dev/ocp-release:' + build_name + '-x86_64' }}

- name: Discover the release build name for the z-stream promoted to upgrade channel on {{ release }}
# Ref: https://docs.openshift.com/container-platform/4.9/updating/understanding-upgrade-channels-release.html
Expand All @@ -68,3 +81,12 @@
- name: Set openshift_release_build_name when openshift.build is set to a channel
ansible.builtin.set_fact:
openshift_release_build_name: "{{ result.stdout }}"

- name: Parse openshift_release_pull_spec from Pull From field in release.txt
ansible.builtin.shell: set -o pipefail && grep '^Pull From:' {{ home_dir }}/release.txt | awk '{print $3}'
changed_when: false
register: pull_from_result

- name: Set openshift_release_pull_spec from channel release.txt
ansible.builtin.set_fact:
openshift_release_pull_spec: "{{ pull_from_result.stdout }}"