Skip to content

Commit

Permalink
Merge pull request #455 from redhat-openshift-ecosystem/ISV-4161
Browse files Browse the repository at this point in the history
[ISV-4161] Ensure target bundle exists before upgrading
  • Loading branch information
mporrato authored and mvaras committed Aug 3, 2024
2 parents 946ff3f + a6fdc00 commit f1c8670
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
41 changes: 39 additions & 2 deletions upstream/roles/build_app_registry/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,45 @@

- name: "Building and pushing app registry"
block:
- name: "Build app registry image '{{ app_registry_image }}' using '{{ app_registry_build_file }}'"
shell: "{{ container_tool }} build --no-cache -t {{ app_registry_image }} -f {{ app_registry_build_dir }}/{{ app_registry_build_file }} {{ bundle_export_dir_app_registry | dirname }}"
- name: "Build app registry image '{{ app_registry_image }}' using '{{ app_registry_build_file }}' (!)"
shell: |
podman info
sudo df -h
podman system reset -f
sudo mkdir -p /mnt/storage /mnt/rundir /mnt/tmp
sudo chown "$(id -u):$(id -g)" /mnt/storage /mnt/rundir
sudo chmod 1777 /mnt/tmp
sudo chmod 1777 /mnt/rundir
sudo chmod 1777 /mnt/storage
export TMPDIR=/mnt/tmp
cat <<__EOF__ >/usr/share/containers/storage.conf
[storage]
graphroot = "/mnt/storage"
driver = "overlay"
runroot = "/mnt/rundir"
[storage.options]
pull_options = {enable_partial_images = "true", use_hard_links = "true", ostree_repos=""}
[storage.options.overlay]
mountopt = "nodev"
__EOF__
cat <<__EOF__ | sudo tee /etc/containers/containers.conf
[engine]
env = ["TMPDIR=/mnt/tmp"]
__EOF__
cat /usr/share/containers/storage.conf
ls /tmp/community-operators-for-catalog/upstream.Dockerfile
ls /tmp/operator-test/app_registry
set +e
"{{ container_tool }} build --log-level=debug -t {{ app_registry_image }} -f {{ app_registry_build_dir }}/{{ app_registry_build_file }} {{ bundle_export_dir_app_registry | dirname }}"
result=$?
podman info
sudo df -h
exit $result
- name: "Push app registry image '{{ app_registry_image }}'"
shell: "{{ container_tool }} push {{ container_push_extra }} {{ app_registry_image }}"
Expand Down
12 changes: 12 additions & 0 deletions upstream/roles/test_operator_update/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
set_fact:
tou_operator_bundle_for_install: "{{ production_registry_namespace }}/{{ operator_package_name }}:v{{ tou_upgrade_from }}"
tou_operator_bundle_for_upgrade: "{{ tou_local_registry_namespace }}/{{ operator_package_name }}:v{{ tou_upgrade_to }}"
tou_operator_bundle_for_upgrade_external: "{{ production_registry_namespace }}/{{ operator_package_name }}:v{{ tou_upgrade_to }}"
when:
- cluster_type is defined
- cluster_type == "k8s"
Expand All @@ -60,6 +61,7 @@
set_fact:
tou_operator_bundle_for_install: "{{ external_production_registry_namespace }}/{{ operator_package_name }}:v{{ tou_upgrade_from }}"
tou_operator_bundle_for_upgrade: "quay.io/{{ test_quay_namespace }}/{{ operator_package_name }}:{{ commit_tag }}"
tou_operator_bundle_for_upgrade_external: "{{ external_production_registry_namespace }}/{{ operator_package_name }}:v{{ tou_upgrade_to }}"
when: (cluster_type is not defined) or (cluster_type != "k8s")

- name: "Check if OLM is needed"
Expand Down Expand Up @@ -89,6 +91,16 @@
- name: "Create namespace for upgrade tests"
shell: "{{ oc_bin_path }} create ns {{ tou_namespace_for_upgrades }}"

- name: "Check if {{ tou_operator_bundle_for_upgrade }} exists"
shell: "skopeo inspect docker://{{ tou_operator_bundle_for_upgrade }}"
register: inspect_bundle_for_upgrade
ignore_errors: true

- name: "Import {{ tou_operator_bundle_for_upgrade }}"
shell: "skopeo copy docker://{{ tou_operator_bundle_for_upgrade_external }} docker://{{ tou_operator_bundle_for_upgrade }}"
when:
- inspect_bundle_for_upgrade is failed

- name: "Installing {{ tou_operator_bundle_for_install }} with {{ sdk_version_for_upgrade.stdout }}"
shell: "{{ operator_sdk_bin_path }} run bundle {{ tou_operator_bundle_for_install }} -n {{ tou_namespace_for_upgrades }} --skip-tls-verify"
register: tou_n_1_rc
Expand Down

0 comments on commit f1c8670

Please sign in to comment.