diff --git a/octavia/amphorae/backends/utils/haproxy_query.py b/octavia/amphorae/backends/utils/haproxy_query.py index e227edc3b6..d4c484d7ac 100644 --- a/octavia/amphorae/backends/utils/haproxy_query.py +++ b/octavia/amphorae/backends/utils/haproxy_query.py @@ -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: diff --git a/octavia/common/constants.py b/octavia/common/constants.py index 3dba6a82ff..ec70b64696 100644 --- a/octavia/common/constants.py +++ b/octavia/common/constants.py @@ -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) diff --git a/octavia/controller/healthmanager/update_health_mixin.py b/octavia/controller/healthmanager/update_health_mixin.py index 05d372e6e8..243d54c377 100644 --- a/octavia/controller/healthmanager/update_health_mixin.py +++ b/octavia/controller/healthmanager/update_health_mixin.py @@ -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, diff --git a/octavia/db/migration/alembic_migrations/versions/3b199c848b96_create_no_monitor_operational_status.py b/octavia/db/migration/alembic_migrations/versions/3b199c848b96_create_no_monitor_operational_status.py new file mode 100644 index 0000000000..7f8305b66b --- /dev/null +++ b/octavia/db/migration/alembic_migrations/versions/3b199c848b96_create_no_monitor_operational_status.py @@ -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'}]) diff --git a/octavia/tests/unit/controller/healthmanager/test_health_mixin.py b/octavia/tests/unit/controller/healthmanager/test_health_mixin.py index cb735ea40c..b4db69127d 100644 --- a/octavia/tests/unit/controller/healthmanager/test_health_mixin.py +++ b/octavia/tests/unit/controller/healthmanager/test_health_mixin.py @@ -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):