Commit beb0a3b4 authored by Julien Muchembled's avatar Julien Muchembled

NEO: by default, instantiate an admin node when there's a master node

Since commit ebc1636d ("instanciate a
single admin node, by default in the first subpartition"), there was
only 1 admin node (and 1 neoctl wrapper) and this was inconvenient if
the partition hosting it lost.

Only 1 admin node does monitoring.
parent ac2a7e45
...@@ -18,11 +18,11 @@ md5sum = 80599fcc6e5d07270d7900aebfd62139 ...@@ -18,11 +18,11 @@ md5sum = 80599fcc6e5d07270d7900aebfd62139
[root-common] [root-common]
filename = root-common.cfg.in filename = root-common.cfg.in
md5sum = c03fbfc9df9edc1ef60be970e0627c5e md5sum = 8e28f599247ad604ec6e32df410412a8
[instance-neo-admin] [instance-neo-admin]
filename = instance-neo-admin.cfg.in filename = instance-neo-admin.cfg.in
md5sum = 87670ddc6b5d2007dac1b6d2ba86d168 md5sum = ccd9dced3e971e8c60ae7e7b25d23f60
[instance-neo-master] [instance-neo-master]
filename = instance-neo-master.cfg.in filename = instance-neo-master.cfg.in
...@@ -30,7 +30,7 @@ md5sum = 9f27195d770b2f57461c60a82c851ab9 ...@@ -30,7 +30,7 @@ md5sum = 9f27195d770b2f57461c60a82c851ab9
[instance-neo] [instance-neo]
filename = instance-neo.cfg.in filename = instance-neo.cfg.in
md5sum = 512383220488335ac186013c2ffdc7c1 md5sum = 7642c760a2c5af3e3e81c2c54486d1a8
[template-neo-my-cnf] [template-neo-my-cnf]
filename = my.cnf.in filename = my.cnf.in
......
{%- if slapparameter_dict.get('admin') != 0 %} {%- if slapparameter_dict.get('admin') != 0 %}
{%- set monitor_dict = slapparameter_dict['monitor'] %} {%- set monitor_dict = slapparameter_dict.get('monitor', {}) %}
{%- set bang_on_problem = monitor_dict.pop('bang-on-problem', None) %} {%- set bang_on_problem = monitor_dict.pop('bang-on-problem', None) %}
{%- set periodicity = monitor_dict.pop('periodicity', None) %} {%- set periodicity = monitor_dict.pop('periodicity', None) %}
{%- set monitor_passwd = slapparameter_dict.get('monitor-passwd') %}
[buildout] [buildout]
extends =
{{ template_monitor }}
parts += parts +=
logrotate-admin logrotate-admin
{%- if monitor_passwd != None %}
monitor-neo-health monitor-neo-health
extends =
{{ template_monitor }}
[directory]
plugin = ${:etc}/plugin
[monitor-neo-health]
<= monitor-promise-base
module = check_neo_health
name = ${:_buildout_section_name_}.py
config-neoctl = ${neoctl:wrapper-path}
{%- if bang_on_problem != None %}
config-bang-on-problem = {{ dumps(bang_on_problem) }}
{%- endif %}
{%- if periodicity != None %}
config-periodicity = {{ dumps(periodicity) }}
{%- endif %}
[monitor-instance-parameter]
monitor-httpd-port = {{ slapparameter_dict.get('monitor-port', 2052) }}
monitor-title = neo
password = {{ monitor_passwd }}
{%- endif %}
[neo-admin] [neo-admin]
recipe = slapos.cookbook:neoppod.admin recipe = slapos.cookbook:neoppod.admin
...@@ -33,26 +56,6 @@ extra-options = ...@@ -33,26 +56,6 @@ extra-options =
{%- endfor %} {%- endfor %}
{%- endfor %} {%- endfor %}
[directory]
plugin = ${:etc}/plugin
[monitor-neo-health]
<= monitor-promise-base
module = check_neo_health
name = ${:_buildout_section_name_}.py
config-neoctl = ${neoctl:wrapper-path}
{%- if bang_on_problem != None %}
config-bang-on-problem = {{ dumps(bang_on_problem) }}
{%- endif %}
{%- if periodicity != None %}
config-periodicity = {{ dumps(periodicity) }}
{%- endif %}
[monitor-instance-parameter]
monitor-httpd-port = {{ slapparameter_dict.get('admin', 2050) + 1 }}
monitor-title = neo
password = {{ slapparameter_dict['monitor-passwd'] }}
[logrotate-admin] [logrotate-admin]
< = logrotate-entry-base < = logrotate-entry-base
name = neo-admin name = neo-admin
......
...@@ -82,15 +82,18 @@ ...@@ -82,15 +82,18 @@
"additionalProperties": false, "additionalProperties": false,
"properties": { "properties": {
"admin": { "admin": {
"description": "Port of admin node. 0 to disable.", "description": "Admin port, 0 to disable. Default to 2050 if the node has a master, 0 otherwise.",
"default": 2050,
"type": "integer" "type": "integer"
}, },
"master": { "master": {
"description": "Port of master node. 0 to disable.", "description": "Master port, 0 to disable.",
"default": 2051, "default": 2051,
"type": "integer" "type": "integer"
}, },
"monitor": {
"description": "Monitor port, 0 to disable. Unless explicitly set by a node, the first one with an admin gets a monitor at port 2052.",
"type": "integer"
},
"storage-count": { "storage-count": {
"description": "Number of storage nodes to deploy. One master and one admin node is deployed with each storage.", "description": "Number of storage nodes to deploy. One master and one admin node is deployed with each storage.",
"default": 1, "default": 1,
......
...@@ -65,7 +65,7 @@ recipe = slapos.cookbook:publish.serialised ...@@ -65,7 +65,7 @@ recipe = slapos.cookbook:publish.serialised
# TODO: make port a partition parameter # TODO: make port a partition parameter
ip = {{ "[%s]" % list(ipv6_set)[0] if ipv6_set else list(ipv4_set)[0] }} ip = {{ "[%s]" % list(ipv6_set)[0] if ipv6_set else list(ipv4_set)[0] }}
{% set admin = slapparameter_dict.get('admin', 2050) -%} {% set admin = slapparameter_dict.get('admin', 2050) -%}
{% set master = slapparameter_dict.get('master', 2052) -%} {% set master = slapparameter_dict.get('master', 2051) -%}
{% if master -%} {% if master -%}
port-master = {{ master }} port-master = {{ master }}
master = ${:ip}:${:port-master} master = ${:ip}:${:port-master}
...@@ -75,10 +75,12 @@ master = ...@@ -75,10 +75,12 @@ master =
{% if admin -%} {% if admin -%}
port-admin = {{ admin }} port-admin = {{ admin }}
admin = ${:ip}:${:port-admin} admin = ${:ip}:${:port-admin}
{%- if 'monitor-passwd' in slapparameter_dict %}
monitor-base-url = ${monitor-publish-parameters:monitor-base-url} monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
{% else -%} {%- endif %}
{%- else %}
admin = admin =
{% endif -%} {%- endif %}
{#- Hack to deploy SSL certs via instance parameters #} {#- Hack to deploy SSL certs via instance parameters #}
{%- for name, pem in zip(('ca.crt', 'neo.crt', 'neo.key'), {%- for name, pem in zip(('ca.crt', 'neo.crt', 'neo.key'),
......
...@@ -88,13 +88,26 @@ software-type = {{ software_type }} ...@@ -88,13 +88,26 @@ software-type = {{ software_type }}
{% endfor -%} {% endfor -%}
config-autostart = {{ dumps(sum(storage_count)) }} config-autostart = {{ dumps(sum(storage_count)) }}
{%- do assert(replicas < len(node_list)) %} {%- do assert(replicas < len(node_list)) %}
{%- set admin_list = [] %} {%- set monitor = set() %}
{%- for i, node in enumerate(node_list) %}
{%- set port = node.get('monitor') %}
{%- if port %}
{%- do monitor.add(node.get('admin') != 0 and port) %}
{%- endif %}
{%- endfor %}
{%- if False in monitor %}
{%- do monitor.remove(False) %}
{%- do assert(monitor) %}
{%- endif %}
{%- for i, node in enumerate(node_list) %} {%- for i, node in enumerate(node_list) %}
{%- set section_id = prefix ~ i %} {%- set section_id = prefix ~ i %}
{%- do section_id_list.append(section_id) %} {%- do section_id_list.append(section_id) %}
{%- if admin_list %} {%- if node.get('master') == 0 and not node.get('monitor') %}
{%- do node.setdefault('admin', 0) %} {%- do node.setdefault('admin', 0) %}
{%- endif %} {%- endif %}
{%- if monitor or node.get('admin') == 0 %}
{%- do node.setdefault('monitor', 0) %}
{%- endif %}
[{{section_id}}] [{{section_id}}]
<= {{ prefix }}request-common <= {{ prefix }}request-common
...@@ -102,14 +115,21 @@ name = {{ section_id }} ...@@ -102,14 +115,21 @@ name = {{ section_id }}
return = return =
master master
admin admin
{%- if node.get('admin') != 0 %} {%- set port = node.pop('monitor', None) %}
{%- if port != 0 or node.get('admin') != 0 and not monitor %}
{%- if port != 0 %}
monitor-base-url monitor-base-url
{%- if monitor_base_url_dict != None %} {%- if monitor_base_url_dict != None %}
{%- do monitor_base_url_dict.__setitem__('neo', {%- do monitor_base_url_dict.__setitem__('neo',
'${' ~ section_id ~ ':connection-monitor-base-url}') %} '${' ~ section_id ~ ':connection-monitor-base-url}') %}
{%- endif %} {%- endif %}
{%- do admin_list.append(section_id) %}
config-monitor-passwd = ${monitor-htpasswd:passwd} config-monitor-passwd = ${monitor-htpasswd:passwd}
{%- endif %}
{%- if port %}
config-monitor-port = {{ dumps(port) }}
{%- else %}
{%- do monitor.add(None) %}
{%- endif %}
config-monitor = {{ dumps(parameter_dict.get('monitor', {})) }} config-monitor = {{ dumps(parameter_dict.get('monitor', {})) }}
{%- endif %} {%- endif %}
{%- for k, v in node.iteritems() %} {%- for k, v in node.iteritems() %}
...@@ -117,7 +137,7 @@ config-{{ k }} = {{ dumps(v) }} ...@@ -117,7 +137,7 @@ config-{{ k }} = {{ dumps(v) }}
{%- endfor %} {%- endfor %}
{{ sla(section_id) }} {{ sla(section_id) }}
{%- endfor %} {%- endfor %}
{%- do assert(len(admin_list) == 1, admin_list) %} {%- do assert(len(monitor) == 1, monitor) %}
[{{section(prefix ~ 'cluster')}}] [{{section(prefix ~ 'cluster')}}]
recipe = slapos.cookbook:neoppod.cluster recipe = slapos.cookbook:neoppod.cluster
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment