Skip to content

Commit 8a0fde1

Browse files
Merge pull request #7568 from mgugino-upstream-stage/fix-etcd-hosts-list-master
Remove etcd_hosts and etcd_urls from openshift_facts
2 parents 82887b1 + 352dd79 commit 8a0fde1

File tree

19 files changed

+76
-64
lines changed

19 files changed

+76
-64
lines changed

playbooks/init/cluster_facts.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,29 @@
4545
role: node
4646
local_facts:
4747
sdn_mtu: "{{ openshift_node_sdn_mtu | default(None) }}"
48+
49+
- name: Initialize etcd host variables
50+
hosts: oo_masters_to_config
51+
roles:
52+
- role: openshift_facts
53+
- role: lib_utils
54+
tasks:
55+
# This needs to run after openshift_facts common role has run on etcd hosts.
56+
# lib_utils_oo_select_keys, lib_utils_oo_collect
57+
# are custom filter plugins in roles/lib_utils/filter_plugins/oo_filters.py
58+
- set_fact:
59+
openshift_no_proxy_etcd_host_ips: "{{ hostvars | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
60+
| lib_utils_oo_collect('openshift.common.ip') | default([]) | join(',')
61+
}}"
62+
openshift_master_etcd_port: "{{ etcd_client_port | default('2379') }}"
63+
openshift_master_etcd_hosts: "{{ hostvars
64+
| lib_utils_oo_select_keys(groups['oo_etcd_to_config']
65+
| default([]))
66+
| lib_utils_oo_collect('openshift.common.hostname')
67+
| default(none, true) }}"
68+
# This fact requires the facts set above, so needs to happen in it's own task.
69+
- set_fact:
70+
# lib_utils_oo_etcd_host_urls is a custom filter plugin in roles/lib_utils/filter_plugins/oo_filters.py
71+
openshift_master_etcd_urls: "{{ openshift_master_etcd_hosts | lib_utils_oo_etcd_host_urls(l_use_ssl, openshift_master_etcd_port) }}"
72+
vars:
73+
l_use_ssl: "{{ openshift_master_etcd_use_ssl | default(True) | bool}}"

playbooks/openshift-etcd/private/scaleup.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,23 @@
6464
- name: Update master etcd client urls
6565
hosts: oo_masters_to_config
6666
serial: 1
67-
vars:
68-
openshift_master_etcd_hosts: "{{ hostvars
69-
| lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | union(groups['oo_new_etcd_to_config'] | default([]) ))
70-
| lib_utils_oo_collect('openshift.common.hostname')
71-
| default(none, true) }}"
72-
openshift_master_etcd_port: "{{ (etcd_client_port | default('2379')) if (groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config) else none }}"
67+
pre_tasks:
68+
- set_fact:
69+
openshift_master_etcd_hosts: "{{ hostvars
70+
| lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | union(groups['oo_new_etcd_to_config'] | default([]) ))
71+
| lib_utils_oo_collect('openshift.common.hostname')
72+
| default(none, true) }}"
73+
openshift_master_etcd_port: "{{ etcd_client_port | default('2379') }}"
74+
openshift_no_proxy_etcd_host_ips: "{{ hostvars | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
75+
| lib_utils_oo_collect('openshift.common.ip') | default([]) | join(',')
76+
}}"
77+
# This fact requires the facts set above, so needs to happen in it's own task.
78+
- set_fact:
79+
# lib_utils_oo_etcd_host_urls is a custom filter plugin in roles/lib_utils/filter_plugins/oo_filters.py
80+
openshift_master_etcd_urls: "{{ openshift_master_etcd_hosts | lib_utils_oo_etcd_host_urls(l_use_ssl, openshift_master_etcd_port) }}"
81+
vars:
82+
l_use_ssl: "{{ openshift_master_etcd_use_ssl | default(True) | bool}}"
83+
7384
roles:
7485
- role: openshift_master_facts
7586
post_tasks:

playbooks/openshift-master/private/additional_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
hosts: oo_first_master
1616
vars:
1717
cockpit_plugins: "{{ osm_cockpit_plugins | default(['cockpit-kubernetes']) }}"
18-
etcd_urls: "{{ openshift.master.etcd_urls }}"
18+
etcd_urls: "{{ openshift_master_etcd_urls }}"
1919
omc_cluster_hosts: "{{ groups.oo_masters | join(' ')}}"
2020
roles:
2121
# TODO: this is currently required in order to schedule pods onto the masters, but

