diff options
author | Devan Goodwin <dgoodwin@redhat.com> | 2016-06-15 12:07:05 -0300 |
---|---|---|
committer | Devan Goodwin <dgoodwin@redhat.com> | 2016-06-15 12:07:05 -0300 |
commit | 5346266575045e1a42914e10249dc6e9874da7ec (patch) | |
tree | e083bf10ac5a4069c4f4dfa7abc131f416cb908c /roles/openshift_facts/library | |
parent | 739ad9de2a11bb8c67d77641a86cfd39e4594542 (diff) | |
download | openshift-5346266575045e1a42914e10249dc6e9874da7ec.tar.gz openshift-5346266575045e1a42914e10249dc6e9874da7ec.tar.bz2 openshift-5346266575045e1a42914e10249dc6e9874da7ec.tar.xz openshift-5346266575045e1a42914e10249dc6e9874da7ec.zip |
More stable containerized version lookup.
Diffstat (limited to 'roles/openshift_facts/library')
-rwxr-xr-x | roles/openshift_facts/library/openshift_facts.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index 97cca2e5c..eb6369f50 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -1133,7 +1133,10 @@ def get_openshift_version(facts): if os.path.isfile('/usr/bin/openshift'): _, output, _ = module.run_command(['/usr/bin/openshift', 'version']) version = parse_openshift_version(output) - elif 'node' in facts and 'common' in facts and 'is_containerized' in facts['common']: + # TODO: it probably makes more sense to read this from sysconfig service env files, + # these control the running versions when containerized, and would work even if the service + # is dead for some reason. + elif 'common' in facts and 'is_containerized' in facts['common']: version = get_containerized_node_openshift_version(facts) return version @@ -1148,6 +1151,23 @@ def get_containerized_node_openshift_version(facts): _, output, _ = module.run_command(['docker', 'exec', '-ti', node_svc, 'openshift', 'version']) return parse_openshift_version(output) + # 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): + return None + + with open(node_env) as f: + for line in f: + if line.startwith("IMAGE_VERSION="): + tag = line[len("IMAGE_VERSION="):] + # Remove leading "v" and any trailing release info, we just want + # a version number here: + version = tag[1:].split("-")[0] + return version + return None + + + def parse_openshift_version(output): """ Apply provider facts to supplied facts dict |