From 8e070a769c240f50331cc3fdda72594d66142155 Mon Sep 17 00:00:00 2001 From: Patrick Dillon Date: Mon, 15 Oct 2018 16:04:03 -0400 Subject: [PATCH 1/2] Use openshift_cli_image to find version in openshift_facts when containerized. Code review. --- playbooks/init/cluster_facts.yml | 1 + roles/openshift_facts/library/openshift_facts.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/playbooks/init/cluster_facts.yml b/playbooks/init/cluster_facts.yml index a7ba20dc54a..7fc0562b005 100644 --- a/playbooks/init/cluster_facts.yml +++ b/playbooks/init/cluster_facts.yml @@ -21,6 +21,7 @@ https_proxy: "{{ openshift_https_proxy | default(None) }}" no_proxy: "{{ openshift_no_proxy | default(None) }}" generate_no_proxy_hosts: "{{ openshift_generate_no_proxy_hosts | default(True) }}" + openshift_cli_image: "{{ openshift_cli_image }}" - name: Set fact of no_proxy_internal_hostnames openshift_facts: diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index c1968987c0e..012481aa642 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -848,8 +848,6 @@ def get_openshift_version(facts): version: the current openshift version """ version = None - image_type_dict = {'origin': 'openshift/origin', - 'openshift-enterprise': 'openshift3/ose'} # No need to run this method repeatedly on a system if we already know the # version @@ -866,7 +864,12 @@ def get_openshift_version(facts): image_tag = get_container_openshift_version(deployment_type) if image_tag is None: return version - cli_image = image_type_dict[deployment_type] + ":" + image_tag + + openshift_cli_image = facts['common'].get('openshift_cli_image') + if not openshift_cli_image: + return version + + cli_image = openshift_cli_image + ":" + image_tag _, output, _ = module.run_command(['docker', 'run', '--rm', cli_image, 'version']) # noqa: F405 version = parse_openshift_version(output) From 584927dfadf1f443e05c377588c38b7ff47845d8 Mon Sep 17 00:00:00 2001 From: Patrick Dillon Date: Mon, 15 Oct 2018 16:14:57 -0400 Subject: [PATCH 2/2] Remove empty function set_container_facts_if_unset. --- roles/openshift_facts/library/openshift_facts.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 012481aa642..4fb8f69e807 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1247,20 +1247,6 @@ def set_buildoverrides_facts(facts): return facts -# pylint: disable=too-many-statements -def set_container_facts_if_unset(facts): - """ Set containerized facts. - - Args: - facts (dict): existing facts - Returns: - dict: the facts dict updated with the generated containerization - facts - """ - - return facts - - def pop_obsolete_local_facts(local_facts): """Remove unused keys from local_facts""" keys_to_remove = { @@ -1382,7 +1368,6 @@ def generate_facts(self, facts = set_identity_providers_if_unset(facts) facts = set_deployment_facts_if_unset(facts) facts = set_sdn_facts_if_unset(facts, self.system_facts) - facts = set_container_facts_if_unset(facts) facts = build_controller_args(facts) facts = build_api_server_args(facts) facts = set_version_facts_if_unset(facts)