playbooks/openshift-master/private/certificates.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,3 @@
88
- role: openshift_named_certificates
99
- role: openshift_ca
1010
- role: openshift_master_certificates
11-
openshift_master_etcd_hosts: "{{ hostvars
12-
| lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
13-
| lib_utils_oo_collect('openshift.common.hostname')
14-
| default(none, true) }}"

playbooks/openshift-master/private/config.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@
5353
- node
5454
- .config_managed
5555

56-
- set_fact:
57-
openshift_master_etcd_port: "{{ (etcd_client_port | default('2379')) if (groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config) else none }}"
58-
openshift_master_etcd_hosts: "{{ hostvars
59-
| lib_utils_oo_select_keys(groups['oo_etcd_to_config']
60-
| default([]))
61-
| lib_utils_oo_collect('openshift.common.hostname')
62-
| default(none, true) }}"
6356
roles:
6457
- openshift_facts
6558
post_tasks:
@@ -169,13 +162,6 @@
169162
openshift_master_session_auth_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_auth_secrets }}"
170163
openshift_master_session_encryption_secrets: "{{ hostvars[groups.oo_first_master.0].openshift.master.session_encryption_secrets }}"
171164
openshift_ca_host: "{{ groups.oo_first_master.0 }}"
172-
openshift_master_etcd_hosts: "{{ hostvars
173-
| lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
174-
| lib_utils_oo_collect('openshift.common.hostname')
175-
| default(none, true) }}"
176-
openshift_no_proxy_etcd_host_ips: "{{ hostvars | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
177-
| lib_utils_oo_collect('openshift.common.ip') | default([]) | join(',')
178-
}}"
179165
pre_tasks:
180166
# This will be moved into the control plane role once openshift_master is removed
181167
- name: Add static pod and systemd shim commands

playbooks/openshift-node/private/additional_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
hosts: oo_nodes_use_flannel
3333
roles:
3434
- role: flannel
35-
etcd_urls: "{{ hostvars[groups.oo_first_master.0].openshift.master.etcd_urls }}"
35+
etcd_urls: "{{ hostvars[groups.oo_first_master.0].openshift_master_etcd_urls }}"
3636
when: openshift_use_flannel | default(false) | bool
3737

3838
- name: Additional node config

roles/calico_master/tasks/certs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
calico_etcd_ca_cert_file: "/etc/origin/master/master.etcd-ca.crt"
1717
calico_etcd_cert_file: "/etc/origin/master/master.etcd-client.crt"
1818
calico_etcd_key_file: "/etc/origin/master/master.etcd-client.key"
19-
calico_etcd_endpoints: "{{ hostvars[groups.oo_first_master.0].openshift.master.etcd_urls | join(',') }}"
19+
calico_etcd_endpoints: "{{ hostvars[groups.oo_first_master.0].openshift_master_etcd_urls | join(',') }}"
2020

2121
- name: Calico Node | Error if no certs set.
2222
fail:

roles/lib_utils/filter_plugins/oo_filters.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,17 @@ def map_to_pairs(source, delim="="):
680680
return ','.join(["{}{}{}".format(key, delim, value) for key, value in iteritems(source)])
681681

682682

683+
def lib_utils_oo_etcd_host_urls(hosts, use_ssl=True, port='2379'):
684+
'''Return a list of urls for etcd hosts'''
685+
urls = []
686+
port = str(port)
687+
proto = "https://" if use_ssl else "http://"
688+
for host in hosts:
689+
url_string = "{}{}:{}".format(proto, host, port)
690+
urls.append(url_string)
691+
return urls
692+
693+
683694
class FilterModule(object):
684695
""" Custom ansible filter mapping """
685696

@@ -713,4 +724,5 @@ def filters(self):
713724
"lib_utils_oo_l_of_d_to_csv": lib_utils_oo_l_of_d_to_csv,
714725
"map_from_pairs": map_from_pairs,
715726
"map_to_pairs": map_to_pairs,
727+
"lib_utils_oo_etcd_host_urls": lib_utils_oo_etcd_host_urls,
716728
}

roles/nuage_master/templates/nuage-master-config-daemonset.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ data:
4646
certFile: {{ nuage_master_crt_dir }}/nuageEtcd-client.crt
4747
keyFile: {{ nuage_master_crt_dir }}/nuageEtcd-client.key
4848
urls:
49-
{% for etcd_url in openshift.master.etcd_urls %}
49+
{% for etcd_url in openshift_master_etcd_urls %}
5050
- {{ etcd_url }}
5151
{% endfor %}
5252

