Skip to content

Commit

Permalink
Merge pull request #887 from IBM/cartridges-test
Browse files Browse the repository at this point in the history
Cartridges test + various other fixes
  • Loading branch information
fketelaars authored Jan 27, 2025
2 parents 4add16a + f58da2e commit 76391e8
Show file tree
Hide file tree
Showing 29 changed files with 387 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@
when:
- _install_cartridges_result.rc!=0

- name: Wait for cartridges to finish installation
include_tasks: cp4d-wait-cartridges-ready.yml
- name: Run post-processing scripts
include_tasks: cp4d-install-cr-post-processing.yml
loop: "{{ _apply_cr_cartridges | default([]) }}"
loop_control:
loop_var: _current_cp4d_cartridge
when:
- _install_cartridges_result.rc==0

when: not cpd_dry_run
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@
- include_tasks: "cp4d-install-cr-{{ _current_cp4d_cartridge.olm_utils_name }}.yml"
when: _install_cr_script.stat.exists

- name: Run post-processing scripts
include_tasks: cp4d-install-cr-post-processing.yml
when:
- _install_cartridges_result.rc==0

when:
- (_current_cp4d_cartridge.separate_install | default(False) | bool)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@
- include_role:
name: cp4d-variables

# Set fact which is handled when testing install of all cartridges
- set_fact:
_cp4d_cartridges_installed_successfully: True

- set_fact:
_apply_olm_cartridges_list: >-
{{ _cartridges_to_install
| map(attribute='olm_utils_name')
| difference(_v_cp4d_control_plane_cartridges)
| list
| join(',')}}
- set_fact:
_apply_cr_cartridges: >-
{{ _cartridges_to_install |
selectattr('separate_install','undefined') |
union(_cartridges_to_install | selectattr('separate_install','defined') | selectattr('separate_install','!=',True)) }}
- set_fact:
_apply_cr_cartridges_list: >-
{{ _apply_cr_cartridges
| map(attribute='olm_utils_name')
| difference(_v_cp4d_control_plane_cartridges)
| list
| join(',')}}
- name: Create catalog sources for Cloud Pak for Data cartridges in project {{ _p_current_cp4d_cluster.project }}
include_role:
name: cp4d-catalog-source
vars:
_p_catsrc_scope: cartridges

- name: Create subscriptions for Cloud Pak for Data cartridges in project {{ _p_current_cp4d_cluster.project }}
include_role:
name: cp4d-subscriptions
vars:
_p_subscription_scope: cartridges

