Skip to content

Commit

Permalink
Bug 1324728 - Ansible should not downgrade docker when installing 3.2…
Browse files Browse the repository at this point in the history
… containerized env
  • Loading branch information
brenton committed Apr 12, 2016
1 parent 8cd237c commit 94416d5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@
- include: docker_upgrade.yml
when: not openshift.common.is_atomic | bool

# The cli image is used by openshift_facts to determine the currently installed
# version. We need to explicitly pull the latest image to handle cases where
# the locally cached 'latest' tag is older the g_new_version.
- name: Download cli image
hosts: oo_masters_to_config:oo_nodes_to_config
roles:
- openshift_facts
tasks:
- name: Pull Images
command: >
docker pull {{ item }}:latest
with_items:
- "{{ openshift.common.cli_image }}"

###############################################################################
# Upgrade Masters
###############################################################################
Expand Down
17 changes: 10 additions & 7 deletions roles/openshift_facts/library/openshift_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,20 +1080,23 @@ def get_openshift_version(facts, cli_image=None):
elif 'node' in facts:
container = facts['common']['service_type'] + '-node'

if container is not None:
exit_code, output, _ = module.run_command(['docker', 'exec', container, 'openshift', 'version'])
# if for some reason the container is installed but not running
# we'll fall back to using docker run later in this method.
if exit_code == 0:
version = parse_openshift_version(output)

# Try to get the version fromthe available cli image _before_ resorting
# to exec'ing in to the running container. This is to be more fault
# tolerant in environments where the container is not running.
if version is None and cli_image is not None:
# Assume we haven't installed the environment yet and we need
# to query the latest image, but only if docker is installed
if 'docker' in facts and 'version' in facts['docker']:
exit_code, output, _ = module.run_command(['docker', 'run', '--rm', cli_image, 'version'])
version = parse_openshift_version(output)

if version is None and container is not None:
exit_code, output, _ = module.run_command(['docker', 'exec', container, 'openshift', 'version'])
# if for some reason the container is installed but not running
# we'll fall back to using docker run later in this method.
if exit_code == 0:
version = parse_openshift_version(output)

return version

def parse_openshift_version(output):
Expand Down

0 comments on commit 94416d5

Please sign in to comment.