Scale-in fixes

Properly handle departed and broken hooks.

Change-Id: Iecb1f943ffa5505617b5e5eb70f070458fc6645d
Closes-Bug: #1881596
This commit is contained in:
David Ames 2020-08-28 09:33:57 -07:00
parent b2ed9aa73c
commit 06675c43c9
2 changed files with 12 additions and 5 deletions

View File

@ -64,9 +64,7 @@ class MySQLSharedProvides(reactive.Endpoint):
else:
reactive.clear_flag(self.expand_name('{endpoint_name}.available'))
@reactive.when_any('endpoint.{endpoint_name}.broken',
'endpoint.{endpoint_name}.departed')
def departed(self):
def remove(self):
flags = (
self.expand_name('{endpoint_name}.connected'),
self.expand_name('{endpoint_name}.available'),
@ -74,6 +72,14 @@ class MySQLSharedProvides(reactive.Endpoint):
for flag in flags:
reactive.clear_flag(flag)
@reactive.when('endpoint.{endpoint_name}.broken')
def broken(self):
self.remove()
@reactive.when('endpoint.{endpoint_name}.departed')
def departed(self):
self.remove()
def set_db_connection_info(
self, relation_id, db_host, password,
allowed_units=None, prefix=None, wait_timeout=None, db_port=3306,

View File

@ -28,8 +28,9 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
"changed": (
"endpoint.{endpoint_name}.changed",),
"departed": ("endpoint.{endpoint_name}.broken",
"endpoint.{endpoint_name}.departed",),
"departed": ("endpoint.{endpoint_name}.departed",),
"broken": ("endpoint.{endpoint_name}.broken",),
},
}
# test that the hooks were registered