summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README_CONTAINERIZED_INSTALLATION.md6
-rw-r--r--playbooks/byo/openshift-cluster/upgrades/v3_2/README.md18
-rw-r--r--playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml65
-rw-r--r--playbooks/common/openshift-cluster/evaluate_groups.yml18
-rw-r--r--playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml2
-rw-r--r--playbooks/common/openshift-cluster/upgrades/etcd/backup.yml8
-rw-r--r--playbooks/common/openshift-cluster/upgrades/etcd/main.yml22
-rw-r--r--playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml11
-rw-r--r--playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml5
-rw-r--r--playbooks/common/openshift-cluster/upgrades/upgrade_scheduler.yml166
l---------playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/nuke_images.sh1
-rwxr-xr-xroles/openshift_facts/library/openshift_facts.py6
-rw-r--r--roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_predicates.py129
-rw-r--r--roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_priorities.py116
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py205
-rw-r--r--roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py202
-rw-r--r--roles/openshift_node/tasks/main.yml2
-rw-r--r--utils/.coveragerc4
-rw-r--r--utils/Makefile23
-rw-r--r--utils/setup.cfg10
20 files changed, 631 insertions, 388 deletions
diff --git a/README_CONTAINERIZED_INSTALLATION.md b/README_CONTAINERIZED_INSTALLATION.md
index 0a0ebb836..5e013e809 100644
--- a/README_CONTAINERIZED_INSTALLATION.md
+++ b/README_CONTAINERIZED_INSTALLATION.md
@@ -48,17 +48,17 @@ before attempting to pull any of the following images.
openshift/origin
openshift/node (node + openshift-sdn + openvswitch rpm for client tools)
openshift/openvswitch (centos7 + openvswitch rpm, runs ovsdb ovsctl processes)
- registry.access.redhat.com/rhel7/etcd3
+ registry.access.redhat.com/rhel7/etcd
OpenShift Enterprise
openshift3/ose
openshift3/node
openshift3/openvswitch
- registry.access.redhat.com/rhel7/etcd3
+ registry.access.redhat.com/rhel7/etcd
Atomic Enterprise Platform
aep3/aep
aep3/node
aep3/openvswitch
- registry.access.redhat.com/rhel7/etcd3
+ registry.access.redhat.com/rhel7/etcd
* note openshift3/* and aep3/* images come from registry.access.redhat.com and
rely on the --additional-repository flag being set appropriately.
diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_2/README.md b/playbooks/byo/openshift-cluster/upgrades/v3_2/README.md
deleted file mode 100644
index 30603463a..000000000
--- a/playbooks/byo/openshift-cluster/upgrades/v3_2/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# v3.2 Major and Minor Upgrade Playbook
-
-## Overview
-This playbook currently performs the
-following steps.
-
- * Upgrade and restart master services
- * Unschedule node.
- * Upgrade and restart docker
- * Upgrade and restart node services
- * Modifies the subset of the configuration necessary
- * Applies the latest cluster policies
- * Updates the default router if one exists
- * Updates the default registry if one exists
- * Updates image streams and quickstarts
-
-## Usage
-ansible-playbook -i ~/ansible-inventory openshift-ansible/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml
diff --git a/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml b/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml
deleted file mode 100644
index d92761e48..000000000
--- a/playbooks/byo/openshift-cluster/upgrades/v3_2/upgrade.yml
+++ /dev/null
@@ -1,65 +0,0 @@
----
-- include: ../../../../common/openshift-cluster/verify_ansible_version.yml
-
-- hosts: localhost
- connection: local
- become: no
- gather_facts: no
- tasks:
- - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml
- - add_host:
- name: "{{ item }}"
- groups: l_oo_all_hosts
- with_items: "{{ g_all_hosts | default([]) }}"
-
-- hosts: l_oo_all_hosts
- gather_facts: no
- tasks:
- - include_vars: ../../../../byo/openshift-cluster/cluster_hosts.yml
-
-- include: ../../../../common/openshift-cluster/evaluate_groups.yml
- vars:
- # Do not allow adding hosts during upgrade.
- g_new_master_hosts: []
- g_new_node_hosts: []
- openshift_cluster_id: "{{ cluster_id | default('default') }}"
- openshift_deployment_type: "{{ deployment_type }}"
-
-- name: Set oo_options
- hosts: oo_all_hosts
- tasks:
- - set_fact:
- openshift_docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries') }}"
- when: openshift_docker_additional_registries is not defined
- - set_fact:
- openshift_docker_insecure_registries: "{{ lookup('oo_option', 'docker_insecure_registries') }}"
- when: openshift_docker_insecure_registries is not defined
- - set_fact:
- openshift_docker_blocked_registries: "{{ lookup('oo_option', 'docker_blocked_registries') }}"
- when: openshift_docker_blocked_registries is not defined
- - set_fact:
- openshift_docker_options: "{{ lookup('oo_option', 'docker_options') }}"
- when: openshift_docker_options is not defined
- - set_fact:
- openshift_docker_log_driver: "{{ lookup('oo_option', 'docker_log_driver') }}"
- when: openshift_docker_log_driver is not defined
- - set_fact:
- openshift_docker_log_options: "{{ lookup('oo_option', 'docker_log_options') }}"
- when: openshift_docker_log_options is not defined
-
-
-# Configure the upgrade target for the common upgrade tasks:
-- hosts: l_oo_all_hosts
- tasks:
- - set_fact:
- openshift_upgrade_target: "{{ '1.2' if deployment_type == 'origin' else '3.2' }}"
- openshift_upgrade_min: "{{ '1.1' if deployment_type == 'origin' else '3.1' }}"
-
-- include: ../../../../common/openshift-cluster/upgrades/pre.yml
- vars:
- openshift_deployment_type: "{{ deployment_type }}"
-- include: ../../../../common/openshift-cluster/upgrades/upgrade.yml
- vars:
- openshift_deployment_type: "{{ deployment_type }}"
-- include: ../../../openshift-master/restart.yml
-- include: ../../../../common/openshift-cluster/upgrades/post.yml
diff --git a/playbooks/common/openshift-cluster/evaluate_groups.yml b/playbooks/common/openshift-cluster/evaluate_groups.yml
index 65b45886a..45a4875a3 100644
--- a/playbooks/common/openshift-cluster/evaluate_groups.yml
+++ b/playbooks/common/openshift-cluster/evaluate_groups.yml
@@ -7,27 +7,27 @@
tasks:
- fail:
msg: This playbook requires g_etcd_hosts to be set
- when: g_etcd_hosts is not defined
+ when: "{{ g_etcd_hosts is not defined }}"
- fail:
msg: This playbook requires g_master_hosts or g_new_master_hosts to be set
- when: g_master_hosts is not defined and g_new_master_hosts is not defined
+ when: "{{ g_master_hosts is not defined and g_new_master_hosts is not defined }}"
- fail:
msg: This playbook requires g_node_hosts or g_new_node_hosts to be set
- when: g_node_hosts is not defined and g_new_node_hosts is not defined
+ when: "{{ g_node_hosts is not defined and g_new_node_hosts is not defined }}"
- fail:
msg: This playbook requires g_lb_hosts to be set
- when: g_lb_hosts is not defined
+ when: "{{ g_lb_hosts is not defined }}"
- fail:
msg: This playbook requires g_nfs_hosts to be set
- when: g_nfs_hosts is not defined
+ when: "{{ g_nfs_hosts is not defined }}"
- fail:
msg: The nfs group must be limited to one host
- when: (groups[g_nfs_hosts] | default([])) | length > 1
+ when: "{{ (groups[g_nfs_hosts] | default([])) | length > 1 }}"
- name: Evaluate oo_all_hosts
add_host:
@@ -82,7 +82,7 @@
ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
ansible_become: "{{ g_sudo | default(omit) }}"
with_items: "{{ g_master_hosts | default([]) }}"
- when: g_nodeonmaster | default(false) | bool and not g_new_node_hosts | default(false) | bool
+ when: "{{ g_nodeonmaster | default(false) | bool and not g_new_node_hosts | default(false) | bool }}"
changed_when: no
- name: Evaluate oo_first_etcd
@@ -90,7 +90,7 @@
name: "{{ g_etcd_hosts[0] }}"
groups: oo_first_etcd
ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
- when: g_etcd_hosts|length > 0
+ when: "{{ g_etcd_hosts|length > 0 }}"
changed_when: no
- name: Evaluate oo_first_master
@@ -99,7 +99,7 @@
groups: oo_first_master
ansible_ssh_user: "{{ g_ssh_user | default(omit) }}"
ansible_become: "{{ g_sudo | default(omit) }}"
- when: g_master_hosts|length > 0
+ when: "{{ g_master_hosts|length > 0 }}"
changed_when: no
- name: Evaluate oo_lb_to_config
diff --git a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml
index ee75aa853..f2a2259e3 100644
--- a/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml
+++ b/playbooks/common/openshift-cluster/upgrades/docker/upgrade_check.yml
@@ -9,6 +9,8 @@
- name: Check if Docker is installed
command: rpm -q docker
+ args:
+ warn: no
register: pkg_check
failed_when: pkg_check.rc > 1
changed_when: no
diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml
index b7f0267c1..cfb273b82 100644
--- a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml
+++ b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml
@@ -41,9 +41,11 @@
{{ avail_disk.stdout }} Kb available.
when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int)
- - name: Install etcd (for etcdctl)
- package: name=etcd state=present
- when: not openshift.common.is_atomic | bool
+ # for non containerized etcd is already installed, don't touch it, but for containerized
+ # but not atomic always get the latest
+ - name: Install latest text for containerized but not atomic
+ package: name=etcd state=latest
+ when: not openshift.common.is_atomic | bool and openshift.common.is_containerized
- name: Generate etcd backup
command: >
diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/main.yml b/playbooks/common/openshift-cluster/upgrades/etcd/main.yml
index 192799376..c67cf282f 100644
--- a/playbooks/common/openshift-cluster/upgrades/etcd/main.yml
+++ b/playbooks/common/openshift-cluster/upgrades/etcd/main.yml
@@ -38,12 +38,14 @@
tasks:
- name: Record RPM based etcd version
command: rpm -qa --qf '%{version}' etcd\*
- register: etcd_installed_version
+ args:
+ warn: no
+ register: etcd_rpm_version
failed_when: false
when: not openshift.common.is_containerized | bool
- name: Record containerized etcd version
command: docker exec etcd_container rpm -qa --qf '%{version}' etcd\*
- register: etcd_installed_version
+ register: etcd_container_version
failed_when: false
when: openshift.common.is_containerized | bool
@@ -56,7 +58,7 @@
upgrade_version: '2.1'
tasks:
- include: rhel_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('2.1','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
+ when: etcd_rpm_version.stdout | default('99') | version_compare('2.1','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
- name: Upgrade RPM hosts to 2.2
hosts: etcd_hosts_to_upgrade
@@ -65,7 +67,7 @@
upgrade_version: '2.2'
tasks:
- include: rhel_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('2.2','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
+ when: etcd_rpm_version.stdout | default('99') | version_compare('2.2','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
- name: Upgrade containerized hosts to 2.2.5
hosts: etcd_hosts_to_upgrade
@@ -74,7 +76,7 @@
upgrade_version: 2.2.5
tasks:
- include: containerized_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('2.2','<') and openshift.common.is_containerized | bool
+ when: etcd_container_version.stdout | default('99') | version_compare('2.2','<') and openshift.common.is_containerized | bool
- name: Upgrade RPM hosts to 2.3
hosts: etcd_hosts_to_upgrade
@@ -83,7 +85,7 @@
upgrade_version: '2.3'
tasks:
- include: rhel_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('2.3','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
+ when: etcd_rpm_version.stdout | default('99') | version_compare('2.3','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
- name: Upgrade containerized hosts to 2.3.7
hosts: etcd_hosts_to_upgrade
@@ -92,7 +94,7 @@
upgrade_version: 2.3.7
tasks:
- include: containerized_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('2.3','<') and openshift.common.is_containerized | bool
+ when: etcd_container_version.stdout | default('99') | version_compare('2.3','<') and openshift.common.is_containerized | bool
- name: Upgrade RPM hosts to 3.0
hosts: etcd_hosts_to_upgrade
@@ -101,16 +103,16 @@
upgrade_version: '3.0'
tasks:
- include: rhel_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('3.0','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
+ when: etcd_rpm_version.stdout | default('99') | version_compare('3.0','<') and ansible_distribution == 'RedHat' and not openshift.common.is_containerized | bool
- name: Upgrade containerized hosts to etcd3 image
hosts: etcd_hosts_to_upgrade
serial: 1
vars:
- upgrade_version: 3.0.3
+ upgrade_version: 3.0.14
tasks:
- include: containerized_tasks.yml
- when: etcd_installed_version.stdout | default('99') | version_compare('3.0','<') and openshift.common.is_containerized | bool
+ when: etcd_container_version.stdout | default('99') | version_compare('3.0','<') and openshift.common.is_containerized | bool
- name: Upgrade fedora to latest
hosts: etcd_hosts_to_upgrade
diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml b/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml
index 8e7dc9d9b..3a972e8ab 100644
--- a/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml
+++ b/playbooks/common/openshift-cluster/upgrades/etcd/rhel_tasks.yml
@@ -2,13 +2,10 @@
- name: Verify cluster is healthy pre-upgrade
command: "etcdctl --cert-file /etc/etcd/peer.crt --key-file /etc/etcd/peer.key --ca-file /etc/etcd/ca.crt -C https://{{ openshift.common.hostname }}:2379 cluster-health"
-- name: Update etcd package but exclude etcd3
- command: "{{ ansible_pkg_mgr }} install -y etcd-{{ upgrade_version }}\\* --exclude etcd3"
- when: upgrade_version | version_compare('3.0','<')
-
-- name: Update etcd package not excluding etcd3
- command: "{{ ansible_pkg_mgr }} install -y etcd3-{{ upgrade_version }}\\*"
- when: not upgrade_version | version_compare('3.0','<')
+- name: Update etcd RPM
+ package:
+ name: etcd-{{ upgrade_version }}*
+ state: latest
- name: Restart etcd
service:
diff --git a/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml b/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml
index 9035b4d1d..f74ea9820 100644
--- a/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml
+++ b/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml
@@ -33,9 +33,6 @@
- name: Upgrade master packages
hosts: oo_masters_to_config
- handlers:
- - include: ../../../../roles/openshift_master/handlers/main.yml
- static: yes
roles:
- openshift_facts
tasks:
@@ -64,6 +61,8 @@
- openshift_facts
- openshift_master_facts
tasks:
+ - include: upgrade_scheduler.yml
+
- include: "{{ master_config_hook }}"
when: master_config_hook is defined
diff --git a/playbooks/common/openshift-cluster/upgrades/upgrade_scheduler.yml b/playbooks/common/openshift-cluster/upgrades/upgrade_scheduler.yml
new file mode 100644
index 000000000..88f2ddc78
--- /dev/null
+++ b/playbooks/common/openshift-cluster/upgrades/upgrade_scheduler.yml
@@ -0,0 +1,166 @@
+---
+# Upgrade predicates
+- vars:
+ prev_predicates: "{{ lookup('openshift_master_facts_default_predicates', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type) }}"
+ prev_predicates_no_region: "{{ lookup('openshift_master_facts_default_predicates', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type, regions_enabled=False) }}"
+ default_predicates_no_region: "{{ lookup('openshift_master_facts_default_predicates', regions_enabled=False) }}"
+ # older_predicates are the set of predicates that have previously been
+ # hard-coded into openshift_facts
+ older_predicates:
+ - - name: MatchNodeSelector
+ - name: PodFitsResources
+ - name: PodFitsPorts
+ - name: NoDiskConflict
+ - name: NoVolumeZoneConflict
+ - name: MaxEBSVolumeCount
+ - name: MaxGCEPDVolumeCount
+ - name: Region
+ argument:
+ serviceAffinity:
+ labels:
+ - region
+ - - name: MatchNodeSelector
+ - name: PodFitsResources
+ - name: PodFitsPorts
+ - name: NoDiskConflict
+ - name: NoVolumeZoneConflict
+ - name: Region
+ argument:
+ serviceAffinity:
+ labels:
+ - region
+ - - name: MatchNodeSelector
+ - name: PodFitsResources
+ - name: PodFitsPorts
+ - name: NoDiskConflict
+ - name: Region
+ argument:
+ serviceAffinity:
+ labels:
+ - region
+ # older_predicates_no_region are the set of predicates that have previously
+ # been hard-coded into openshift_facts, with the Region predicate removed
+ older_predicates_no_region:
+ - - name: MatchNodeSelector
+ - name: PodFitsResources
+ - name: PodFitsPorts
+ - name: NoDiskConflict
+ - name: NoVolumeZoneConflict
+ - name: MaxEBSVolumeCount
+ - name: MaxGCEPDVolumeCount
+ - - name: MatchNodeSelector
+ - name: PodFitsResources
+ - name: PodFitsPorts
+ - name: NoDiskConflict
+ - name: NoVolumeZoneConflict
+ - - name: MatchNodeSelector
+ - name: PodFitsResources
+ - name: PodFitsPorts
+ - name: NoDiskConflict
+ block:
+
+ # Handle case where openshift_master_predicates is defined
+ - block:
+ - debug:
+ msg: "WARNING: openshift_master_scheduler_predicates is set to defaults from an earlier release of OpenShift current defaults are: {{ openshift_master_scheduler_default_predicates }}"
+ when: "{{ openshift_master_scheduler_predicates in older_predicates + older_predicates_no_region + [prev_predicates] + [prev_predicates_no_region] }}"
+
+ - debug:
+ msg: "WARNING: openshift_master_scheduler_predicates does not match current defaults of: {{ openshift_master_scheduler_default_predicates }}"
+ when: "{{ openshift_master_scheduler_predicates != openshift_master_scheduler_default_predicates }}"
+ when: "{{ openshift_master_scheduler_predicates | default(none) is not none }}"
+
+ # Handle cases where openshift_master_predicates is not defined
+ - block:
+ - debug:
+ msg: "WARNING: existing scheduler config does not match previous known defaults automated upgrade of scheduler config is disabled.\nexisting scheduler predicates: {{ openshift_master_scheduler_current_predicates }}\ncurrent scheduler default predicates are: {{ openshift_master_scheduler_default_predicates }}"
+ when: "{{ openshift_master_scheduler_current_predicates != openshift_master_scheduler_default_predicates and
+ openshift_master_scheduler_current_predicates not in older_predicates + [prev_predicates] }}"
+
+ - set_fact:
+ openshift_upgrade_scheduler_predicates: "{{ openshift_master_scheduler_default_predicates }}"
+ when: "{{ openshift_master_scheduler_current_predicates != openshift_master_scheduler_default_predicates and
+ openshift_master_scheduler_current_predicates in older_predicates + [prev_predicates] }}"
+
+ - set_fact:
+ openshift_upgrade_scheduler_predicates: "{{ default_predicates_no_region }}"
+ when: "{{ openshift_master_scheduler_current_predicates != default_predicates_no_region and
+ openshift_master_scheduler_current_predicates in older_predicates_no_region + [prev_predicates_no_region] }}"
+
+ when: "{{ openshift_master_scheduler_predicates | default(none) is none }}"
+
+
+# Upgrade priorities
+- vars:
+ prev_priorities: "{{ lookup('openshift_master_facts_default_priorities', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type) }}"
+ prev_priorities_no_zone: "{{ lookup('openshift_master_facts_default_priorities', short_version=openshift_upgrade_min, deployment_type=openshift_deployment_type, zones_enabled=False) }}"
+ default_priorities_no_zone: "{{ lookup('openshift_master_facts_default_priorities', zones_enabled=False) }}"
+ # older_priorities are the set of priorities that have previously been
+ # hard-coded into openshift_facts
+ older_priorities:
+ - - name: LeastRequestedPriority
+ weight: 1
+ - name: SelectorSpreadPriority
+ weight: 1
+ - name: Zone
+ weight: 2
+ argument:
+ serviceAntiAffinity:
+ label: zone
+ # older_priorities_no_region are the set of priorities that have previously
+ # been hard-coded into openshift_facts, with the Zone priority removed
+ older_priorities_no_zone:
+ - - name: LeastRequestedPriority
+ weight: 1
+ - name: SelectorSpreadPriority
+ weight: 1
+ block:
+
+ # Handle case where openshift_master_priorities is defined
+ - block:
+ - debug:
+ msg: "WARNING: openshift_master_scheduler_priorities is set to defaults from an earlier release of OpenShift current defaults are: {{ openshift_master_scheduler_default_priorities }}"
+ when: "{{ openshift_master_scheduler_priorities in older_priorities + older_priorities_no_zone + [prev_priorities] + [prev_priorities_no_zone] }}"
+
+ - debug:
+ msg: "WARNING: openshift_master_scheduler_priorities does not match current defaults of: {{ openshift_master_scheduler_default_priorities }}"
+ when: "{{ openshift_master_scheduler_priorities != openshift_master_scheduler_default_priorities }}"
+ when: "{{ openshift_master_scheduler_priorities | default(none) is not none }}"
+
+ # Handle cases where openshift_master_priorities is not defined
+ - block:
+ - debug:
+ msg: "WARNING: existing scheduler config does not match previous known defaults automated upgrade of scheduler config is disabled.\nexisting scheduler priorities: {{ openshift_master_scheduler_current_priorities }}\ncurrent scheduler default priorities are: {{ openshift_master_scheduler_default_priorities }}"
+ when: "{{ openshift_master_scheduler_current_priorities != openshift_master_scheduler_default_priorities and
+ openshift_master_scheduler_current_priorities not in older_priorities + [prev_priorities] }}"
+
+ - set_fact:
+ openshift_upgrade_scheduler_priorities: "{{ openshift_master_scheduler_default_priorities }}"
+ when: "{{ openshift_master_scheduler_current_priorities != openshift_master_scheduler_default_priorities and
+ openshift_master_scheduler_current_priorities in older_priorities + [prev_priorities] }}"
+
+ - set_fact:
+ openshift_upgrade_scheduler_priorities: "{{ default_priorities_no_zone }}"
+ when: "{{ openshift_master_scheduler_current_priorities != default_priorities_no_zone and
+ openshift_master_scheduler_current_priorities in older_priorities_no_zone + [prev_priorities_no_zone] }}"
+
+ when: "{{ openshift_master_scheduler_priorities | default(none) is none }}"
+
+
+# Update scheduler
+- vars:
+ scheduler_config:
+ kind: Policy
+ apiVersion: v1
+ predicates: "{{ openshift_upgrade_scheduler_predicates
+ | default(openshift_master_scheduler_current_predicates) }}"
+ priorities: "{{ openshift_upgrade_scheduler_priorities
+ | default(openshift_master_scheduler_current_priorities) }}"
+ block:
+ - name: Update scheduler config
+ copy:
+ content: "{{ scheduler_config | to_nice_json }}"
+ dest: "{{ openshift_master_scheduler_conf }}"
+ backup: true
+ when: "{{ openshift_upgrade_scheduler_predicates is defined or
+ openshift_upgrade_scheduler_priorities is defined }}"
diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/nuke_images.sh b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/nuke_images.sh
deleted file mode 120000
index 49a51bba9..000000000
--- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/nuke_images.sh
+++ /dev/null
@@ -1 +0,0 @@
-../files/nuke_images.sh \ No newline at end of file
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py
index 2495ad46c..a6f74168e 100755
--- a/roles/openshift_facts/library/openshift_facts.py
+++ b/roles/openshift_facts/library/openshift_facts.py
@@ -1673,7 +1673,7 @@ def set_container_facts_if_unset(facts):
cli_image = master_image
node_image = 'openshift3/node'
ovs_image = 'openshift3/openvswitch'
- etcd_image = 'registry.access.redhat.com/rhel7/etcd3'
+ etcd_image = 'registry.access.redhat.com/rhel7/etcd'
pod_image = 'openshift3/ose-pod'
router_image = 'openshift3/ose-haproxy-router'
registry_image = 'openshift3/ose-docker-registry'
@@ -1683,7 +1683,7 @@ def set_container_facts_if_unset(facts):
cli_image = master_image
node_image = 'aep3_beta/node'
ovs_image = 'aep3_beta/openvswitch'
- etcd_image = 'registry.access.redhat.com/rhel7/etcd3'
+ etcd_image = 'registry.access.redhat.com/rhel7/etcd'
pod_image = 'aep3_beta/aep-pod'
router_image = 'aep3_beta/aep-haproxy-router'
registry_image = 'aep3_beta/aep-docker-registry'
@@ -1693,7 +1693,7 @@ def set_container_facts_if_unset(facts):
cli_image = master_image
node_image = 'openshift/node'
ovs_image = 'openshift/openvswitch'
- etcd_image = 'registry.access.redhat.com/rhel7/etcd3'
+ etcd_image = 'registry.access.redhat.com/rhel7/etcd'
pod_image = 'openshift/origin-pod'
router_image = 'openshift/origin-haproxy-router'
registry_image = 'openshift/origin-docker-registry'
diff --git a/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_predicates.py b/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_predicates.py
index 05b62a7a6..4f7461827 100644
--- a/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_predicates.py
+++ b/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_predicates.py
@@ -6,26 +6,24 @@ from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
- # pylint: disable=too-many-branches,too-many-statements
-
- def run(self, terms, variables=None, regions_enabled=True, **kwargs):
- if 'openshift' not in variables:
- raise AnsibleError("This lookup module requires openshift_facts to be run prior to use")
- if 'master' not in variables['openshift']:
- raise AnsibleError("This lookup module is meant to be run against an OpenShift master host only")
-
- if 'openshift_master_scheduler_predicates' in variables:
- return variables['openshift_master_scheduler_predicates']
- elif 'scheduler_predicates' in variables['openshift']['master']:
- return variables['openshift']['master']['scheduler_predicates']
- else:
- predicates = []
+ # pylint: disable=too-many-branches,too-many-statements,too-many-arguments
+
+ def run(self, terms, variables=None, regions_enabled=True, short_version=None,
+ deployment_type=None, **kwargs):
+
+ predicates = []
+
+ if short_version is None or deployment_type is None:
+ if 'openshift' not in variables:
+ raise AnsibleError("This lookup module requires openshift_facts to be run prior to use")
- if 'deployment_type' not in variables['openshift']['common']:
+ if deployment_type is None:
+ if 'common' not in variables['openshift'] or 'deployment_type' not in variables['openshift']['common']:
raise AnsibleError("This lookup module requires that the deployment_type be set")
deployment_type = variables['openshift']['common']['deployment_type']
+ if short_version is None:
if 'short_version' in variables['openshift']['common']:
short_version = variables['openshift']['common']['short_version']
elif 'openshift_release' in variables:
@@ -34,63 +32,62 @@ class LookupModule(LookupBase):
short_version = release[1:]
else:
short_version = release
+ short_version = '.'.join(short_version.split('.')[0:2])
elif 'openshift_version' in variables:
version = variables['openshift_version']
short_version = '.'.join(version.split('.')[0:2])
else:
# pylint: disable=line-too-long
raise AnsibleError("Either OpenShift needs to be installed or openshift_release needs to be specified")
- if deployment_type not in ['origin', 'openshift-enterprise']:
- raise AnsibleError("Unknown deployment_type %s" % deployment_type)
-
- if deployment_type == 'origin':
- if short_version not in ['1.1', '1.2', '1.3', '1.4']:
- raise AnsibleError("Unknown short_version %s" % short_version)
- elif deployment_type == 'openshift_enterprise':
- if short_version not in ['3.1', '3.2', '3.3', '3.4']:
- raise AnsibleError("Unknown short_version %s" % short_version)
-
- if deployment_type == 'openshift-enterprise':
- # convert short_version to origin short_version
- short_version = re.sub('^3.', '1.', short_version)
-
- if short_version in ['1.1', '1.2']:
- predicates.append({'name': 'PodFitsHostPorts'})
- predicates.append({'name': 'PodFitsResources'})
-
- # applies to all known versions
- predicates.append({'name': 'NoDiskConflict'})
-
- # only 1.1 didn't include NoVolumeZoneConflict
- if short_version != '1.1':
- predicates.append({'name': 'NoVolumeZoneConflict'})
-
- if short_version in ['1.1', '1.2']:
- predicates.append({'name': 'MatchNodeSelector'})
- predicates.append({'name': 'Hostname'})
-
- if short_version != '1.1':
- predicates.append({'name': 'MaxEBSVolumeCount'})
- predicates.append({'name': 'MaxGCEPDVolumeCount'})
-
- if short_version not in ['1.1', '1.2']:
- predicates.append({'name': 'GeneralPredicates'})
- predicates.append({'name': 'PodToleratesNodeTaints'})
- predicates.append({'name': 'CheckNodeMemoryPressure'})
-
- if short_version not in ['1.1', '1.2', '1.3']:
- predicates.append({'name': 'CheckNodeDiskPressure'})
- predicates.append({'name': 'MatchInterPodAffinity'})
-
- if regions_enabled:
- region_predicate = {
- 'name': 'Region',
- 'argument': {
- 'serviceAffinity': {
- 'labels': ['region']
- }
+ if deployment_type == 'origin':
+ if short_version not in ['1.1', '1.2', '1.3', '1.4']:
+ raise AnsibleError("Unknown short_version %s" % short_version)
+ elif deployment_type == 'openshift-enterprise':
+ if short_version not in ['3.1', '3.2', '3.3', '3.4']:
+ raise AnsibleError("Unknown short_version %s" % short_version)
+ else:
+ raise AnsibleError("Unknown deployment_type %s" % deployment_type)
+
+ if deployment_type == 'openshift-enterprise':
+ # convert short_version to origin short_version
+ short_version = re.sub('^3.', '1.', short_version)
+
+ if short_version in ['1.1', '1.2']:
+ predicates.append({'name': 'PodFitsHostPorts'})
+ predicates.append({'name': 'PodFitsResources'})
+
+ # applies to all known versions
+ predicates.append({'name': 'NoDiskConflict'})
+
+ # only 1.1 didn't include NoVolumeZoneConflict
+ if short_version != '1.1':
+ predicates.append({'name': 'NoVolumeZoneConflict'})
+
+ if short_version in ['1.1', '1.2']:
+ predicates.append({'name': 'MatchNodeSelector'})
+
+ if short_version != '1.1':
+ predicates.append({'name': 'MaxEBSVolumeCount'})
+ predicates.append({'name': 'MaxGCEPDVolumeCount'})
+
+ if short_version not in ['1.1', '1.2']:
+ predicates.append({'name': 'GeneralPredicates'})
+ predicates.append({'name': 'PodToleratesNodeTaints'})
+ predicates.append({'name': 'CheckNodeMemoryPressure'})
+
+ if short_version not in ['1.1', '1.2', '1.3']:
+ predicates.append({'name': 'CheckNodeDiskPressure'})
+ predicates.append({'name': 'MatchInterPodAffinity'})
+
+ if regions_enabled:
+ region_predicate = {
+ 'name': 'Region',
+ 'argument': {
+ 'serviceAffinity': {
+ 'labels': ['region']
}
}
- predicates.append(region_predicate)
+ }
+ predicates.append(region_predicate)
- return predicates
+ return predicates
diff --git a/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_priorities.py b/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_priorities.py
index 3329d26b0..7087ff03c 100644
--- a/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_priorities.py
+++ b/roles/openshift_master_facts/lookup_plugins/openshift_master_facts_default_priorities.py
@@ -6,30 +6,28 @@ from ansible.plugins.lookup import LookupBase
class LookupModule(LookupBase):
- # pylint: disable=too-many-branches
-
- def run(self, terms, variables=None, zones_enabled=True, **kwargs):
- if 'openshift' not in variables:
- raise AnsibleError("This lookup module requires openshift_facts to be run prior to use")
- if 'master' not in variables['openshift']:
- raise AnsibleError("This lookup module is meant to be run against an OpenShift master host only")
-
- if 'openshift_master_scheduler_priorities' in variables:
- return variables['openshift_master_scheduler_priorities']
- elif 'scheduler_priorities' in variables['openshift']['master']:
- return variables['openshift']['master']['scheduler_priorities']
- else:
- priorities = [
- {'name': 'LeastRequestedPriority', 'weight': 1},
- {'name': 'BalancedResourceAllocation', 'weight': 1},
- {'name': 'SelectorSpreadPriority', 'weight': 1}
- ]
+ # pylint: disable=too-many-branches,too-many-statements,too-many-arguments
+
+ def run(self, terms, variables=None, zones_enabled=True, short_version=None,
+ deployment_type=None, **kwargs):
+
+ priorities = [
+ {'name': 'LeastRequestedPriority', 'weight': 1},
+ {'name': 'BalancedResourceAllocation', 'weight': 1},
+ {'name': 'SelectorSpreadPriority', 'weight': 1}
+ ]
- if 'deployment_type' not in variables['openshift']['common']:
+ if short_version is None or deployment_type is None:
+ if 'openshift' not in variables:
+ raise AnsibleError("This lookup module requires openshift_facts to be run prior to use")
+
+ if deployment_type is None:
+ if 'common' not in variables['openshift'] or 'deployment_type' not in variables['openshift']['common']:
raise AnsibleError("This lookup module requires that the deployment_type be set")
deployment_type = variables['openshift']['common']['deployment_type']
+ if short_version is None:
if 'short_version' in variables['openshift']['common']:
short_version = variables['openshift']['common']['short_version']
elif 'openshift_release' in variables:
@@ -38,6 +36,7 @@ class LookupModule(LookupBase):
short_version = release[1:]
else:
short_version = release
+ short_version = '.'.join(short_version.split('.')[0:2])
elif 'openshift_version' in variables:
version = variables['openshift_version']
short_version = '.'.join(version.split('.')[0:2])
@@ -45,43 +44,42 @@ class LookupModule(LookupBase):
# pylint: disable=line-too-long
raise AnsibleError("Either OpenShift needs to be installed or openshift_release needs to be specified")
- if deployment_type not in ['origin', 'openshift-enterprise']:
- raise AnsibleError("Unknown deployment_type %s" % deployment_type)
-
- if deployment_type == 'origin':
- if short_version not in ['1.1', '1.2', '1.3', '1.4']:
- raise AnsibleError("Unknown short_version %s" % short_version)
- elif deployment_type == 'openshift_enterprise':
- if short_version not in ['3.1', '3.2', '3.3', '3.4']:
- raise AnsibleError("Unknown short_version %s" % short_version)
-
- if deployment_type == 'openshift-enterprise':
- # convert short_version to origin short_version
- short_version = re.sub('^3.', '1.', short_version)
-
- if short_version == '1.4':
- priorities.append({'name': 'NodePreferAvoidPodsPriority', 'weight': 10000})
-
- # only 1.1 didn't include NodeAffinityPriority
- if short_version != '1.1':
- priorities.append({'name': 'NodeAffinityPriority', 'weight': 1})
-
- if short_version not in ['1.1', '1.2']:
- priorities.append({'name': 'TaintTolerationPriority', 'weight': 1})
-
- if short_version not in ['1.1', '1.2', '1.3']:
- priorities.append({'name': 'InterPodAffinityPriority', 'weight': 1})
-
- if zones_enabled:
- zone_priority = {
- 'name': 'Zone',
- 'argument': {
- 'serviceAntiAffinity': {
- 'label': 'zone'
- }
- },
- 'weight': 2
- }
- priorities.append(zone_priority)
-
- return priorities
+ if deployment_type == 'origin':
+ if short_version not in ['1.1', '1.2', '1.3', '1.4']:
+ raise AnsibleError("Unknown short_version %s" % short_version)
+ elif deployment_type == 'openshift-enterprise':
+ if short_version not in ['3.1', '3.2', '3.3', '3.4']:
+ raise AnsibleError("Unknown short_version %s" % short_version)
+ else:
+ raise AnsibleError("Unknown deployment_type %s" % deployment_type)
+
+ if deployment_type == 'openshift-enterprise':
+ # convert short_version to origin short_version
+ short_version = re.sub('^3.', '1.', short_version)
+
+ if short_version == '1.4':
+ priorities.append({'name': 'NodePreferAvoidPodsPriority', 'weight': 10000})
+
+ # only 1.1 didn't include NodeAffinityPriority
+ if short_version != '1.1':
+ priorities.append({'name': 'NodeAffinityPriority', 'weight': 1})
+
+ if short_version not in ['1.1', '1.2']:
+ priorities.append({'name': 'TaintTolerationPriority', 'weight': 1})
+
+ if short_version not in ['1.1', '1.2', '1.3']:
+ priorities.append({'name': 'InterPodAffinityPriority', 'weight': 1})
+
+ if zones_enabled:
+ zone_priority = {
+ 'name': 'Zone',
+ 'argument': {
+ 'serviceAntiAffinity': {
+ 'label': 'zone'
+ }
+ },
+ 'weight': 2
+ }
+ priorities.append(zone_priority)
+
+ return priorities
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
index 6f2a916d0..c95356908 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_default_predicates_tests.py
@@ -14,7 +14,6 @@ DEFAULT_PREDICATES_1_1 = [
{'name': 'PodFitsResources'},
{'name': 'NoDiskConflict'},
{'name': 'MatchNodeSelector'},
- {'name': 'Hostname'}
]
DEFAULT_PREDICATES_1_2 = [
@@ -23,7 +22,6 @@ DEFAULT_PREDICATES_1_2 = [
{'name': 'NoDiskConflict'},
{'name': 'NoVolumeZoneConflict'},
{'name': 'MatchNodeSelector'},
- {'name': 'Hostname'},
{'name': 'MaxEBSVolumeCount'},
{'name': 'MaxGCEPDVolumeCount'}
]
@@ -59,13 +57,23 @@ REGION_PREDICATE = {
}
}
+TEST_VARS = [
+ ('1.1', 'origin', DEFAULT_PREDICATES_1_1),
+ ('3.1', 'openshift-enterprise', DEFAULT_PREDICATES_1_1),
+ ('1.2', 'origin', DEFAULT_PREDICATES_1_2),
+ ('3.2', 'openshift-enterprise', DEFAULT_PREDICATES_1_2),
+ ('1.3', 'origin', DEFAULT_PREDICATES_1_3),
+ ('3.3', 'openshift-enterprise', DEFAULT_PREDICATES_1_3),
+ ('1.4', 'origin', DEFAULT_PREDICATES_1_4),
+ ('3.4', 'openshift-enterprise', DEFAULT_PREDICATES_1_4)
+]
+
class TestOpenShiftMasterFactsDefaultPredicates(object):
def setUp(self):
self.lookup = LookupModule()
self.default_facts = {
'openshift': {
- 'master': {},
'common': {}
}
}
@@ -76,13 +84,70 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
facts['openshift']['common']['deployment_type'] = 'origin'
self.lookup.run(None, variables=facts)
- def check_defaults(self, release, deployment_type, default_predicates,
- regions_enabled, short_version):
+ def check_defaults_short_version(self, short_version, deployment_type, default_predicates,
+ regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = short_version
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+
+ def check_defaults_short_version_kwarg(self, short_version, deployment_type, default_predicates,
+ regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled,
+ short_version=short_version)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+
+ def check_defaults_deployment_type_kwarg(self, short_version, deployment_type,
+ default_predicates, regions_enabled):
facts = copy.deepcopy(self.default_facts)
- if short_version:
- facts['openshift']['common']['short_version'] = release
+ facts['openshift']['common']['short_version'] = short_version
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled,
+ deployment_type=deployment_type)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+
+ def check_defaults_only_kwargs(self, short_version, deployment_type,
+ default_predicates, regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled,
+ short_version=short_version,
+ deployment_type=deployment_type)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+
+ def check_defaults_release(self, release, deployment_type, default_predicates,
+ regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_release'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
else:
- facts['openshift_release'] = release
+ assert_equal(results, default_predicates)
+
+ def check_defaults_version(self, version, deployment_type, default_predicates,
+ regions_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_version'] = version
facts['openshift']['common']['deployment_type'] = deployment_type
results = self.lookup.run(None, variables=facts,
regions_enabled=regions_enabled)
@@ -91,39 +156,63 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_predicates)
- def test_openshift_release_defaults(self):
- test_vars = [
- ('1.1', 'origin', DEFAULT_PREDICATES_1_1),
- ('3.1', 'openshift-enterprise', DEFAULT_PREDICATES_1_1),
- ('1.2', 'origin', DEFAULT_PREDICATES_1_2),
- ('3.2', 'openshift-enterprise', DEFAULT_PREDICATES_1_2),
- ('1.3', 'origin', DEFAULT_PREDICATES_1_3),
- ('3.3', 'openshift-enterprise', DEFAULT_PREDICATES_1_3),
- ('1.4', 'origin', DEFAULT_PREDICATES_1_4),
- ('3.4', 'openshift-enterprise', DEFAULT_PREDICATES_1_4)
- ]
+ def check_defaults_override_vars(self, release, deployment_type,
+ default_predicates, regions_enabled,
+ extra_facts=None):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ if extra_facts is not None:
+ for fact in extra_facts:
+ facts[fact] = extra_facts[fact]
+ results = self.lookup.run(None, variables=facts,
+ regions_enabled=regions_enabled,
+ return_set_vars=False)
+ if regions_enabled:
+ assert_equal(results, default_predicates + [REGION_PREDICATE])
+ else:
+ assert_equal(results, default_predicates)
+ def test_openshift_version(self):
for regions_enabled in (True, False):
- for release, deployment_type, default_predicates in test_vars:
- for prepend_v in (True, False):
- if prepend_v:
- release = 'v' + release
- yield self.check_defaults, release, deployment_type, default_predicates, regions_enabled, False
+ for release, deployment_type, default_predicates in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_version, release, deployment_type, default_predicates, regions_enabled
+
+ def test_v_release_defaults(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_release, 'v' + release, deployment_type, default_predicates, regions_enabled
+
+ def test_release_defaults(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_release, release, deployment_type, default_predicates, regions_enabled
def test_short_version_defaults(self):
- test_vars = [
- ('1.1', 'origin', DEFAULT_PREDICATES_1_1),
- ('3.1', 'openshift-enterprise', DEFAULT_PREDICATES_1_1),
- ('1.2', 'origin', DEFAULT_PREDICATES_1_2),
- ('3.2', 'openshift-enterprise', DEFAULT_PREDICATES_1_2),
- ('1.3', 'origin', DEFAULT_PREDICATES_1_3),
- ('3.3', 'openshift-enterprise', DEFAULT_PREDICATES_1_3),
- ('1.4', 'origin', DEFAULT_PREDICATES_1_4),
- ('3.4', 'openshift-enterprise', DEFAULT_PREDICATES_1_4)
- ]
for regions_enabled in (True, False):
- for short_version, deployment_type, default_predicates in test_vars:
- yield self.check_defaults, short_version, deployment_type, default_predicates, regions_enabled, True
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_short_version, release, deployment_type, default_predicates, regions_enabled
+
+ def test_short_version_kwarg(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_short_version_kwarg, release, deployment_type, default_predicates, regions_enabled
+
+ def test_only_kwargs(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_only_kwargs, release, deployment_type, default_predicates, regions_enabled
+
+ def test_deployment_type_kwarg(self):
+ for regions_enabled in (True, False):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ yield self.check_defaults_deployment_type_kwarg, release, deployment_type, default_predicates, regions_enabled
+
+ def test_trunc_openshift_release(self):
+ for release, deployment_type, default_predicates in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_release, release, deployment_type, default_predicates, False
@raises(AnsibleError)
def test_unknown_deployment_types(self):
@@ -133,42 +222,26 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
self.lookup.run(None, variables=facts)
@raises(AnsibleError)
- def test_missing_deployment_type(self):
+ def test_unknown_origin_version(self):
facts = copy.deepcopy(self.default_facts)
- facts['openshift']['common']['short_version'] = '10.10'
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'origin'
self.lookup.run(None, variables=facts)
@raises(AnsibleError)
- def testMissingOpenShiftFacts(self):
- facts = {}
+ def test_unknown_ocp_version(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
self.lookup.run(None, variables=facts)
@raises(AnsibleError)
- def testMissingMasterRole(self):
- facts = {'openshift': {}}
+ def test_missing_deployment_type(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '10.10'
self.lookup.run(None, variables=facts)
- def testPreExistingPredicates(self):
- facts = {
- 'openshift': {
- 'master': {
- 'scheduler_predicates': [
- {'name': 'pred_a'},
- {'name': 'pred_b'}
- ]
- }
- }
- }
- result = self.lookup.run(None, variables=facts)
- assert_equal(result, facts['openshift']['master']['scheduler_predicates'])
-
- def testDefinedPredicates(self):
- facts = {
- 'openshift': {'master': {}},
- 'openshift_master_scheduler_predicates': [
- {'name': 'pred_a'},
- {'name': 'pred_b'}
- ]
- }
- result = self.lookup.run(None, variables=facts)
- assert_equal(result, facts['openshift_master_scheduler_predicates'])
+ @raises(AnsibleError)
+ def testMissingOpenShiftFacts(self):
+ facts = {}
+ self.lookup.run(None, variables=facts)
diff --git a/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py b/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
index d63f06904..5427a07a1 100644
--- a/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
+++ b/roles/openshift_master_facts/test/openshift_master_facts_default_priorities_tests.py
@@ -50,13 +50,23 @@ ZONE_PRIORITY = {
'weight': 2
}
+TEST_VARS = [
+ ('1.1', 'origin', DEFAULT_PRIORITIES_1_1),
+ ('3.1', 'openshift-enterprise', DEFAULT_PRIORITIES_1_1),
+ ('1.2', 'origin', DEFAULT_PRIORITIES_1_2),
+ ('3.2', 'openshift-enterprise', DEFAULT_PRIORITIES_1_2),
+ ('1.3', 'origin', DEFAULT_PRIORITIES_1_3),
+ ('3.3', 'openshift-enterprise', DEFAULT_PRIORITIES_1_3),
+ ('1.4', 'origin', DEFAULT_PRIORITIES_1_4),
+ ('3.4', 'openshift-enterprise', DEFAULT_PRIORITIES_1_4)
+]
+
class TestOpenShiftMasterFactsDefaultPredicates(object):
def setUp(self):
self.lookup = LookupModule()
self.default_facts = {
'openshift': {
- 'master': {},
'common': {}
}
}
@@ -67,13 +77,68 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
facts['openshift']['common']['deployment_type'] = 'origin'
self.lookup.run(None, variables=facts)
- def check_defaults(self, release, deployment_type, default_priorities,
- zones_enabled, short_version):
+ def check_defaults_short_version(self, release, deployment_type,
+ default_priorities, zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def check_defaults_short_version_kwarg(self, release, deployment_type,
+ default_priorities, zones_enabled):
facts = copy.deepcopy(self.default_facts)
- if short_version:
- facts['openshift']['common']['short_version'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts,
+ zones_enabled=zones_enabled,
+ short_version=release)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
else:
- facts['openshift_release'] = release
+ assert_equal(results, default_priorities)
+
+ def check_defaults_deployment_type_kwarg(self, release, deployment_type,
+ default_priorities, zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = release
+ results = self.lookup.run(None, variables=facts,
+ zones_enabled=zones_enabled,
+ deployment_type=deployment_type)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def check_defaults_only_kwargs(self, release, deployment_type,
+ default_priorities, zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ results = self.lookup.run(None, variables=facts,
+ zones_enabled=zones_enabled,
+ short_version=release,
+ deployment_type=deployment_type)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def check_defaults_release(self, release, deployment_type, default_priorities,
+ zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_release'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def check_defaults_version(self, release, deployment_type, default_priorities,
+ zones_enabled):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift_version'] = release
facts['openshift']['common']['deployment_type'] = deployment_type
results = self.lookup.run(None, variables=facts, zones_enabled=zones_enabled)
if zones_enabled:
@@ -81,39 +146,78 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
else:
assert_equal(results, default_priorities)
- def test_openshift_release_defaults(self):
- test_vars = [
- ('1.1', 'origin', DEFAULT_PRIORITIES_1_1),
- ('3.1', 'openshift-enterprise', DEFAULT_PRIORITIES_1_1),
- ('1.2', 'origin', DEFAULT_PRIORITIES_1_2),
- ('3.2', 'openshift-enterprise', DEFAULT_PRIORITIES_1_2),
- ('1.3', 'origin', DEFAULT_PRIORITIES_1_3),
- ('3.3', 'openshift-enterprise', DEFAULT_PRIORITIES_1_3),
- ('1.4', 'origin', DEFAULT_PRIORITIES_1_4),
- ('3.4', 'openshift-enterprise', DEFAULT_PRIORITIES_1_4)
- ]
+ def check_defaults_override_vars(self, release, deployment_type,
+ default_priorities, zones_enabled,
+ extra_facts=None):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = release
+ facts['openshift']['common']['deployment_type'] = deployment_type
+ if extra_facts is not None:
+ for fact in extra_facts:
+ facts[fact] = extra_facts[fact]
+ results = self.lookup.run(None, variables=facts,
+ zones_enabled=zones_enabled,
+ return_set_vars=False)
+ if zones_enabled:
+ assert_equal(results, default_priorities + [ZONE_PRIORITY])
+ else:
+ assert_equal(results, default_priorities)
+
+ def test_openshift_version(self):
+ for zones_enabled in (True, False):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_version, release, deployment_type, default_priorities, zones_enabled
+
+ def test_v_release_defaults(self):
+ for zones_enabled in (True, False):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ release = 'v' + release
+ yield self.check_defaults_release, release, deployment_type, default_priorities, zones_enabled
+ def test_release_defaults(self):
for zones_enabled in (True, False):
- for release, deployment_type, default_priorities in test_vars:
- for prepend_v in (True, False):
- if prepend_v:
- release = 'v' + release
- yield self.check_defaults, release, deployment_type, default_priorities, zones_enabled, False
+ for release, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_release, release, deployment_type, default_priorities, zones_enabled
def test_short_version_defaults(self):
- test_vars = [
- ('1.1', 'origin', DEFAULT_PRIORITIES_1_1),
- ('3.1', 'openshift-enterprise', DEFAULT_PRIORITIES_1_1),
- ('1.2', 'origin', DEFAULT_PRIORITIES_1_2),
- ('3.2', 'openshift-enterprise', DEFAULT_PRIORITIES_1_2),
- ('1.3', 'origin', DEFAULT_PRIORITIES_1_3),
- ('3.3', 'openshift-enterprise', DEFAULT_PRIORITIES_1_3),
- ('1.4', 'origin', DEFAULT_PRIORITIES_1_4),
- ('3.4', 'openshift-enterprise', DEFAULT_PRIORITIES_1_4)
- ]
for zones_enabled in (True, False):
- for short_version, deployment_type, default_priorities in test_vars:
- yield self.check_defaults, short_version, deployment_type, default_priorities, zones_enabled, True
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_short_version, short_version, deployment_type, default_priorities, zones_enabled
+
+ def test_only_kwargs(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_only_kwargs, short_version, deployment_type, default_priorities, zones_enabled
+
+ def test_deployment_type_kwarg(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_deployment_type_kwarg, short_version, deployment_type, default_priorities, zones_enabled
+
+ def test_release_kwarg(self):
+ for zones_enabled in (True, False):
+ for short_version, deployment_type, default_priorities in TEST_VARS:
+ yield self.check_defaults_short_version_kwarg, short_version, deployment_type, default_priorities, zones_enabled
+
+ def test_trunc_openshift_release(self):
+ for release, deployment_type, default_priorities in TEST_VARS:
+ release = release + '.1'
+ yield self.check_defaults_release, release, deployment_type, default_priorities, False
+
+ @raises(AnsibleError)
+ def test_unknown_origin_version(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'origin'
+ self.lookup.run(None, variables=facts)
+
+ @raises(AnsibleError)
+ def test_unknown_ocp_version(self):
+ facts = copy.deepcopy(self.default_facts)
+ facts['openshift']['common']['short_version'] = '0.1'
+ facts['openshift']['common']['deployment_type'] = 'openshift-enterprise'
+ self.lookup.run(None, variables=facts)
@raises(AnsibleError)
def test_unknown_deployment_types(self):
@@ -132,33 +236,3 @@ class TestOpenShiftMasterFactsDefaultPredicates(object):
def test_missing_openshift_facts(self):
facts = {}
self.lookup.run(None, variables=facts)
-
- @raises(AnsibleError)
- def test_missing_master_role(self):
- facts = {'openshift': {}}
- self.lookup.run(None, variables=facts)
-
- def test_pre_existing_priorities(self):
- facts = {
- 'openshift': {
- 'master': {
- 'scheduler_priorities': [
- {'name': 'pri_a', 'weight': 1},
- {'name': 'pri_b', 'weight': 1}
- ]
- }
- }
- }
- result = self.lookup.run(None, variables=facts)
- assert_equal(result, facts['openshift']['master']['scheduler_priorities'])
-
- def testDefinedPredicates(self):
- facts = {
- 'openshift': {'master': {}},
- 'openshift_master_scheduler_priorities': [
- {'name': 'pri_a', 'weight': 1},
- {'name': 'pri_b', 'weight': 1}
- ]
- }
- result = self.lookup.run(None, variables=facts)
- assert_equal(result, facts['openshift_master_scheduler_priorities'])
diff --git a/roles/openshift_node/tasks/main.yml b/roles/openshift_node/tasks/main.yml
index b8d0b6130..e970c4cd1 100644
--- a/roles/openshift_node/tasks/main.yml
+++ b/roles/openshift_node/tasks/main.yml
@@ -44,6 +44,8 @@
- name: Check for tuned package
command: rpm -q tuned
+ args:
+ warn: no
register: tuned_installed
changed_when: false
failed_when: false
diff --git a/utils/.coveragerc b/utils/.coveragerc
new file mode 100644
index 000000000..0c870af42
--- /dev/null
+++ b/utils/.coveragerc
@@ -0,0 +1,4 @@
+[run]
+omit=
+ */lib/python*/site-packages/*
+ /usr/*
diff --git a/utils/Makefile b/utils/Makefile
index ee6b885e6..49c61e115 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -59,13 +59,18 @@ docs: $(MANPAGES)
viewcover:
xdg-open cover/index.html
-virtualenv:
+# Conditional virtualenv building strategy taken from this great post
+# by Marcel Hellkamp:
+# http://blog.bottlepy.org/2012/07/16/virtualenv-and-makefiles.html
+venv: oo-installenv/bin/activate
+oo-installenv/bin/activate: test-requirements.txt
@echo "#############################################"
@echo "# Creating a virtualenv"
@echo "#############################################"
- virtualenv $(NAME)env
+ test -d venv || virtualenv $(NAME)env
. $(NAME)env/bin/activate && pip install setuptools==17.1.1
. $(NAME)env/bin/activate && pip install -r test-requirements.txt
+ touch $(NAME)env/bin/activate
# If there are any special things to install do it here
# . $(NAME)env/bin/activate && INSTALL STUFF
@@ -73,14 +78,14 @@ ci-unittests:
@echo "#############################################"
@echo "# Running Unit Tests in virtualenv"
@echo "#############################################"
- . $(NAME)env/bin/activate && python setup.py nosetests
+ . $(NAME)env/bin/activate && python setup.py nosetests --cover-erase
@echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'"
ci-pylint:
@echo "#############################################"
@echo "# Running PyLint Tests in virtualenv"
@echo "#############################################"
- . $(NAME)env/bin/activate && python -m pylint --rcfile ../git/.pylintrc $(shell find ../ -name $(NAME)env -prune -o -name test -prune -o -name "*.py" -print)
+ . $(NAME)env/bin/activate && python -m pylint --rcfile ../git/.pylintrc $(shell find ../ -name $(NAME)env -prune -o -name test -prune -o -name "*.py" -print) 2>&1 | grep -E -v '(locally-disabled|file-ignored)'
ci-list-deps:
@echo "#############################################"
@@ -93,7 +98,11 @@ ci-flake8:
@echo "# Running Flake8 Compliance Tests in virtualenv"
@echo "#############################################"
. $(NAME)env/bin/activate && flake8 --config=setup.cfg ../ --exclude="utils,../inventory"
- . $(NAME)env/bin/activate && python setup.py flake8
+ . $(NAME)env/bin/activate && python setup.py flake8
-ci: clean virtualenv ci-list-deps ci-flake8 ci-pylint ci-unittests
- :
+ci: venv ci-list-deps ci-unittests ci-flake8 ci-pylint
+ @echo
+ @echo "##################################################################################"
+ @echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'"
+ @echo "To clean your test environment run 'make clean'"
+ @echo "Other targets you may run with 'make': 'ci-pylint', 'ci-unittests', 'ci-flake8'"
diff --git a/utils/setup.cfg b/utils/setup.cfg
index f5f0d8aad..18b4e3057 100644
--- a/utils/setup.cfg
+++ b/utils/setup.cfg
@@ -7,10 +7,12 @@ universal=1
[nosetests]
tests=../,../roles/openshift_master_facts/test/,test/
verbosity=2
-with_coverage=1
-cover_html=1
-cover_package=ooinstall
-cover_min_percentage=70
+with-coverage=1
+cover-html=1
+cover-inclusive=1
+cover-min-percentage=70
+detailed-errors=1
+cover-branches=1
[flake8]
max-line-length=120