From 895a55c23fb7ae202ed3d6b4660f5e37410b05f2 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 11 Apr 2016 16:38:52 -0300 Subject: Fix legacy cli_docker_* vars not migrating. No hosts were matching this renamed host group, so the oo_lookup module was not being triggered to migrate these to their new openshift_docker prefix. --- playbooks/common/openshift-cluster/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playbooks/common/openshift-cluster/config.yml b/playbooks/common/openshift-cluster/config.yml index 6f908fa7f..99b36098a 100644 --- a/playbooks/common/openshift-cluster/config.yml +++ b/playbooks/common/openshift-cluster/config.yml @@ -4,7 +4,7 @@ - include: validate_hostnames.yml - name: Set oo_options - hosts: oo_hosts_to_config + hosts: oo_all_hosts tasks: - set_fact: openshift_docker_additional_registries: "{{ lookup('oo_option', 'docker_additional_registries') }}" -- cgit v1.2.3 From b0e43e87b132594bc370419085000b6d6c54cdc6 Mon Sep 17 00:00:00 2001 From: Devan Goodwin Date: Mon, 11 Apr 2016 16:43:05 -0300 Subject: Use a JSON list for docker log options. Previously we expected you to comma separate, but this wasn't really clear. Insted we will use an explicit JSON list going forward. The comma separated list will be supported for backwards compatability. --- filter_plugins/oo_filters.py | 5 ++++- inventory/byo/hosts.aep.example | 2 +- inventory/byo/hosts.origin.example | 2 +- inventory/byo/hosts.ose.example | 2 +- roles/openshift_facts/library/openshift_facts.py | 13 ++++++++++++- 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 57c14e9a3..3da4562ac 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -259,8 +259,11 @@ class FilterModule(object): @staticmethod def oo_split(string, separator=','): - """ This splits the input string into a list + """ This splits the input string into a list. If the input string is + already a list we will return it as is. """ + if isinstance(string, list): + return string return string.split(separator) @staticmethod diff --git a/inventory/byo/hosts.aep.example b/inventory/byo/hosts.aep.example index c3f551401..7c98ddcd6 100644 --- a/inventory/byo/hosts.aep.example +++ b/inventory/byo/hosts.aep.example @@ -75,7 +75,7 @@ deployment_type=atomic-enterprise #openshift_docker_options="-l warn --ipv6=false" # Deprecated methods to set --log-driver and --log-opts flags, use openshift_docker_options instead #openshift_docker_log_driver=json -#openshift_docker_log_options="tag=mailer" +#openshift_docker_log_options=["tag=mailer"] # Alternate image format string. If you're not modifying the format string and # only need to inject your own registry you may want to consider diff --git a/inventory/byo/hosts.origin.example b/inventory/byo/hosts.origin.example index caed1c6a1..ad5c77ac6 100644 --- a/inventory/byo/hosts.origin.example +++ b/inventory/byo/hosts.origin.example @@ -76,7 +76,7 @@ deployment_type=origin #openshift_docker_options="-l warn --ipv6=false" # Deprecated methods to set --log-driver and --log-opts flags, use openshift_docker_options instead #openshift_docker_log_driver=json -#openshift_docker_log_options="tag=mailer" +#openshift_docker_log_options=["tag=mailer"] # Alternate image format string. If you're not modifying the format string and # only need to inject your own registry you may want to consider diff --git a/inventory/byo/hosts.ose.example b/inventory/byo/hosts.ose.example index 557e7d8aa..7c0c71484 100644 --- a/inventory/byo/hosts.ose.example +++ b/inventory/byo/hosts.ose.example @@ -75,7 +75,7 @@ deployment_type=openshift-enterprise #openshift_docker_options="-l warn --ipv6=false" # Deprecated methods to set --log-driver and --log-opts flags, use openshift_docker_options instead #openshift_docker_log_driver=json -#openshift_docker_log_options="tag=mailer" +#openshift_docker_log_options=["tag=mailer"] # Alternate image format string. If you're not modifying the format string and diff --git a/roles/openshift_facts/library/openshift_facts.py b/roles/openshift_facts/library/openshift_facts.py index f2d17293a..fe5fdd246 100755 --- a/roles/openshift_facts/library/openshift_facts.py +++ b/roles/openshift_facts/library/openshift_facts.py @@ -56,6 +56,13 @@ def migrate_docker_facts(facts): if 'node' in facts and 'portal_net' in facts['node']: facts['docker']['hosted_registry_insecure'] = True facts['docker']['hosted_registry_network'] = facts['node'].pop('portal_net') + + # log_options was originally meant to be a comma separated string, but + # we now prefer an actual list, with backward compatability: + if 'log_options' in facts['docker'] and \ + isinstance(facts['docker']['log_options'], basestring): + facts['docker']['log_options'] = facts['docker']['log_options'].split(",") + return facts # TODO: We should add a generic migration function that takes source and destination @@ -1852,6 +1859,10 @@ class OpenShiftFacts(object): if isinstance(val, basestring): val = [x.strip() for x in val.split(',')] new_local_facts['docker'][key] = list(set(val) - set([''])) + # Convert legacy log_options comma sep string to a list if present: + if 'log_options' in new_local_facts['docker'] and \ + isinstance(new_local_facts['docker']['log_options'], basestring): + new_local_facts['docker']['log_options'] = new_local_facts['docker']['log_options'].split(',') new_local_facts = self.remove_empty_facts(new_local_facts) @@ -1875,7 +1886,7 @@ class OpenShiftFacts(object): if isinstance(facts[fact], dict): facts[fact] = self.remove_empty_facts(facts[fact]) else: - if value == "" or value is None: + if value == "" or value == [""] or value is None: facts_to_remove.append(fact) for fact in facts_to_remove: del facts[fact] -- cgit v1.2.3