Adds the NO_MONITOR operational status for members

When no health monitor is assigned to a member HAProxy returns
"no_check" as the status for the server.  This change will pull
that forward into Octavia as member operational_status "NO_MONITOR"

Closes-Bug: 1491936
Change-Id: Ifefd2bddf8999c75397bf7c693042003e0f8a382
This commit is contained in:
Michael Johnson 2015-09-03 16:31:48 +00:00
parent ccd7865350
commit c421056956
5 changed files with 88 additions and 2 deletions

View File

@ -117,7 +117,8 @@ class HAProxyQuery(object):
# pxname: pool, svname: server_name, status: status
# All the way up is UP, otherwise call it DOWN
if line['status'] != consts.UP:
if (line['status'] != consts.UP and
line['status'] != consts.NO_CHECK):
line['status'] = consts.DOWN
if line['pxname'] not in final_results:

View File

@ -66,7 +66,8 @@ ONLINE = 'ONLINE'
OFFLINE = 'OFFLINE'
DEGRADED = 'DEGRADED'
ERROR = 'ERROR'
SUPPORTED_OPERATING_STATUSES = (ONLINE, OFFLINE, DEGRADED, ERROR)
NO_MONITOR = 'NO_MONITOR'
SUPPORTED_OPERATING_STATUSES = (ONLINE, OFFLINE, DEGRADED, ERROR, NO_MONITOR)
AMPHORA_VM = 'VM'
SUPPORTED_AMPHORA_TYPES = (AMPHORA_VM,)
@ -158,3 +159,7 @@ DOWN = 'DOWN'
# UP = HAProxy backend has working or no servers
# DOWN = HAProxy backend has no working servers
HAPROXY_BACKEND_STATUSES = (UP, DOWN)
NO_CHECK = 'no check'
HAPROXY_MEMBER_STATUSES = (UP, DOWN, NO_CHECK)

View File

@ -149,6 +149,8 @@ class UpdateHealthMixin(driver_base.HealthMixin):
pool_status = constants.DEGRADED
if lb_status == constants.ONLINE:
lb_status = constants.DEGRADED
elif status == constants.NO_CHECK:
member_status = constants.NO_MONITOR
else:
LOG.warn(_LW('Member %(mem)s reported status of '
'%(status)s'), {'mem': member_id,

View File

@ -0,0 +1,34 @@
# Copyright 2015 Hewlett-Packard Development Company, L.P.
#
# 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.
"""Create NO_MONITOR operational_status
Revision ID: 3b199c848b96
Revises: 543f5d8e4e56
Create Date: 2015-09-03 17:11:03.724070
"""
# revision identifiers, used by Alembic.
revision = '3b199c848b96'
down_revision = '543f5d8e4e56'
from alembic import op
import sqlalchemy as sa
def upgrade():
bind = op.get_bind()
md = sa.MetaData()
sa.Table('operating_status', md, autoload=True, autoload_with=bind)
op.bulk_insert(md.tables['operating_status'], [{'name': 'NO_MONITOR'}])

View File

@ -135,6 +135,50 @@ class TestUpdateHealthMixin(base.TestCase):
self.hm.update_health(health)
@mock.patch('octavia.db.api.get_session')
def test_update_health_member_no_check(self, session):
health = {
"id": self.FAKE_UUID_1,
"listeners": {
"listener-id-1": {"status": constants.OPEN, "pools": {
"pool-id-1": {"status": constants.UP,
"members": {"member-id-1":
constants.NO_CHECK}
}
}
}
}
}
session.return_value = 'blah'
self.hm.update_health(health)
self.assertTrue(self.amphora_health_repo.replace.called)
# test listener, member
for listener_id, listener in six.iteritems(
health.get('listeners', {})):
self.listener_repo.update.assert_any_call(
'blah', listener_id, operating_status=constants.ONLINE)
for pool_id, pool in six.iteritems(listener.get('pools', {})):
self.hm.pool_repo.update.assert_any_call(
'blah', pool_id, operating_status=constants.ONLINE)
for member_id, member in six.iteritems(
pool.get('members', {})):
self.member_repo.update.assert_any_call(
'blah', id=member_id,
operating_status=constants.NO_MONITOR)
self.hm.listener_repo.count.return_value = 2
self.hm.update_health(health)
@mock.patch('octavia.db.api.get_session')
def test_update_health_list_full_member_down(self, session):