- name: Populate {{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-install-options.yml
lineinfile:
path: "{{ status_dir }}/cp4d/{{ _p_current_cp4d_cluster.project }}-install-options.yml"
Expand All @@ -25,43 +63,16 @@
var: _patch_db2u
when: not cpd_dry_run

# Set fact which is handled when testing install of all cartridges
- set_fact:
_cp4d_cartridges_installed_successfully: True

- set_fact:
_apply_cr_cartridges: >-
{{ _cartridges_to_install |
rejectattr('olm_utils_name','==','scheduler') |
rejectattr('olm_utils_name','==','cpd_platform') |
rejectattr('olm_utils_name','==','cpfs') |
selectattr('separate_install','undefined') |
union(_cartridges_to_install | selectattr('separate_install','defined') | selectattr('separate_install','!=',True)) }}
- include_tasks: cp4d-install-cartridges-olm-utils.yml
when: _apply_cr_cartridges_list != ''

- set_fact:
_apply_cr_cartridges_list: >-
{{ _apply_cr_cartridges |
map(attribute='olm_utils_name') |
join(',')}}
- include_tasks: cp4d-install-cartridges-olm-utils.yml
when: _apply_cr_cartridges != []
_apply_cr_cartridges_separate: >-
{{ _cartridges_to_install
| selectattr('separate_install','defined') | selectattr('separate_install','==',True) }}
- name: Install separate cartridges
include_tasks: cp4d-install-separate-cr.yml
loop: "{{ _cartridges_to_install | default([]) }}"
loop_control:
loop_var: _current_cp4d_cartridge

- name: Run post-processing scripts
include_tasks: cp4d-install-cr-post-processing.yml
loop: "{{ _cartridges_to_install | default([]) }}"
loop_control:
loop_var: _current_cp4d_cartridge

- name: Wait for cartridges to finish installation
include_tasks: cp4d-wait-cartridges-ready.yml
loop: "{{ _cartridges_to_install | default([]) }}"
loop: "{{ _apply_cr_cartridges_separate | default([]) }}"
loop_control:
loop_var: _current_cp4d_cartridge
when: not cpd_dry_run
loop_var: _current_cp4d_cartridge

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
---
- name: Fail if destroy was not confirmed
fail:
msg: "Will not delete cartridge {{ _current_cartridge_cr.name }}. Destroy was not confirmed with --confirm-destroy parameter or global_config confirm_destroy property"
when:
- (_confirm_destroy | default(False) | bool) != True
- not cpd_dry_run

- name: Delete instances of {{ _current_cartridge_cr.name }}
- name: Delete instances of {{ _obsolete_cartridge.Component }}
include_tasks: cp4d-delete-cr-instances.yml

- name: Generate delete-cr command to delete cartridge {{ _obsolete_cartridge.Component }} from project {{ _p_current_cp4d_cluster.project }}
set_fact:
_delete_cr_command: "{{ lookup('template', 'delete-cr.j2') }}"

- include_role:
name: run-command
vars:
_p_command_description: Remove cartridge {{ _current_cartridge_cr.name }} in namespace {{ _p_current_cp4d_cluster.project }}
_p_command: "oc delete {{ _current_cartridge_cr.cr_cr }} --namespace {{ _p_current_cp4d_cluster.project }} --all"
_p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log"
_p_command_description: Remove cartridge {{ _obsolete_cartridge.Component }} in namespace {{ _p_current_cp4d_cluster.project }}
_p_command: "{{ _delete_cr_command }}"
_p_command_log_file: "{{ status_dir }}/log/{{ _p_current_cp4d_cluster.project }}-delete-cartridge.log"
_p_command_failed_when: False

- block:
- set_fact:
_delete_cartridge_result: "{{ _run_command_result }}"

- name: Fail if there was an error deleting the cartridge {{ _obsolete_cartridge.Component }} using delete-cr
fail:
msg: "{{ _delete_cartridge_result }}"
when:
- _delete_cartridge_result.rc!=0
- not (cpd_test_cartridges | default(False) | bool)

- set_fact:
_cp4d_cartridges_installed_successfully: False
when:
- _delete_cartridge_result.rc!=0
when: not cpd_dry_run
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
- include_role:
name: cp4d-variables

- name: Fail if there are cartridges to remove and destroy was not confirmed
fail:
msg: |
Will not delete cartridges. Destroy was not confirmed with --confirm-destroy parameter or global_config confirm_destroy property.
Cartridges that would be destroyed are: {{ _obsolete_cartridges_names }}
when:
- _obsolete_cartridges_names | length != 0
- (_confirm_destroy | default(False) | bool) != True
- not cpd_dry_run

- name: Remove obsolete cartridges from CP4D cluster {{ _p_current_cp4d_cluster.project }}
debug:
msg: "Remove obsolete cartridges from CP4D cluster {{ _p_current_cp4d_cluster.project }}"

- name: Check which obsolete cartridges are still installed
include_tasks: cp4d-check-remove-cr.yml
loop: "{{ _all_cartridges }}"
- include_tasks: cp4d-remove-cr.yml
loop: "{{ _obsolete_cartridges }}"
loop_control:
loop_var: _current_cartridge_cr
when:
- (_current_cartridge_cr.cr_cr | default('')) != ''
- not (_current_cartridge_cr.embedded | default(False) | bool)
- not (_current_cartridge_cr.cr_internal | default(False) | bool)
- not _current_cartridge_cr.name in ['cpfs','cp-foundation','cpd_platform','lite','scheduler']
loop_var: _obsolete_cartridge
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
delete-cr \
--cpd_instance_ns={{ _p_current_cp4d_cluster.project }} \
--components={{ _obsolete_cartridge.Component }}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
vars:
_p_command_description: Create catalog sources for {{ _p_catsrc_scope }}
_p_command: "{{ _apply_olm_command }}"
_p_command_log_file: "{{ status_dir }}/log/apply-olm-create-catsrc{{ _p_catsrc_scope }}.log"
_p_command_log_file: "{{ status_dir }}/log/apply-olm-create-catsrc-{{ _p_catsrc_scope }}.log"

- name: If not air-gapped, copy case files from /tmp/work/offline to {{ status_dir }}/cp4d/offline
copy:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
---
- set_fact:
_catsrc_cartridges_to_install_list: "{{ _cartridges_to_install_list }}"
_catsrc_cartridges_to_install_list: "{{ _apply_olm_cartridges_list }}"

- set_fact:
_catsrc_cartridges_to_install_list: "cpfs,cpd_platform"
when: _p_catsrc_scope == 'platform'

- include_tasks: create-catalog-source-olm-utils.yml

- include_tasks: wait-catalog-sources-ready.yml
when: not cpd_dry_run
when: _catsrc_cartridges_to_install_list != ''
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
debug:
var: _test_current_cp4d_cluster

- name: Login to the OpenShift cluster {{ _test_current_cp4d_cluster.openshift_cluster_name }}
include_role:
name: openshift-login
vars:
_p_openshift_cluster_name: "{{ _test_current_cp4d_cluster.openshift_cluster_name }}"

- name: CPD TEST CARTRIDGES - Remove obsolete cartridges
include_role:
name: cp4d-cartridge-remove
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@
vars:
_p_current_cp4d_cluster: "{{ current_cp4d_cluster }}"

- set_fact:
_cpd_accept_licenses: "False"

- set_fact:
_cpd_accept_licenses: "True"
when: (cpd_accept_licenses | default(False) | bool) or (current_cp4d_cluster.accept_licenses | default(False) | bool)

- debug:
var: _cpd_accept_licenses

- name: Fail if licenses were not accepted
fail:
msg: "You must accept the licenses, either in the cp4d object with accept_licenses: True, or by specifying --accept-all-licenses at the command line"
Expand Down Expand Up @@ -71,7 +61,4 @@
name: cp4d-prepare-openshift
vars:
_p_openshift_cluster_name: "{{ current_cp4d_cluster.openshift_cluster_name }}"
when: ( current_cp4d_cluster.change_node_settings | default(True) | bool )

- include_tasks: install-cp4d.yml
when: not (cpd_skip_cp_install | bool)
when: ( current_cp4d_cluster.change_node_settings | default(True) | bool )
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
_p_preview: False
when: current_cp4d_cluster.cp4d_version >= "4.7.0"

- name: Prepare KNative for OpenShift
include_tasks: openshift-install-knative.yml

- name: Prepare OpenShift project {{ current_cp4d_cluster.project }} for Cloud Pak for Data
include_tasks: openshift-prepare-project.yml

Expand Down Expand Up @@ -93,26 +90,4 @@
name: cp4d-apply-entitlement
vars:
_p_cp4d_entitlement: "{{ current_cp4d_cluster.cp4d_entitlement | default([]) }}"
_p_cp4d_production_license: "{{ current_cp4d_cluster.cp4d_production_license | default(True) }}"

- name: Create catalog sources for Cloud Pak for Data cartridges in project {{ current_cp4d_cluster.project }}
include_role:
name: cp4d-catalog-source
vars:
_p_current_cp4d_cluster: "{{ current_cp4d_cluster }}"
_p_catsrc_scope: cartridges

- name: Create subscriptions for Cloud Pak for Data cartridges in project {{ current_cp4d_cluster.project }}
include_role:
name: cp4d-subscriptions
vars:
_p_current_cp4d_cluster: "{{ current_cp4d_cluster }}"
_p_subscription_scope: cartridges

# Install selected cartridges
- include_tasks: cp4d-cartridges.yml
when: not (cpd_test_cartridges | default(False) | bool)

# Install all cartridges one by one
- include_tasks: cp4d-cartridges-test-all.yml
when: (cpd_test_cartridges | default(False) | bool)
_p_cp4d_production_license: "{{ current_cp4d_cluster.cp4d_production_license | default(True) }}"
Loading

0 comments on commit 76391e8

Please sign in to comment.