Skip to content

Commit

Permalink
if OS console is not enabled, then fail with a human readable error
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazzitelli committed Oct 25, 2023
1 parent 4b4e941 commit f8f30b8
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 2 deletions.
12 changes: 12 additions & 0 deletions roles/default/kiali-deploy/tasks/openshift/os-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
when:
- is_openshift == True

# If it is Removed, the web console is disabled.
# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html
- name: Determine if OpenShift Console is installed and enabled
vars:
console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}"
set_fact:
has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}"
when:
- is_openshift == True

- name: Create Kiali objects on OpenShift
include_tasks: process-resource.yml
vars:
Expand Down Expand Up @@ -95,6 +105,8 @@
{% endfor %}
when:
- is_openshift == True
- has_openshift_console is defined
- has_openshift_console == True
- no_longer_accessible_namespaces is defined

- name: Process OpenShift Console Links
Expand Down
13 changes: 13 additions & 0 deletions roles/default/kiali-remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@
when:
- is_openshift == True

# If it is Removed, the web console is disabled.
# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html
- name: Determine if OpenShift Console is installed and enabled
ignore_errors: yes
vars:
console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}"
set_fact:
has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}"
when:
- is_openshift == True

- name: Delete OpenShift-specific Kiali ConsoleLinks
ignore_errors: yes
k8s:
Expand All @@ -254,3 +265,5 @@
{% endfor %}
when:
- is_openshift == True
- has_openshift_console is defined
- has_openshift_console == True
11 changes: 11 additions & 0 deletions roles/default/ossmconsole-deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
serviceNamespace: null
servicePort: null

# There are three possible values for the console managementState: Managed, Unmanaged, and Removed.
# If it is Removed, the web console is disabled and thus we cannot install OSSMC so abort immediately.
# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html
- name: Ensure OpenShift Console is installed and enabled
vars:
console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}"
fail:
msg: "The OpenShift Console is not installed and enabled. Cannot install OSSMC."
when:
- console_res | length == 0 or console_res[0].spec.managementState == "Removed"

- name: Get information about the cluster
set_fact:
api_groups: "{{ lookup(k8s_plugin, cluster_info='api_groups') }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/default/ossmconsole-remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- name: Disable plugin by ensuring the OSSM Console is removed from the Console list of plugins
ignore_errors: yes
vars:
existing_plugins: "{{ lookup('kubernetes.core.k8s', resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}"
existing_plugins: "{{ lookup(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}"
k8s:
state: patched
api_version: operator.openshift.io/v1
Expand Down
12 changes: 12 additions & 0 deletions roles/v1.73/kiali-deploy/tasks/openshift/os-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
when:
- is_openshift == True

# If it is Removed, the web console is disabled.
# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html
- name: Determine if OpenShift Console is installed and enabled
vars:
console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}"
set_fact:
has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}"
when:
- is_openshift == True

- name: Create Kiali objects on OpenShift
include_tasks: process-resource.yml
vars:
Expand Down Expand Up @@ -95,6 +105,8 @@
{% endfor %}
when:
- is_openshift == True
- has_openshift_console is defined
- has_openshift_console == True
- no_longer_accessible_namespaces is defined

- name: Process OpenShift Console Links
Expand Down
13 changes: 13 additions & 0 deletions roles/v1.73/kiali-remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@
when:
- is_openshift == True

# If it is Removed, the web console is disabled.
# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html
- name: Determine if OpenShift Console is installed and enabled
ignore_errors: yes
vars:
console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}"
set_fact:
has_openshift_console: "{{ console_res | length > 0 and console_res[0].spec.managementState != 'Removed' }}"
when:
- is_openshift == True

- name: Delete OpenShift-specific Kiali ConsoleLinks
ignore_errors: yes
k8s:
Expand All @@ -254,3 +265,5 @@
{% endfor %}
when:
- is_openshift == True
- has_openshift_console is defined
- has_openshift_console == True
11 changes: 11 additions & 0 deletions roles/v1.73/ossmconsole-deploy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@
serviceNamespace: null
servicePort: null

# There are three possible values for the console managementState: Managed, Unmanaged, and Removed.
# If it is Removed, the web console is disabled and thus we cannot install OSSMC so abort immediately.
# See: https://docs.openshift.com/container-platform/4.13/web_console/disabling-web-console.html
- name: Ensure OpenShift Console is installed and enabled
vars:
console_res: "{{ query(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console', errors='ignore') }}"
fail:
msg: "The OpenShift Console is not installed and enabled. Cannot install OSSMC."
when:
- console_res | length == 0 or console_res[0].spec.managementState == "Removed"

- name: Get information about the cluster
set_fact:
api_groups: "{{ lookup(k8s_plugin, cluster_info='api_groups') }}"
Expand Down
2 changes: 1 addition & 1 deletion roles/v1.73/ossmconsole-remove/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- name: Disable plugin by ensuring the OSSM Console is removed from the Console list of plugins
ignore_errors: yes
vars:
existing_plugins: "{{ lookup('kubernetes.core.k8s', resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}"
existing_plugins: "{{ lookup(k8s_plugin, resource_name='cluster', api_version='operator.openshift.io/v1', kind='Console').spec.plugins | default([]) }}"
k8s:
state: patched
api_version: operator.openshift.io/v1
Expand Down

0 comments on commit f8f30b8

Please sign in to comment.