Sync charm-helpers
Notable issues resolved: openstack_upgrade_available() broken for swift https://bugs.launchpad.net/charm-swift-proxy/+bug/1743847 haproxy context doesn't consider bindings https://bugs.launchpad.net/charm-helpers/+bug/1735421 regression in haproxy check https://bugs.launchpad.net/charm-helpers/+bug/1743287 * Zesty is EOL Change-Id: I1cabed3bfc2be09d2632ed06a84ee20ec5738484changes/86/536486/3
parent
b826fbd9f5
commit
c0cec270b9
|
@ -93,10 +93,10 @@ from charmhelpers.contrib.network.ip import (
|
|||
format_ipv6_addr,
|
||||
is_bridge_member,
|
||||
is_ipv6_disabled,
|
||||
get_relation_ip,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
config_flags_parser,
|
||||
get_host_ip,
|
||||
git_determine_usr_bin,
|
||||
git_determine_python_path,
|
||||
enable_memcache,
|
||||
|
@ -555,7 +555,9 @@ class HAProxyContext(OSContextGenerator):
|
|||
"""
|
||||
interfaces = ['cluster']
|
||||
|
||||
def __init__(self, singlenode_mode=False):
|
||||
def __init__(self, singlenode_mode=False,
|
||||
address_types=ADDRESS_TYPES):
|
||||
self.address_types = address_types
|
||||
self.singlenode_mode = singlenode_mode
|
||||
|
||||
def __call__(self):
|
||||
|
@ -564,19 +566,22 @@ class HAProxyContext(OSContextGenerator):
|
|||
if not relation_ids('cluster') and not self.singlenode_mode:
|
||||
return {}
|
||||
|
||||
if config('prefer-ipv6'):
|
||||
addr = get_ipv6_addr(exc_list=[config('vip')])[0]
|
||||
else:
|
||||
addr = get_host_ip(unit_get('private-address'))
|
||||
|
||||
l_unit = local_unit().replace('/', '-')
|
||||
cluster_hosts = {}
|
||||
|
||||
# NOTE(jamespage): build out map of configured network endpoints
|
||||
# and associated backends
|
||||
for addr_type in ADDRESS_TYPES:
|
||||
for addr_type in self.address_types:
|
||||
cfg_opt = 'os-{}-network'.format(addr_type)
|
||||
laddr = get_address_in_network(config(cfg_opt))
|
||||
# NOTE(thedac) For some reason the ADDRESS_MAP uses 'int' rather
|
||||
# than 'internal'
|
||||
if addr_type == 'internal':
|
||||
_addr_map_type = INTERNAL
|
||||
else:
|
||||
_addr_map_type = addr_type
|
||||
# Network spaces aware
|
||||
laddr = get_relation_ip(ADDRESS_MAP[_addr_map_type]['binding'],
|
||||
config(cfg_opt))
|
||||
if laddr:
|
||||
netmask = get_netmask_for_address(laddr)
|
||||
cluster_hosts[laddr] = {
|
||||
|
@ -587,15 +592,19 @@ class HAProxyContext(OSContextGenerator):
|
|||
}
|
||||
for rid in relation_ids('cluster'):
|
||||
for unit in sorted(related_units(rid)):
|
||||
# API Charms will need to set {addr_type}-address with
|
||||
# get_relation_ip(addr_type)
|
||||
_laddr = relation_get('{}-address'.format(addr_type),
|
||||
rid=rid, unit=unit)
|
||||
if _laddr:
|
||||
_unit = unit.replace('/', '-')
|
||||
cluster_hosts[laddr]['backends'][_unit] = _laddr
|
||||
|
||||
# NOTE(jamespage) add backend based on private address - this
|
||||
# with either be the only backend or the fallback if no acls
|
||||
# NOTE(jamespage) add backend based on get_relation_ip - this
|
||||
# will either be the only backend or the fallback if no acls
|
||||
# match in the frontend
|
||||
# Network spaces aware
|
||||
addr = get_relation_ip('cluster')
|
||||
cluster_hosts[addr] = {}
|
||||
netmask = get_netmask_for_address(addr)
|
||||
cluster_hosts[addr] = {
|
||||
|
@ -605,6 +614,8 @@ class HAProxyContext(OSContextGenerator):
|
|||
}
|
||||
for rid in relation_ids('cluster'):
|
||||
for unit in sorted(related_units(rid)):
|
||||
# API Charms will need to set their private-address with
|
||||
# get_relation_ip('cluster')
|
||||
_laddr = relation_get('private-address',
|
||||
rid=rid, unit=unit)
|
||||
if _laddr:
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
CRITICAL=0
|
||||
NOTACTIVE=''
|
||||
LOGFILE=/var/log/nagios/check_haproxy.log
|
||||
AUTH=$(grep -r "stats auth" /etc/haproxy/haproxy.cfg | awk 'NR=1{print $4}')
|
||||
AUTH=$(grep -r "stats auth" /etc/haproxy/haproxy.cfg | awk 'NR=1{print $3}')
|
||||
|
||||
typeset -i N_INSTANCES=0
|
||||
for appserver in $(awk '/^\s+server/{print $2}' /etc/haproxy/haproxy.cfg)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
CURRQthrsh=0
|
||||
MAXQthrsh=100
|
||||
|
||||
AUTH=$(grep -r "stats auth" /etc/haproxy | head -1 | awk '{print $4}')
|
||||
AUTH=$(grep -r "stats auth" /etc/haproxy/haproxy.cfg | awk 'NR=1{print $3}')
|
||||
|
||||
HAPROXYSTATS=$(/usr/lib/nagios/plugins/check_http -a ${AUTH} -I 127.0.0.1 -p 8888 -u '/;csv' -v)
|
||||
|
||||
|
|
|
@ -654,11 +654,6 @@ def openstack_upgrade_available(package):
|
|||
else:
|
||||
avail_vers = get_os_version_install_source(src)
|
||||
apt.init()
|
||||
if "swift" in package:
|
||||
major_cur_vers = cur_vers.split('.', 1)[0]
|
||||
major_avail_vers = avail_vers.split('.', 1)[0]
|
||||
major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
|
||||
return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
|
||||
return apt.version_compare(avail_vers, cur_vers) == 1
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ if not six.PY3:
|
|||
else:
|
||||
from collections import UserDict
|
||||
|
||||
|
||||
CRITICAL = "CRITICAL"
|
||||
ERROR = "ERROR"
|
||||
WARNING = "WARNING"
|
||||
|
@ -344,6 +345,7 @@ class Config(dict):
|
|||
|
||||
"""
|
||||
with open(self.path, 'w') as f:
|
||||
os.fchmod(f.fileno(), 0o600)
|
||||
json.dump(self, f)
|
||||
|
||||
def _implicit_save(self):
|
||||
|
|
|
@ -175,6 +175,8 @@ class Storage(object):
|
|||
else:
|
||||
self.db_path = os.path.join(
|
||||
os.environ.get('CHARM_DIR', ''), '.unit-state.db')
|
||||
with open(self.db_path, 'a') as f:
|
||||
os.fchmod(f.fileno(), 0o600)
|
||||
self.conn = sqlite3.connect('%s' % self.db_path)
|
||||
self.cursor = self.conn.cursor()
|
||||
self.revision = None
|
||||
|
|
|
@ -21,7 +21,6 @@ extra-bindings:
|
|||
series:
|
||||
- xenial
|
||||
- artful
|
||||
- zesty
|
||||
- trusty
|
||||
provides:
|
||||
nrpe-external-master:
|
||||
|
|
|
@ -39,6 +39,7 @@ if not six.PY3:
|
|||
else:
|
||||
from collections import UserDict
|
||||
|
||||
|
||||
CRITICAL = "CRITICAL"
|
||||
ERROR = "ERROR"
|
||||
WARNING = "WARNING"
|
||||
|
@ -344,6 +345,7 @@ class Config(dict):
|
|||
|
||||
"""
|
||||
with open(self.path, 'w') as f:
|
||||
os.fchmod(f.fileno(), 0o600)
|
||||
json.dump(self, f)
|
||||
|
||||
def _implicit_save(self):
|
||||
|
|
|
@ -175,6 +175,8 @@ class Storage(object):
|
|||
else:
|
||||
self.db_path = os.path.join(
|
||||
os.environ.get('CHARM_DIR', ''), '.unit-state.db')
|
||||
with open(self.db_path, 'a') as f:
|
||||
os.fchmod(f.fileno(), 0o600)
|
||||
self.conn = sqlite3.connect('%s' % self.db_path)
|
||||
self.cursor = self.conn.cursor()
|
||||
self.revision = None
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright 2016 Canonical Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""Amulet tests on a basic neutron-api deployment on zesty-ocata."""
|
||||
|
||||
from basic_deployment import NeutronAPIBasicDeployment
|
||||
|
||||
if __name__ == '__main__':
|
||||
deployment = NeutronAPIBasicDeployment(series='zesty')
|
||||
deployment.run_tests()
|
|
@ -312,6 +312,7 @@ class HAProxyContextTest(CharmTestCase):
|
|||
with patch('builtins.__import__'):
|
||||
self.assertTrue('units' not in hap_ctxt())
|
||||
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'get_relation_ip')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'mkdir')
|
||||
@patch.object(
|
||||
charmhelpers.contrib.openstack.context, 'get_netmask_for_address')
|
||||
|
@ -330,7 +331,7 @@ class HAProxyContextTest(CharmTestCase):
|
|||
def test_context_peers(self, _open, _import, _kv, _log, _rids, _runits,
|
||||
_rget, _uget, _lunit, _config,
|
||||
_get_address_in_network, _get_netmask_for_address,
|
||||
_mkdir):
|
||||
_mkdir, _get_relation_ip):
|
||||
unit_addresses = {
|
||||
'neutron-api-0': '10.10.10.10',
|
||||
'neutron-api-1': '10.10.10.11',
|
||||
|
@ -340,6 +341,7 @@ class HAProxyContextTest(CharmTestCase):
|
|||
_rget.return_value = unit_addresses['neutron-api-0']
|
||||
_lunit.return_value = "neutron-api/1"
|
||||
_uget.return_value = unit_addresses['neutron-api-1']
|
||||
_get_relation_ip.return_value = unit_addresses['neutron-api-1']
|
||||
_config.return_value = None
|
||||
_get_address_in_network.return_value = None
|
||||
_get_netmask_for_address.return_value = '255.255.255.0'
|
||||
|
|
Loading…
Reference in New Issue