From 78dd487871796a71c450a1a1daf78b079a3a1090 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Thu, 16 Jun 2016 14:27:20 -0300 Subject: Cleanup, fix 3.1 version bug in facts. --- .../upgrades/v3_1_to_v3_2/pre.yml | 5 ++--- .../upgrades/v3_1_to_v3_2/rpm_upgrade.yml | 2 +- roles/openshift_facts/library/openshift_facts.py | 23 +++++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml index a5a9a0fec..e5a1d30f7 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/pre.yml @@ -206,10 +206,9 @@ g_docker_version: "{{ g_atomic_docker_version_result.stdout | from_yaml }}" when: openshift.common.is_atomic | bool - # TODO: Update to 1.10 once branch merges - fail: - msg: This playbook requires access to Docker 1.9 or later - when: g_docker_version.avail_version | default(g_docker_version.curr_version, true) | version_compare('1.9','<') + msg: This playbook requires access to Docker 1.10 or later + when: g_docker_version.avail_version | default(g_docker_version.curr_version, true) | version_compare('1.10','<') # TODO: add check to upgrade ostree to get latest Docker diff --git a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml index ea27a40d1..1d97d3802 100644 --- a/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml +++ b/playbooks/common/openshift-cluster/upgrades/v3_1_to_v3_2/rpm_upgrade.yml @@ -1,4 +1,4 @@ -# TODO: Use a specific version here once we're setting openshift_pkg_version reliably in the openshift_version module. +# We verified latest rpm available is suitable, so just yum update. - name: Upgrade packages command: "{{ ansible_pkg_mgr}} update -y {{ openshift.common.service_type }}-{{ component }}" diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index eb6369f50..a979639f8 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1113,7 +1113,9 @@ def get_docker_version_info(): return result def get_openshift_version(facts): - """ Get current version of openshift on the host + """ Get current version of openshift on the host. + + Checks a variety of ways ranging from fastest to slowest. Args: facts (dict): existing facts @@ -1139,18 +1141,17 @@ def get_openshift_version(facts): elif 'common' in facts and 'is_containerized' in facts['common']: version = get_containerized_node_openshift_version(facts) + # Handle containerized masters that have not yet been configured as a node. + # This can be very slow and may get re-run multiple times, so we only use this + # if other methods failed to find a version. + if not version and os.path.isfile('/usr/local/bin/openshift'): + _, output, _ = module.run_command(['/usr/local/bin/openshift', 'version']) + version = parse_openshift_version(output) + return version -def get_containerized_node_openshift_version(facts): - node_svc = "%s-node" % facts['common']['service_type'] - rc, _, _ = module.run_command(['systemctl', 'is-active', node_svc]) - if rc > 0: - # Node service not running or doesn't exist: - return None - # Node service running, exec in and get the version: - _, output, _ = module.run_command(['docker', 'exec', '-ti', node_svc, 'openshift', 'version']) - return parse_openshift_version(output) +def get_containerized_node_openshift_version(facts): # If containerized, see if we can determine the installed version via the systemd environment files: node_env = '/etc/sysconfig/%s-node' % facts['common']['service_type'] if not os.path.exists(node_env): @@ -1167,8 +1168,6 @@ def get_containerized_node_openshift_version(facts): return None - - def parse_openshift_version(output): """ Apply provider facts to supplied facts dict -- cgit v1.2.3