diff options
-rw-r--r-- | git/.pylintrc | 11 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/etcd/backup.yml | 12 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/etcd/main.yml | 111 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/etcd/upgrade.yml | 94 | ||||
-rw-r--r-- | playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml | 5 | ||||
-rw-r--r-- | utils/Makefile | 37 | ||||
-rw-r--r-- | utils/setup.cfg | 1 |
7 files changed, 140 insertions, 131 deletions
diff --git a/git/.pylintrc b/git/.pylintrc index fe6eef6de..9c98889b3 100644 --- a/git/.pylintrc +++ b/git/.pylintrc @@ -71,7 +71,7 @@ confidence= # no Warning level messages displayed, use"--disable=all --enable=classes # --disable=W" # w0511 - fixme - disabled because TODOs are acceptable -disable=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1636,W0511,R0801 +disable=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1636,W0511,R0801,locally-disabled,file-ignored [REPORTS] @@ -79,7 +79,7 @@ disable=E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623, # Set the output format. Available formats are text, parseable, colorized, msvs # (visual studio) and html. You can also give a reporter class, eg # mypackage.mymodule.MyReporterClass. -output-format=text +output-format=parseable # Put messages in a separate file for each module / package specified on the # command line instead of printing them on stdout. Reports (if any) will be @@ -114,9 +114,6 @@ logging-modules=logging [BASIC] -# Required attributes for module, separated by a comma -required-attributes= - # List of builtins function names that should not be used, separated by a comma bad-functions=map,filter,input @@ -348,10 +345,6 @@ max-public-methods=20 [CLASSES] -# List of interface methods to ignore, separated by a comma. This is used for -# instance to not check methods defines in Zope's Interface base class. -ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by - # List of method names used to declare (i.e. assign) instance attributes. defining-attr-methods=__init__,__new__,setUp diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml index cfb273b82..691961382 100644 --- a/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml +++ b/playbooks/common/openshift-cluster/upgrades/etcd/backup.yml @@ -41,11 +41,15 @@ {{ avail_disk.stdout }} Kb available. when: (embedded_etcd | bool) and (etcd_disk_usage.stdout|int > avail_disk.stdout|int) - # 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 + # TODO - Refactor containerized backup to use etcd_container to backup the data so we don't rely on + # the host's etcdctl binary which may be of a different version. + + # for non containerized and non embedded we should have the correct version of etcd installed already + # For embedded we need to use the latest because OCP 3.3 uses a version of etcd that can only be backed + # up with etcd-3.x + - name: Install latest etcd for containerized or embedded package: name=etcd state=latest - when: not openshift.common.is_atomic | bool and openshift.common.is_containerized + when: ( openshift.common.is_containerized and not openshift.common.is_atomic ) or embedded_etcd | bool - 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 c67cf282f..8268adc2e 100644 --- a/playbooks/common/openshift-cluster/upgrades/etcd/main.yml +++ b/playbooks/common/openshift-cluster/upgrades/etcd/main.yml @@ -9,119 +9,36 @@ tags: - always -- name: Evaluate additional groups for upgrade +# We use two groups one for hosts we're upgrading which doesn't include embedded etcd +# The other for backing up which includes the embedded etcd host, there's no need to +# upgrade embedded etcd that just happens when the master is updated. +- name: Evaluate additional groups for etcd hosts: localhost connection: local become: no tasks: - - fail: - msg: 'The etcd upgrade playbook does not support upgrading embedded etcd, simply run the normal playbooks and etcd will be upgraded when your master is updated.' - when: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}" - name: Evaluate etcd_hosts_to_upgrade add_host: name: "{{ item }}" - groups: etcd_hosts_to_upgrade, etcd_hosts_to_backup + groups: etcd_hosts_to_upgrade + with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else [] }}" + - name: Evaluate etcd_hosts_to_backup + add_host: + name: "{{ item }}" + groups: etcd_hosts_to_backup with_items: "{{ groups.oo_etcd_to_config if groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config | length > 0 else groups.oo_first_master }}" - name: Backup etcd before upgrading anything include: backup.yml vars: backup_tag: "pre-upgrade-" + when: openshift_etcd_backup | default(true) | bool - name: Drop etcdctl profiles hosts: etcd_hosts_to_upgrade tasks: - include: roles/etcd/tasks/etcdctl.yml -- name: Determine etcd version - hosts: etcd_hosts_to_upgrade - tasks: - - name: Record RPM based etcd version - command: rpm -qa --qf '%{version}' etcd\* - 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_container_version - failed_when: false - when: openshift.common.is_containerized | bool - -# I really dislike this copy/pasta but I wasn't able to find a way to get it to loop -# through hosts, then loop through tasks only when appropriate -- name: Upgrade to 2.1 - hosts: etcd_hosts_to_upgrade - serial: 1 - vars: - upgrade_version: '2.1' - tasks: - - include: rhel_tasks.yml - 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 - serial: 1 - vars: - upgrade_version: '2.2' - tasks: - - include: rhel_tasks.yml - 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 - serial: 1 - vars: - upgrade_version: 2.2.5 - tasks: - - include: containerized_tasks.yml - 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 - serial: 1 - vars: - upgrade_version: '2.3' - tasks: - - include: rhel_tasks.yml - 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 - serial: 1 - vars: - upgrade_version: 2.3.7 - tasks: - - include: containerized_tasks.yml - 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 - serial: 1 - vars: - upgrade_version: '3.0' - tasks: - - include: rhel_tasks.yml - 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.14 - tasks: - - include: containerized_tasks.yml - 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 - serial: 1 - tasks: - - include: fedora_tasks.yml - when: ansible_distribution == 'Fedora' and not openshift.common.is_containerized | bool - -- name: Backup etcd - include: backup.yml - vars: - backup_tag: "post-3.0-" +- name: Perform etcd upgrade + include: ./upgrade.yml + when: openshift_etcd_upgrade | default(true) | bool diff --git a/playbooks/common/openshift-cluster/upgrades/etcd/upgrade.yml b/playbooks/common/openshift-cluster/upgrades/etcd/upgrade.yml new file mode 100644 index 000000000..5ff9521ec --- /dev/null +++ b/playbooks/common/openshift-cluster/upgrades/etcd/upgrade.yml @@ -0,0 +1,94 @@ +--- +- name: Determine etcd version + hosts: etcd_hosts_to_upgrade + tasks: + - name: Record RPM based etcd version + command: rpm -qa --qf '%{version}' etcd\* + 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_container_version + failed_when: false + when: openshift.common.is_containerized | bool + +# I really dislike this copy/pasta but I wasn't able to find a way to get it to loop +# through hosts, then loop through tasks only when appropriate +- name: Upgrade to 2.1 + hosts: etcd_hosts_to_upgrade + serial: 1 + vars: + upgrade_version: '2.1' + tasks: + - include: rhel_tasks.yml + 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 + serial: 1 + vars: + upgrade_version: '2.2' + tasks: + - include: rhel_tasks.yml + 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 + serial: 1 + vars: + upgrade_version: 2.2.5 + tasks: + - include: containerized_tasks.yml + 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 + serial: 1 + vars: + upgrade_version: '2.3' + tasks: + - include: rhel_tasks.yml + 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 + serial: 1 + vars: + upgrade_version: 2.3.7 + tasks: + - include: containerized_tasks.yml + 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 + serial: 1 + vars: + upgrade_version: '3.0' + tasks: + - include: rhel_tasks.yml + 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.14 + tasks: + - include: containerized_tasks.yml + 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 + serial: 1 + tasks: + - include: fedora_tasks.yml + when: ansible_distribution == 'Fedora' and not openshift.common.is_containerized | bool + +- name: Backup etcd + include: backup.yml + vars: + backup_tag: "post-3.0-" + when: openshift_etcd_backup | default(true) | bool diff --git a/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml b/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml index f74ea9820..474e6311e 100644 --- a/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml +++ b/playbooks/common/openshift-cluster/upgrades/upgrade_control_plane.yml @@ -27,9 +27,8 @@ embedded_etcd: "{{ groups.oo_etcd_to_config | default([]) | length == 0 }}" debug_level: "{{ openshift_master_debug_level | default(openshift.common.debug_level | default(2)) }}" -- name: Backup etcd - include: ./etcd/backup.yml - when: openshift_upgrade_skip_etcd_backup | default(false) | bool +- name: Upgrade and backup etcd + include: ./etcd/main.yml - name: Upgrade master packages hosts: oo_masters_to_config diff --git a/utils/Makefile b/utils/Makefile index 49c61e115..ad6735cb5 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -22,6 +22,7 @@ NAME := oo-install +VENV := $(NAME)env TESTPACKAGE := oo-install SHORTNAME := ooinstall @@ -39,7 +40,7 @@ clean: @find . -type f -regex ".*\.py[co]$$" -delete @find . -type f \( -name "*~" -or -name "#*" \) -delete @rm -fR build dist rpm-build MANIFEST htmlcov .coverage cover ooinstall.egg-info oo-install - @rm -fR $(NAME)env + @rm -fR $(VENV) # To force a rebuild of the docs run 'touch' on any *.in file under @@ -62,45 +63,45 @@ viewcover: # 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 +$(VENV): $(VENV)/bin/activate +$(VENV)/bin/activate: test-requirements.txt @echo "#############################################" @echo "# Creating a virtualenv" @echo "#############################################" - 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 + test -d $(VENV) || virtualenv $(VENV) + . $(VENV)/bin/activate && pip install setuptools==17.1.1 + . $(VENV)/bin/activate && pip install -r test-requirements.txt + touch $(VENV)/bin/activate # If there are any special things to install do it here -# . $(NAME)env/bin/activate && INSTALL STUFF +# . $(VENV)/bin/activate && INSTALL STUFF -ci-unittests: +ci-unittests: $(VENV) @echo "#############################################" @echo "# Running Unit Tests in virtualenv" @echo "#############################################" - . $(NAME)env/bin/activate && python setup.py nosetests --cover-erase + . $(VENV)/bin/activate && python setup.py nosetests @echo "VIEW CODE COVERAGE REPORT WITH 'xdg-open cover/index.html' or run 'make viewcover'" -ci-pylint: +ci-pylint: $(VENV) @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) 2>&1 | grep -E -v '(locally-disabled|file-ignored)' + . $(VENV)/bin/activate && python -m pylint --rcfile ../git/.pylintrc $(shell find ../ -name $(VENV) -prune -o -name ooinstall.egg-info -prune -o -name test -prune -o -name "*.py" -print) -ci-list-deps: +ci-list-deps: $(VENV) @echo "#############################################" @echo "# Listing all pip deps" @echo "#############################################" - . $(NAME)env/bin/activate && pip freeze + . $(VENV)/bin/activate && pip freeze -ci-flake8: +ci-flake8: $(VENV) @echo "#############################################" @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 + . $(VENV)/bin/activate && flake8 --config=setup.cfg ../ --exclude="utils,../inventory" + . $(VENV)/bin/activate && python setup.py flake8 -ci: venv ci-list-deps ci-unittests ci-flake8 ci-pylint +ci: 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'" diff --git a/utils/setup.cfg b/utils/setup.cfg index 18b4e3057..ee3288fc5 100644 --- a/utils/setup.cfg +++ b/utils/setup.cfg @@ -11,6 +11,7 @@ with-coverage=1 cover-html=1 cover-inclusive=1 cover-min-percentage=70 +cover-erase=1 detailed-errors=1 cover-branches=1 |