summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Rutkovsky <vrutkovs@redhat.com>2018-02-06 12:57:21 +0100
committerVadim Rutkovsky <vrutkovs@redhat.com>2018-02-10 10:41:45 +0100
commitcea68953a257477198ac262f3f9c8047e4f39498 (patch)
treee38888067594e8bfa068e3d1a3530a2e85816477
parentf18cfa7897d771cb973b9aa28a90bc3575b56f58 (diff)
downloadopenshift-cea68953a257477198ac262f3f9c8047e4f39498.tar.gz
openshift-cea68953a257477198ac262f3f9c8047e4f39498.tar.bz2
openshift-cea68953a257477198ac262f3f9c8047e4f39498.tar.xz
openshift-cea68953a257477198ac262f3f9c8047e4f39498.zip
Verify that requested services have schedulable nodes matching the selectors
Signed-off-by: Vadim Rutkovsky <vrutkovs@redhat.com>
-rw-r--r--roles/lib_utils/filter_plugins/oo_filters.py48
-rw-r--r--roles/openshift_facts/defaults/main.yml3
-rw-r--r--roles/openshift_logging_curator/tasks/main.yaml7
-rw-r--r--roles/openshift_logging_elasticsearch/tasks/main.yaml7
-rw-r--r--roles/openshift_logging_eventrouter/tasks/install_eventrouter.yaml7
-rw-r--r--roles/openshift_logging_kibana/tasks/main.yaml7
-rw-r--r--roles/openshift_logging_mux/tasks/main.yaml7
-rw-r--r--roles/openshift_metrics/tasks/install_cassandra.yaml7
-rw-r--r--roles/openshift_metrics/tasks/install_hawkular.yaml7
-rw-r--r--roles/openshift_metrics/tasks/install_heapster.yaml7
-rw-r--r--roles/openshift_metrics/tasks/install_hosa.yaml7
-rw-r--r--roles/openshift_prometheus/tasks/install_prometheus.yaml7
-rw-r--r--roles/openshift_provisioners/tasks/install_provisioners.yaml7
-rw-r--r--roles/openshift_service_catalog/tasks/install.yml1
-rw-r--r--roles/template_service_broker/tasks/install.yml7
15 files changed, 134 insertions, 2 deletions
diff --git a/roles/lib_utils/filter_plugins/oo_filters.py b/roles/lib_utils/filter_plugins/oo_filters.py
index c355115b5..ed6bb4c28 100644
--- a/roles/lib_utils/filter_plugins/oo_filters.py
+++ b/roles/lib_utils/filter_plugins/oo_filters.py
@@ -660,6 +660,50 @@ def map_from_pairs(source, delim="="):
return dict(item.split(delim) for item in source.split(","))
+def lib_utils_oo_get_node_labels(source, hostvars=None):
+ ''' Return a list of labels assigned to schedulable nodes '''
+ labels = list()
+
+ # Filter out the unschedulable nodes
+ for host in source:
+ if host not in hostvars:
+ return
+ node_vars = hostvars[host]
+
+ # All nodes are considered schedulable,
+ # unless explicitly marked so
+ schedulable = node_vars.get('openshift_schedulable')
+ if schedulable is None:
+ schedulable = True
+ try:
+ if not strtobool(str(schedulable)):
+ # explicitly marked as unschedulable
+ continue
+ except ValueError:
+ # Incorrect value in openshift_schedulable, skip node
+ continue
+
+ # Get a list of labels from the node
+ node_labels = node_vars.get('openshift_node_labels')
+ if node_labels:
+ labels.append(node_labels)
+
+ return labels
+
+
+def lib_utils_oo_has_no_matching_selector(source, selector=None):
+ ''' Return True when selector cannot be placed
+ on nodes with labels from source '''
+ # Empty selector means any node
+ if not selector:
+ return False
+ for item in source:
+ if selector.items() <= item.items():
+ # Matching selector found
+ return False
+ return True
+
+
class FilterModule(object):
""" Custom ansible filter mapping """
@@ -691,5 +735,7 @@ class FilterModule(object):
"lib_utils_oo_selector_to_string_list": lib_utils_oo_selector_to_string_list,
"lib_utils_oo_filter_sa_secrets": lib_utils_oo_filter_sa_secrets,
"lib_utils_oo_l_of_d_to_csv": lib_utils_oo_l_of_d_to_csv,
- "map_from_pairs": map_from_pairs
+ "lib_utils_oo_has_no_matching_selector": lib_utils_oo_has_no_matching_selector,
+ "lib_utils_oo_get_node_labels": lib_utils_oo_get_node_labels,
+ "map_from_pairs": map_from_pairs,
}
diff --git a/roles/openshift_facts/defaults/main.yml b/roles/openshift_facts/defaults/main.yml
index a223ffba6..3b381b1e4 100644
--- a/roles/openshift_facts/defaults/main.yml
+++ b/roles/openshift_facts/defaults/main.yml
@@ -104,3 +104,6 @@ openshift_service_type_dict:
openshift-enterprise: atomic-openshift
openshift_service_type: "{{ openshift_service_type_dict[openshift_deployment_type] }}"
+
+# Create a list of node labels (dict) for schedulable nodes
+openshift_schedulable_node_labels: "{{ groups['oo_nodes_to_config'] | lib_utils_oo_get_node_labels(hostvars) }}"
diff --git a/roles/openshift_logging_curator/tasks/main.yaml b/roles/openshift_logging_curator/tasks/main.yaml
index 6e8605d28..414fdbb95 100644
--- a/roles/openshift_logging_curator/tasks/main.yaml
+++ b/roles/openshift_logging_curator/tasks/main.yaml
@@ -14,6 +14,13 @@
- include_tasks: determine_version.yaml
+- name: Ensure that logging curator has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for logging curator - '{{ openshift_logging_curator_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_logging_curator_nodeselector)
+
# allow passing in a tempdir
- name: Create temp directory for doing work in
command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
diff --git a/roles/openshift_logging_elasticsearch/tasks/main.yaml b/roles/openshift_logging_elasticsearch/tasks/main.yaml
index 9db67ea9b..758bb7e5d 100644
--- a/roles/openshift_logging_elasticsearch/tasks/main.yaml
+++ b/roles/openshift_logging_elasticsearch/tasks/main.yaml
@@ -1,4 +1,11 @@
---
+- name: Ensure that ElasticSearch has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for Elasticsearch - '{{ openshift_logging_es_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_logging_es_nodeselector)
+
- name: Validate Elasticsearch cluster size
fail: msg="The openshift_logging_es_cluster_size may only be scaled down manually. Please see official documentation on how to do this."
when: openshift_logging_facts.elasticsearch.deploymentconfigs | length > openshift_logging_es_cluster_size|int
diff --git a/roles/openshift_logging_eventrouter/tasks/install_eventrouter.yaml b/roles/openshift_logging_eventrouter/tasks/install_eventrouter.yaml
index fffdd9f8b..2adc51a16 100644
--- a/roles/openshift_logging_eventrouter/tasks/install_eventrouter.yaml
+++ b/roles/openshift_logging_eventrouter/tasks/install_eventrouter.yaml
@@ -4,6 +4,13 @@
msg: Invalid sink type "{{openshift_logging_eventrouter_sink}}", only one of "{{__eventrouter_sinks}}" allowed
that: openshift_logging_eventrouter_sink in __eventrouter_sinks
+- name: Ensure that logging eventrouter has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for logging EventRouter - '{{ openshift_logging_eventrouter_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_logging_eventrouter_nodeselector)
+
# allow passing in a tempdir
- name: Create temp directory for doing work in
command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
diff --git a/roles/openshift_logging_kibana/tasks/main.yaml b/roles/openshift_logging_kibana/tasks/main.yaml
index 58edc5ce5..a125b53bf 100644
--- a/roles/openshift_logging_kibana/tasks/main.yaml
+++ b/roles/openshift_logging_kibana/tasks/main.yaml
@@ -8,6 +8,13 @@
loop_control:
loop_var: var_file_name
+- name: Ensure that Kibana has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for Kibana - '{{ openshift_logging_kibana_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_logging_kibana_nodeselector)
+
- name: Set kibana image facts
set_fact:
openshift_logging_kibana_image_prefix: "{{ openshift_logging_kibana_image_prefix | default(__openshift_logging_kibana_image_prefix) }}"
diff --git a/roles/openshift_logging_mux/tasks/main.yaml b/roles/openshift_logging_mux/tasks/main.yaml
index b2699b285..c061f6766 100644
--- a/roles/openshift_logging_mux/tasks/main.yaml
+++ b/roles/openshift_logging_mux/tasks/main.yaml
@@ -7,6 +7,13 @@
msg: Operations logs destination is required
when: not openshift_logging_mux_ops_host or openshift_logging_mux_ops_host == ''
+- name: Ensure that logging mux has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for logging mux - '{{ openshift_logging_mux_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_logging_mux_nodeselector)
+
- name: Set default image variables based on openshift_deployment_type
include_vars: "{{ var_file_name }}"
with_first_found:
diff --git a/roles/openshift_metrics/tasks/install_cassandra.yaml b/roles/openshift_metrics/tasks/install_cassandra.yaml
index 158e596ec..e0b37ac26 100644
--- a/roles/openshift_metrics/tasks/install_cassandra.yaml
+++ b/roles/openshift_metrics/tasks/install_cassandra.yaml
@@ -1,4 +1,11 @@
---
+- name: Ensure that Cassandra has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for cassandra - '{{ openshift_metrics_cassandra_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_metrics_cassandra_nodeselector)
+
- shell: >
{{ openshift_client_binary }} -n {{ openshift_metrics_project | quote }}
--config={{ mktemp.stdout }}/admin.kubeconfig
diff --git a/roles/openshift_metrics/tasks/install_hawkular.yaml b/roles/openshift_metrics/tasks/install_hawkular.yaml
index f45e7a042..de4e89a01 100644
--- a/roles/openshift_metrics/tasks/install_hawkular.yaml
+++ b/roles/openshift_metrics/tasks/install_hawkular.yaml
@@ -1,4 +1,11 @@
---
+- name: Ensure that Hawkular has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for hawkular - '{{ openshift_metrics_hawkular_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_metrics_hawkular_nodeselector)
+
- command: >
{{ openshift_client_binary }} -n {{ openshift_metrics_project | quote }}
--config={{ mktemp.stdout }}/admin.kubeconfig
diff --git a/roles/openshift_metrics/tasks/install_heapster.yaml b/roles/openshift_metrics/tasks/install_heapster.yaml
index 73e7454f0..15eecf128 100644
--- a/roles/openshift_metrics/tasks/install_heapster.yaml
+++ b/roles/openshift_metrics/tasks/install_heapster.yaml
@@ -1,4 +1,11 @@
---
+- name: Ensure that Heapster has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for heapster - '{{ openshift_metrics_heapster_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_metrics_heapster_nodeselector)
+
- command: >
{{ openshift_client_binary }} -n {{ openshift_metrics_project | quote }}
--config={{ mktemp.stdout }}/admin.kubeconfig
diff --git a/roles/openshift_metrics/tasks/install_hosa.yaml b/roles/openshift_metrics/tasks/install_hosa.yaml
index 7c9bc26d0..d5ae77607 100644
--- a/roles/openshift_metrics/tasks/install_hosa.yaml
+++ b/roles/openshift_metrics/tasks/install_hosa.yaml
@@ -1,4 +1,11 @@
---
+- name: Ensure that Hawkular agent has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for Hawkular agent - '{{ openshift_metrics_hawkular_agent_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_metrics_hawkular_agent_nodeselector)
+
- name: Generate Hawkular Agent (HOSA) Cluster Role
template:
src: hawkular_openshift_agent_role.j2
diff --git a/roles/openshift_prometheus/tasks/install_prometheus.yaml b/roles/openshift_prometheus/tasks/install_prometheus.yaml
index 0b565502f..0d09b0228 100644
--- a/roles/openshift_prometheus/tasks/install_prometheus.yaml
+++ b/roles/openshift_prometheus/tasks/install_prometheus.yaml
@@ -2,6 +2,13 @@
# set facts
- include_tasks: facts.yaml
+- name: Ensure that Prometheus has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for Prometheus - '{{ openshift_prometheus_node_selector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_prometheus_node_selector)
+
# namespace
- name: Add prometheus project
oc_project:
diff --git a/roles/openshift_provisioners/tasks/install_provisioners.yaml b/roles/openshift_provisioners/tasks/install_provisioners.yaml
index 2d1217c74..ec9a762b7 100644
--- a/roles/openshift_provisioners/tasks/install_provisioners.yaml
+++ b/roles/openshift_provisioners/tasks/install_provisioners.yaml
@@ -15,6 +15,13 @@
fail: msg='the openshift_provisioners_efs_aws_secret_access_key variable is required'
when: (openshift_provisioners_efs | bool) and openshift_provisioners_efs_aws_secret_access_key is not defined
+- name: Ensure that provisioners have nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for Prometheus - '{{ openshift_provisioners_efs_nodeselector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(openshift_provisioners_efs_nodeselector)
+
- name: Install support
include_tasks: install_support.yaml
diff --git a/roles/openshift_service_catalog/tasks/install.yml b/roles/openshift_service_catalog/tasks/install.yml
index 4d06c1872..668f9238b 100644
--- a/roles/openshift_service_catalog/tasks/install.yml
+++ b/roles/openshift_service_catalog/tasks/install.yml
@@ -1,6 +1,5 @@
---
# do any asserts here
-
- name: Create temp directory for doing work in
command: mktemp -d /tmp/openshift-service-catalog-ansible-XXXXXX
register: mktemp
diff --git a/roles/template_service_broker/tasks/install.yml b/roles/template_service_broker/tasks/install.yml
index 9f1d66fb5..9c81c3708 100644
--- a/roles/template_service_broker/tasks/install.yml
+++ b/roles/template_service_broker/tasks/install.yml
@@ -1,5 +1,12 @@
---
# Fact setting
+- name: Ensure that Template Service Broker has nodes to run on
+ fail:
+ msg: |-
+ No schedulable nodes found matching node selector for Template Service Broker - '{{ template_service_broker_selector }}'
+ when:
+ - openshift_schedulable_node_labels | lib_utils_oo_has_no_matching_selector(template_service_broker_selector)
+
- name: Set default image variables based on openshift_deployment_type
include_vars: "{{ item }}"
with_first_found: