-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stf-run-ci: get operator info from CSV instead of image metadata #643
Changes from 1 commit
d706ed2
4f8ff58
81668dd
ac1cbfd
ed12f4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -13,35 +13,60 @@ | |||||||||||||||||||||||||||||||||||||
sto_bundle_info: "{{ generate_bundle_sto.stdout_lines[-1] | from_json }}" | ||||||||||||||||||||||||||||||||||||||
sgo_bundle_info: "{{ generate_bundle_sgo.stdout_lines[-1] | from_json }}" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Generate default package names if not present | ||||||||||||||||||||||||||||||||||||||
when: sto_bundle_info is defined and sto_bundle_info.package_name is not defined | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.set_fact: | ||||||||||||||||||||||||||||||||||||||
sto_bundle_info: "{{ sto_bundle_info | combine({'package_name':'service-telemetry-operator.v%s'|format(sto_bundle_info.operator_bundle_version)}) }}" | ||||||||||||||||||||||||||||||||||||||
sgo_bundle_info: "{{ sgo_bundle_info | combine({'package_name':'smart-gateway-operator.v%s'|format(sto_bundle_info.operator_bundle_version)}) }}" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Create info variables from provided pre-built bundles (deploy from bundles) | ||||||||||||||||||||||||||||||||||||||
when: __deploy_from_bundles_enabled | bool and not __local_build_enabled | bool | ||||||||||||||||||||||||||||||||||||||
block: | ||||||||||||||||||||||||||||||||||||||
- name: Get STO operator bundle info | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.command: oc image info {{ __service_telemetry_bundle_image_path }} | ||||||||||||||||||||||||||||||||||||||
register: sto_prebuilt_image_info | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Get SGO operator bundle info | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.command: oc image info {{ __smart_gateway_bundle_image_path }} | ||||||||||||||||||||||||||||||||||||||
register: sgo_prebuilt_image_info | ||||||||||||||||||||||||||||||||||||||
- name: Get STO operator bundle CSV file | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.command: oc image extract {{ __service_telemetry_bundle_image_path }} --file /manifests/*clusterserviceversion.yaml | ||||||||||||||||||||||||||||||||||||||
args: | ||||||||||||||||||||||||||||||||||||||
chdir: "{{ base_dir }}/working/service-telemetry-framework-index/" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Get SGO operator bundle CSV file | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.command: oc image extract {{ __smart_gateway_bundle_image_path }} --file /manifests/*clusterserviceversion.yaml | ||||||||||||||||||||||||||||||||||||||
args: | ||||||||||||||||||||||||||||||||||||||
chdir: "{{ base_dir }}/working/service-telemetry-framework-index/" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add in a fetch between the You will have a different dir on the executor, which is accessible through the For the fetch module, the src is the target node for this play, the dest is on the ansible controller
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to update the filenames in the next two tasks to use this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for explaining! Reading Ansible docs along with your hints has led me to the slurp module, which might work even better here: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/slurp_module.html We're ultimately shoving the file contents into a variable anyway, so if this works it would save us from the zuul vs not divergence and having to keep track of where the file is. I'm giving it a try, if it doesn't work then I'll go with the way you suggested. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize now you already pushed a fix so I'll leave it as is. Thank you. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You made a good point with the zuul vs not divergence. I don't particularly like having to account for zuul in this, since it starts looking complicated. With the slurp module, you need to do something like:
I can provide some playbook for testing that, if you want to play with it for learning. |
||||||||||||||||||||||||||||||||||||||
- name: Read STO bundle CSV file contents | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.include_vars: | ||||||||||||||||||||||||||||||||||||||
file: "{{ base_dir }}/working/service-telemetry-framework-index/service-telemetry-operator.clusterserviceversion.yaml" | ||||||||||||||||||||||||||||||||||||||
compi-migui marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
name: sto_prebuilt_bundle_csv | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Read SGO bundle CSV file contents | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.include_vars: | ||||||||||||||||||||||||||||||||||||||
file: "{{ base_dir }}/working/service-telemetry-framework-index/smart-gateway-operator.clusterserviceversion.yaml" | ||||||||||||||||||||||||||||||||||||||
compi-migui marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||
name: sgo_prebuilt_bundle_csv | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Get STO and SGO bundle package names (from CSV) | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.set_fact: | ||||||||||||||||||||||||||||||||||||||
sto_prebuilt_bundle_package_name: "{{ sto_prebuilt_bundle_csv.metadata.name }}" | ||||||||||||||||||||||||||||||||||||||
sgo_prebuilt_bundle_package_name: "{{ sgo_prebuilt_bundle_csv.metadata.name }}" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Get STO and SGO bundle versions (from metadata) | ||||||||||||||||||||||||||||||||||||||
- name: Get STO and SGO bundle versions (from CSV) | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.set_fact: | ||||||||||||||||||||||||||||||||||||||
sto_prebuilt_bundle_version: "{{ sto_prebuilt_image_info.stdout_lines[-1] | split('=') | last }}" | ||||||||||||||||||||||||||||||||||||||
sgo_prebuilt_bundle_version: "{{ sgo_prebuilt_image_info.stdout_lines[-1] | split('=') | last }}" | ||||||||||||||||||||||||||||||||||||||
sto_prebuilt_bundle_version: "{{ sto_prebuilt_bundle_csv.spec.version }}" | ||||||||||||||||||||||||||||||||||||||
sgo_prebuilt_bundle_version: "{{ sgo_prebuilt_bundle_csv.spec.version }}" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Get STO and SGO bundle tags (from name) | ||||||||||||||||||||||||||||||||||||||
- name: Get STO and SGO bundle image tags (from name) | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.set_fact: | ||||||||||||||||||||||||||||||||||||||
sto_prebuilt_bundle_tag: "{{ __service_telemetry_bundle_image_path | split(':') | last }}" | ||||||||||||||||||||||||||||||||||||||
sgo_prebuilt_bundle_tag: "{{ __smart_gateway_bundle_image_path | split(':') | last }}" | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
- name: Set info variables from provided pre-built bundles | ||||||||||||||||||||||||||||||||||||||
ansible.builtin.set_fact: | ||||||||||||||||||||||||||||||||||||||
sto_bundle_info: | ||||||||||||||||||||||||||||||||||||||
'package_name': "{{ sto_prebuilt_bundle_package_name }}" | ||||||||||||||||||||||||||||||||||||||
'bundle_default_channel': "{{ stf_channel }}" | ||||||||||||||||||||||||||||||||||||||
'bundle_channels': "{{ stf_channel }}" | ||||||||||||||||||||||||||||||||||||||
'operator_bundle_version': "{{ sto_prebuilt_bundle_version }}" | ||||||||||||||||||||||||||||||||||||||
'operator_bundle_tag': "{{ sto_prebuilt_bundle_tag }}" | ||||||||||||||||||||||||||||||||||||||
sgo_bundle_info: | ||||||||||||||||||||||||||||||||||||||
'package_name': "{{ sgo_prebuilt_bundle_package_name }}" | ||||||||||||||||||||||||||||||||||||||
'bundle_default_channel': "{{ stf_channel }}" | ||||||||||||||||||||||||||||||||||||||
'bundle_channels': "{{ stf_channel }}" | ||||||||||||||||||||||||||||||||||||||
'operator_bundle_version': "{{ sgo_prebuilt_bundle_version }}" | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this step inside the "Create info variables from provided pre-built bundles (deploy from bundles)" group of steps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's the opposite problem: the "deploy from bundles" group gets the package_name from the CSV, so this shouldn't run in that case at all. Changing the
when:
to__local_build_enabled | bool and not __deploy_from_bundles_enabled | bool
so it only runs for local builds