cluster_changed/haproxy
This commit is contained in:
parent
430a00f99b
commit
42cad0fb3a
@ -48,19 +48,19 @@ class ObjectStoreContext(OSContextGenerator):
|
|||||||
|
|
||||||
|
|
||||||
class HAProxyContext(OSContextGenerator):
|
class HAProxyContext(OSContextGenerator):
|
||||||
interfaces = ['ceph']
|
interfaces = ['cluster']
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
'''
|
'''
|
||||||
Extends the main charmhelpers HAProxyContext with a port mapping
|
Extends the main charmhelpers HAProxyContext with a port mapping
|
||||||
specific to this charm.
|
specific to this charm.
|
||||||
Also used to extend cinder.conf context with correct api_listening_port
|
Also used to extend glance-api.conf context with correct bind_port
|
||||||
'''
|
'''
|
||||||
haproxy_port = determine_haproxy_port(config('api-listening-port'))
|
haproxy_port = determine_haproxy_port('9292')
|
||||||
api_port = determine_api_port(config('api-listening-port'))
|
api_port = determine_api_port('9292')
|
||||||
|
|
||||||
ctxt = {
|
ctxt = {
|
||||||
'service_ports': {'cinder_api': [haproxy_port, api_port]},
|
'service_ports': {'glance_api': [haproxy_port, api_port]},
|
||||||
'osapi_volume_listen_port': api_port,
|
'bind_port': api_port,
|
||||||
}
|
}
|
||||||
return ctxt
|
return ctxt
|
||||||
|
@ -309,16 +309,12 @@ def config_changed():
|
|||||||
|
|
||||||
|
|
||||||
def cluster_changed():
|
def cluster_changed():
|
||||||
if not peer_units():
|
|
||||||
juju_log('INFO', '%s: cluster_change() with no peers.' % CHARM)
|
|
||||||
sys.exit(0)
|
|
||||||
haproxy_port = determine_haproxy_port('9292')
|
|
||||||
backend_port = determine_api_port('9292')
|
|
||||||
stop('glance-api')
|
stop('glance-api')
|
||||||
configure_haproxy("glance_api:%s:%s" % (haproxy_port, backend_port))
|
CONFIGS.write('/etc/glance/glance-api.conf')
|
||||||
set_or_update(key='bind_port', value=backend_port, file='api')
|
CONFIGS.write('/etc/haproxy/haproxy.cfg')
|
||||||
start('glance-api')
|
start('glance-api')
|
||||||
|
|
||||||
|
|
||||||
def upgrade_charm():
|
def upgrade_charm():
|
||||||
cluster_changed()
|
cluster_changed()
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ CONFIG_FILES = OrderedDict([
|
|||||||
'hook_contexts': [context.SharedDBContext(),
|
'hook_contexts': [context.SharedDBContext(),
|
||||||
context.IdentityServiceContext(),
|
context.IdentityServiceContext(),
|
||||||
glance_contexts.CephContext(),
|
glance_contexts.CephContext(),
|
||||||
glance_contexts.ObjectStoreContext()],
|
glance_contexts.ObjectStoreContext(),
|
||||||
|
glance_contexts.HAProxyContext()],
|
||||||
'services': ['glance-api']
|
'services': ['glance-api']
|
||||||
}),
|
}),
|
||||||
('/etc/glance/glance-api-paste.ini', {
|
('/etc/glance/glance-api-paste.ini', {
|
||||||
@ -67,6 +68,11 @@ CONFIG_FILES = OrderedDict([
|
|||||||
'hook_contexts': [context.CephContext()],
|
'hook_contexts': [context.CephContext()],
|
||||||
'services': []
|
'services': []
|
||||||
}),
|
}),
|
||||||
|
('/etc/haproxy/haproxy.cfg', {
|
||||||
|
'hook_contexts': [context.HAProxyContext(),
|
||||||
|
glance_contexts.HAProxyContext()],
|
||||||
|
'services': ['haproxy'],
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
|
|
||||||
def register_configs():
|
def register_configs():
|
||||||
|
@ -9,7 +9,11 @@ default_store = swift
|
|||||||
default_store = file
|
default_store = file
|
||||||
{% endif %}
|
{% endif %}
|
||||||
bind_host = 0.0.0.0
|
bind_host = 0.0.0.0
|
||||||
|
{% if bind_port %}
|
||||||
|
bind_port = {{ bind_port }}
|
||||||
|
{% else %}
|
||||||
bind_port = 9292
|
bind_port = 9292
|
||||||
|
{% endif %}
|
||||||
log_file = /var/log/glance/api.log
|
log_file = /var/log/glance/api.log
|
||||||
backlog = 4096
|
backlog = 4096
|
||||||
workers = 0
|
workers = 0
|
||||||
|
@ -9,7 +9,11 @@ default_store = swift
|
|||||||
default_store = file
|
default_store = file
|
||||||
{% endif %}
|
{% endif %}
|
||||||
bind_host = 0.0.0.0
|
bind_host = 0.0.0.0
|
||||||
|
{% if bind_port %}
|
||||||
|
bind_port = {{ bind_port }}
|
||||||
|
{% else %}
|
||||||
bind_port = 9292
|
bind_port = 9292
|
||||||
|
{% endif %}
|
||||||
log_file = /var/log/glance/api.log
|
log_file = /var/log/glance/api.log
|
||||||
backlog = 4096
|
backlog = 4096
|
||||||
{% if database_host %}
|
{% if database_host %}
|
||||||
|
37
templates/haproxy.cfg
Normal file
37
templates/haproxy.cfg
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
global
|
||||||
|
log 127.0.0.1 local0
|
||||||
|
log 127.0.0.1 local1 notice
|
||||||
|
maxconn 20000
|
||||||
|
user haproxy
|
||||||
|
group haproxy
|
||||||
|
spread-checks 0
|
||||||
|
|
||||||
|
defaults
|
||||||
|
log global
|
||||||
|
mode http
|
||||||
|
option httplog
|
||||||
|
option dontlognull
|
||||||
|
retries 3
|
||||||
|
timeout queue 1000
|
||||||
|
timeout connect 1000
|
||||||
|
timeout client 30000
|
||||||
|
timeout server 30000
|
||||||
|
|
||||||
|
listen stats :8888
|
||||||
|
mode http
|
||||||
|
stats enable
|
||||||
|
stats hide-version
|
||||||
|
stats realm Haproxy\ Statistics
|
||||||
|
stats uri /
|
||||||
|
stats auth admin:password
|
||||||
|
|
||||||
|
{% if units %}
|
||||||
|
{% for service, ports in service_ports.iteritems() -%}
|
||||||
|
listen {{ service }} 0.0.0.0:{{ ports[0] }}
|
||||||
|
balance roundrobin
|
||||||
|
option tcplog
|
||||||
|
{% for unit, address in units.iteritems() -%}
|
||||||
|
server {{ unit }} {{ address }}:{{ ports[1] }} check
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
Loading…
Reference in New Issue
Block a user