roles/openshift_control_plane/tasks/update_etcd_client_urls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
- yedit:
33
src: "{{ openshift.common.config_base }}/master/master-config.yaml"
44
key: 'etcdClientInfo.urls'
5-
value: "{{ openshift.master.etcd_urls }}"
5+
value: "{{ openshift_master_etcd_urls }}"
66
notify:
77
- restart master

roles/openshift_control_plane/templates/master.yaml.v1.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ etcdClientInfo:
7777
certFile: master.etcd-client.crt
7878
keyFile: master.etcd-client.key
7979
urls:
80-
{% for etcd_url in openshift.master.etcd_urls %}
80+
{% for etcd_url in openshift_master_etcd_urls %}
8181
- {{ etcd_url }}
8282
{% endfor %}
8383
etcdStorageConfig:

roles/openshift_facts/library/openshift_facts.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,13 @@ def set_url_facts_if_unset(facts):
392392
api_hostname = cluster_hostname if cluster_hostname else hostname
393393
api_public_hostname = cluster_public_hostname if cluster_public_hostname else public_hostname
394394
console_path = facts['master']['console_path']
395-
etcd_hosts = facts['master']['etcd_hosts']
396395

397396
use_ssl = dict(
398397
api=facts['master']['api_use_ssl'],
399398
public_api=facts['master']['api_use_ssl'],
400399
loopback_api=facts['master']['api_use_ssl'],
401400
console=facts['master']['console_use_ssl'],
402401
public_console=facts['master']['console_use_ssl'],
403-
etcd=facts['master']['etcd_use_ssl']
404402
)
405403

406404
ports = dict(
@@ -409,21 +407,8 @@ def set_url_facts_if_unset(facts):
409407
loopback_api=facts['master']['api_port'],
410408
console=facts['master']['console_port'],
411409
public_console=facts['master']['console_port'],
412-
etcd=facts['master']['etcd_port'],
413410
)
414411

415-
etcd_urls = []
416-
if etcd_hosts != '':
417-
facts['master']['etcd_port'] = ports['etcd']
418-
for host in etcd_hosts:
419-
etcd_urls.append(format_url(use_ssl['etcd'], host,
420-
ports['etcd']))
421-
else:
422-
etcd_urls = [format_url(use_ssl['etcd'], hostname,
423-
ports['etcd'])]
424-
425-
facts['master'].setdefault('etcd_urls', etcd_urls)
426-
427412
prefix_hosts = [('api', api_hostname),
428413
('public_api', api_public_hostname),
429414
('loopback_api', hostname)]
@@ -1069,7 +1054,7 @@ def set_container_facts_if_unset(facts):
10691054
def pop_obsolete_local_facts(local_facts):
10701055
"""Remove unused keys from local_facts"""
10711056
keys_to_remove = {
1072-
'master': ('etcd_port',)
1057+
'master': ('etcd_port', 'etcd_use_ssl', 'etcd_hosts')
10731058
}
10741059
for role in keys_to_remove:
10751060
if role in local_facts:
@@ -1215,8 +1200,7 @@ def get_defaults(self, roles):
12151200
controllers_port='8444',
12161201
console_use_ssl=True,
12171202
console_path='/console',
1218-
console_port='8443', etcd_use_ssl=True,
1219-
etcd_hosts='', etcd_port='2379',
1203+
console_port='8443',
12201204
portal_net='172.30.0.0/16',
12211205
embedded_kube=True,
12221206
embedded_dns=True,

roles/openshift_health_checker/openshift_checks/etcd_imagedata_size.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def run(self):
2121
default=int(0.5 * float(etcd_total_diskspace - etcd_avail_diskspace))
2222
)
2323

24-
etcd_is_ssl = self.get_var("openshift", "master", "etcd_use_ssl", default=False)
25-
etcd_port = self.get_var("openshift", "master", "etcd_port", default=2379)
26-
etcd_hosts = self.get_var("openshift", "master", "etcd_hosts")
24+
etcd_is_ssl = self.get_var("openshift_master_etcd_use_ssl", default=True)
25+
etcd_port = self.get_var("openshift_master_etcd_port", default=2379)
26+
etcd_hosts = self.get_var("openshift_master_etcd_hosts")
2727

