Commit a3bb9a41 authored by Julien Muchembled's avatar Julien Muchembled

NEO: add monitoring

parent ebc1636d
...@@ -84,7 +84,7 @@ This software release assigns the following port ranges by default: ...@@ -84,7 +84,7 @@ This software release assigns the following port ranges by default:
memcached-persistent 2000-2009 memcached-persistent 2000-2009
memcached-volatile 2010-2019 memcached-volatile 2010-2019
smtp 2025-2029 smtp 2025-2029
neo (admin & master) 2050-2051 neo (admin, master) 2050-2052
mariadb 2099 mariadb 2099
zeo 2100-2149 zeo 2100-2149
balancer 2150-2199 balancer 2150-2199
......
{%- set monitor_dict = slapparameter_dict['monitor'] %}
{%- set bang_on_problem = monitor_dict.pop('bang-on-problem', None) %}
{%- set periodicity = monitor_dict.pop('periodicity', None) %}
[buildout] [buildout]
extends =
{{ template_monitor }}
parts += parts +=
neo-admin-promise
logrotate-admin logrotate-admin
neoctl monitor-neo-health
[neo-admin] [neo-admin]
recipe = slapos.cookbook:neoppod.admin recipe = slapos.cookbook:neoppod.admin
...@@ -14,12 +19,38 @@ port = ${publish:port-admin} ...@@ -14,12 +19,38 @@ port = ${publish:port-admin}
ssl = {{ dumps(bool(slapparameter_dict['ssl'])) }} ssl = {{ dumps(bool(slapparameter_dict['ssl'])) }}
cluster = {{ dumps(slapparameter_dict['cluster']) }} cluster = {{ dumps(slapparameter_dict['cluster']) }}
masters = {{ dumps(slapparameter_dict['masters']) }} masters = {{ dumps(slapparameter_dict['masters']) }}
extra-options =
{%- for k, v in monitor_dict.iteritems() %}
{%- if k == 'backup' %}
{%- set k = 'monitor-backup' %}
{%- endif %}
{%- if not isinstance(v, list) %}
{%- set v = [v] %}
{%- endif %}
{%- for v in v %}
--{{k}}={{v}}
{%- 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 %}
[neo-admin-promise] [monitor-instance-parameter]
recipe = slapos.cookbook:check_port_listening monitor-httpd-port = {{ slapparameter_dict.get('admin', 2050) + 1 }}
hostname = ${neo-admin:ip} monitor-title = neo
port = ${neo-admin:port} password = {{ slapparameter_dict['monitor-passwd'] }}
path = ${directory:promises}/neo-admin-promise
[logrotate-admin] [logrotate-admin]
< = logrotate-entry-base < = logrotate-entry-base
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
], ],
"properties": { "properties": {
"cluster": { "cluster": {
"description": "Cluster unique identifier. Your last line of defense against mixing up NEO clusters and corrupting your data. Choose a unique value for each of your cluster.", "description": "Cluster unique identifier. Your last line of defense against mixing up NEO clusters and corrupting your data. Choose a unique value for each of your cluster. Space not allowed.",
"type": "string" "type": "string"
}, },
"partitions": { "partitions": {
...@@ -28,6 +28,25 @@ ...@@ -28,6 +28,25 @@
"description": "Master nodes in the cluster to backup.", "description": "Master nodes in the cluster to backup.",
"type": "string" "type": "string"
}, },
"monitor": {
"description": "Parameters for monitoring.",
"properties": {
"backup": {
"description": "List of cluster names that are expected to backup this cluster.",
"type": "array",
"items": {
"type": "string"
},
"uniqueItems": true
},
"periodicity": {
"description": "Periodicity in minutes at which the cluster health is checked.",
"default": 10,
"type": "float"
}
},
"type": "object"
},
"sla-dict": { "sla-dict": {
"description": "[NEO SR only] Where to request instances. Each key is a query string for criterions (e.g. \"computer_guid=foo\"), and each value is a list of partition references ('node-0', 'node-1', ...). The prefix 'node-' is mandatory and the number must start from 0. The total number of nodes here must be equal to the length of node-list.", "description": "[NEO SR only] Where to request instances. Each key is a query string for criterions (e.g. \"computer_guid=foo\"), and each value is a list of partition references ('node-0', 'node-1', ...). The prefix 'node-' is mandatory and the number must start from 0. The total number of nodes here must be equal to the length of node-list.",
"additionalProperties": { "additionalProperties": {
...@@ -58,6 +77,7 @@ ...@@ -58,6 +77,7 @@
"items": { "items": {
"description": "Dictionary containing parameters required to configure individual nodes.", "description": "Dictionary containing parameters required to configure individual nodes.",
"default": {}, "default": {},
"additionalProperties": false,
"properties": { "properties": {
"admin": { "admin": {
"description": "Port of admin node. 0 to disable.", "description": "Port of admin node. 0 to disable.",
......
[buildout] [buildout]
parts += parts +=
neo-master-promise
logrotate-master logrotate-master
[neo-master] [neo-master]
...@@ -23,12 +22,6 @@ autostart = {{ slapparameter_dict['autostart'] }} ...@@ -23,12 +22,6 @@ autostart = {{ slapparameter_dict['autostart'] }}
# this default value is required. # this default value is required.
masters = {{ dumps(slapparameter_dict['masters']) }} masters = {{ dumps(slapparameter_dict['masters']) }}
[neo-master-promise]
recipe = slapos.cookbook:check_port_listening
hostname = ${neo-master:ip}
port = ${neo-master:port}
path = ${directory:promises}/neo-master-promise
[logrotate-master] [logrotate-master]
< = logrotate-entry-base < = logrotate-entry-base
name = neo-master name = neo-master
......
...@@ -51,7 +51,7 @@ recipe = slapos.cookbook:publish.serialised ...@@ -51,7 +51,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', 2051) -%} {% set master = slapparameter_dict.get('master', 2052) -%}
{% if master -%} {% if master -%}
port-master = {{ master }} port-master = {{ master }}
master = ${:ip}:${:port-master} master = ${:ip}:${:port-master}
...@@ -61,6 +61,7 @@ master = ...@@ -61,6 +61,7 @@ master =
{% if admin -%} {% if admin -%}
port-admin = {{ admin }} port-admin = {{ admin }}
admin = ${:ip}:${:port-admin} admin = ${:ip}:${:port-admin}
monitor-base-url = ${monitor-publish-parameters:monitor-base-url}
{% else -%} {% else -%}
admin = admin =
{% endif -%} {% endif -%}
...@@ -119,7 +120,6 @@ post = {{ bin_directory }}/slapos-kill -s RTMIN+1 -- {{ bin_directory }}/neostor ...@@ -119,7 +120,6 @@ post = {{ bin_directory }}/slapos-kill -s RTMIN+1 -- {{ bin_directory }}/neostor
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
promises = ${buildout:directory}/etc/promises
bin = ${buildout:directory}/bin bin = ${buildout:directory}/bin
etc = ${buildout:directory}/etc etc = ${buildout:directory}/etc
var = ${buildout:directory}/var var = ${buildout:directory}/var
...@@ -162,11 +162,11 @@ context = ...@@ -162,11 +162,11 @@ context =
[buildout] [buildout]
extends = extends =
{{ logrotate_cfg }} {{ logrotate_cfg }}
{%- if master %}
{{ master_cfg }}
{%- endif %}
{%- if admin %} {%- if admin %}
{{ admin_cfg }} {{ admin_cfg }}
{%- endif %} {%- endif %}
{%- if master %}
{{ master_cfg }}
{%- endif %}
parts += parts +=
{{ '\n '.join(part_list) }} {{ '\n '.join(part_list) }}
...@@ -35,13 +35,10 @@ parts = ...@@ -35,13 +35,10 @@ parts =
{{- assert(not sla_dict, sla_dict) }} {{- assert(not sla_dict, sla_dict) }}
{% endmacro -%} {% endmacro -%}
{% macro request_neo(parameter_dict, software_type, prefix='node-') -%} {% macro request_neo(parameter_dict, software_type, prefix='node-', monitor_base_url_dict=None) -%}
{% set section_id_list = [] -%} {% set section_id_list = [] -%}
[{{ prefix }}request-common] [{{ prefix }}request-common]
<= request-common-base <= request-common-base
return =
master
admin
config-masters = {{ '${' ~ prefix ~ 'cluster:masters}' }} config-masters = {{ '${' ~ prefix ~ 'cluster:masters}' }}
config-cluster = {{ parameter_dict['cluster'] }} config-cluster = {{ parameter_dict['cluster'] }}
{% set replicas = parameter_dict.get('replicas', 0) -%} {% set replicas = parameter_dict.get('replicas', 0) -%}
...@@ -73,8 +70,18 @@ config-autostart = {{ dumps(sum(storage_count)) }} ...@@ -73,8 +70,18 @@ config-autostart = {{ dumps(sum(storage_count)) }}
[{{section_id}}] [{{section_id}}]
<= {{ prefix }}request-common <= {{ prefix }}request-common
name = {{ section_id }} name = {{ section_id }}
return =
master
admin
{%- if node.get('admin') != 0 %} {%- if node.get('admin') != 0 %}
{%- do admin_list.append(node) %} monitor-base-url
{%- if monitor_base_url_dict != None %}
{%- do monitor_base_url_dict.__setitem__('neo',
'${' ~ section_id ~ ':connection-monitor-base-url}') %}
{%- endif %}
{%- do admin_list.append(section_id) %}
config-monitor-passwd = ${monitor-htpasswd:passwd}
config-monitor = {{ dumps(parameter_dict.get('monitor', {})) }}
{%- endif %} {%- endif %}
{%- for k, v in node.iteritems() %} {%- for k, v in node.iteritems() %}
config-{{ k }} = {{ dumps(v) }} config-{{ k }} = {{ dumps(v) }}
......
...@@ -112,19 +112,19 @@ adapter-context = ...@@ -112,19 +112,19 @@ adapter-context =
[root-common] [root-common]
<= download-base-neo <= download-base-neo
md5sum = 22ae2edfcbc7b7ef2a3128cb75e9f456 md5sum = ccc6e33412259415ec6c3452d37b77cc
[instance-neo-admin] [instance-neo-admin]
<= download-base-neo <= download-base-neo
md5sum = ce0d9ff9e899bb706351a99df29238a9 md5sum = 5873b385bed7207ca865536fd63bb610
[instance-neo-master] [instance-neo-master]
<= download-base-neo <= download-base-neo
md5sum = 4faee020eaf7cd495cd6210dfa4eb0c1 md5sum = 728c407bc526252aec2222752226dde6
[instance-neo] [instance-neo]
<= download-base-neo <= download-base-neo
md5sum = 5fc9fcaec3a5387625af34fe686097ae md5sum = d18e049d580720e733502b774b0d6790
[template-neo-my-cnf] [template-neo-my-cnf]
<= download-base-neo <= download-base-neo
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# not need these here). # not need these here).
[template-erp5] [template-erp5]
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = 001affafc204b638615deea04c95cfdf md5sum = 30b6e5b79b7dd78a30cbaee1b265afde
[template-balancer] [template-balancer]
filename = instance-balancer.cfg.in filename = instance-balancer.cfg.in
......
...@@ -152,7 +152,7 @@ connection-url = smtp://127.0.0.2:0/ ...@@ -152,7 +152,7 @@ connection-url = smtp://127.0.0.2:0/
{% set ((name, server_dict),) = server_dict.items() -%} {% set ((name, server_dict),) = server_dict.items() -%}
{% do neo.append(server_dict.get('cluster')) -%} {% do neo.append(server_dict.get('cluster')) -%}
{% do server_dict.update(cluster='${publish-early:neo-cluster}') -%} {% do server_dict.update(cluster='${publish-early:neo-cluster}') -%}
{{ root_common.request_neo(server_dict, 'zodb-neo', 'neo-') }} {{ root_common.request_neo(server_dict, 'zodb-neo', 'neo-', monitor_base_url_dict) }}
{% set client_dict = zodb_dict[name].setdefault('storage-dict', {}) -%} {% set client_dict = zodb_dict[name].setdefault('storage-dict', {}) -%}
{% for k in 'ssl', '_ca', '_cert', '_key' -%} {% for k in 'ssl', '_ca', '_cert', '_key' -%}
{% do k in server_dict and client_dict.setdefault(k, server_dict[k]) -%} {% do k in server_dict and client_dict.setdefault(k, server_dict[k]) -%}
......
...@@ -78,7 +78,7 @@ md5sum = d41d8cd98f00b204e9800998ecf8427e ...@@ -78,7 +78,7 @@ md5sum = d41d8cd98f00b204e9800998ecf8427e
[template-erp5] [template-erp5]
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = af5d9aeac2bae695220465a4348ae592 md5sum = 76b72c59bbe962bf1866851a1837237c
[template-zeo] [template-zeo]
filename = instance-zeo.cfg.in filename = instance-zeo.cfg.in
......
...@@ -152,7 +152,7 @@ connection-url = smtp://127.0.0.2:0/ ...@@ -152,7 +152,7 @@ connection-url = smtp://127.0.0.2:0/
{% set ((name, server_dict),) = server_dict.items() -%} {% set ((name, server_dict),) = server_dict.items() -%}
{% do neo.append(server_dict.get('cluster')) -%} {% do neo.append(server_dict.get('cluster')) -%}
{% do server_dict.update(cluster='${publish-early:neo-cluster}') -%} {% do server_dict.update(cluster='${publish-early:neo-cluster}') -%}
{{ root_common.request_neo(server_dict, 'zodb-neo', 'neo-') }} {{ root_common.request_neo(server_dict, 'zodb-neo', 'neo-', monitor_base_url_dict) }}
{% set client_dict = zodb_dict[name].setdefault('storage-dict', {}) -%} {% set client_dict = zodb_dict[name].setdefault('storage-dict', {}) -%}
{% for k in 'ssl', '_ca', '_cert', '_key' -%} {% for k in 'ssl', '_ca', '_cert', '_key' -%}
{% do k in server_dict and client_dict.setdefault(k, server_dict[k]) -%} {% do k in server_dict and client_dict.setdefault(k, server_dict[k]) -%}
......
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