2828
config_base = self.get_var("openshift", "common", "config_base")
2929

roles/openshift_health_checker/test/etcd_imagedata_size_test.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ def execute_module(module_name, module_args, *_):
127127
etcd_max_image_data_size_bytes=size_limit,
128128
ansible_mounts=ansible_mounts,
129129
openshift=dict(
130-
master=dict(etcd_hosts=["localhost"]),
131130
common=dict(config_base="/var/lib/origin")
132-
)
131+
),
132+
openshift_master_etcd_hosts=["localhost"]
133133
)
134134
if size_limit is None:
135135
task_vars.pop("etcd_max_image_data_size_bytes")
@@ -285,9 +285,9 @@ def execute_module(module_name, module_args, *_):
285285
task_vars = dict(
286286
ansible_mounts=ansible_mounts,
287287
openshift=dict(
288-
master=dict(etcd_hosts=["localhost"]),
289288
common=dict(config_base="/var/lib/origin")
290-
)
289+
),
290+
openshift_master_etcd_hosts=["localhost"]
291291
)
292292

293293
check = EtcdImageDataSize(execute_module, task_vars).run()
@@ -313,9 +313,9 @@ def execute_module(module_name, *_):
313313
'size_total': 80 * 10**9,
314314
}],
315315
openshift=dict(
316-
master=dict(etcd_hosts=["localhost"]),
317316
common=dict(config_base="/var/lib/origin")
318-
)
317+
),
318+
openshift_master_etcd_hosts=["localhost"]
319319
)
320320

321321
check = EtcdImageDataSize(execute_module, task_vars).run()

roles/openshift_master/tasks/update_etcd_client_urls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
- yedit:
33
src: "{{ openshift.common.config_base }}/master/master-config.yaml"
44
key: 'etcdClientInfo.urls'
5-
value: "{{ openshift.master.etcd_urls }}"
5+
value: "{{ openshift_master_etcd_urls }}"
66
notify:
77
- restart master api
88
- restart master controllers

roles/openshift_master/templates/master.yaml.v1.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ etcdClientInfo:
7676
certFile: master.etcd-client.crt
7777
keyFile: master.etcd-client.key
7878
urls:
79-
{% for etcd_url in openshift.master.etcd_urls %}
79+
{% for etcd_url in openshift_master_etcd_urls %}
8080
- {{ etcd_url }}
8181
{% endfor %}
8282
etcdStorageConfig:

roles/openshift_master_certificates/tasks/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
file:
102102
path: "{{ openshift_master_generated_config_dir }}/{{ item }}"
103103
state: absent
104+
# Do we need this boolean here?
104105
when: openshift_master_etcd_hosts | length > 0
105106
with_items:
106107
- master.etcd-client.crt

roles/openshift_master_facts/tasks/main.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@
4141
extension_scripts: "{{ openshift_master_extension_scripts | default(None) }}"
4242
extension_stylesheets: "{{ openshift_master_extension_stylesheets | default(None) }}"
4343
extensions: "{{ openshift_master_extensions | default(None) }}"
44-
etcd_hosts: "{{ openshift_master_etcd_hosts | default(None) }}"
45-
etcd_port: "{{ openshift_master_etcd_port | default(None) }}"
46-
etcd_use_ssl: "{{ openshift_master_etcd_use_ssl | default(None) }}"
47-
etcd_urls: "{{ openshift_master_etcd_urls | default(None) }}"
4844
embedded_kube: "{{ openshift_master_embedded_kube | default(None) }}"
4945
embedded_dns: "{{ openshift_master_embedded_dns | default(None) }}"
5046
bind_addr: "{{ openshift_master_bind_addr | default(None) }}"

roles/openshift_service_catalog/tasks/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
cpu_requests: none
119119
memory_request: none
120120
cors_allowed_origin: localhost
121-
etcd_servers: "{{ openshift.master.etcd_urls | join(',') }}"
121+
etcd_servers: "{{ openshift_master_etcd_urls | join(',') }}"
122122
etcd_cafile: "{{ '/etc/origin/master/master.etcd-ca.crt' if etcd_ca_crt.stat.exists else '/etc/origin/master/ca-bundle.crt' }}"
123123
node_selector: {'node-role.kubernetes.io/master': 'true'}
124124
# apiserver_ca is defined in generate_certs.yml

0 commit comments

Comments
 (0)