implement reactive.Endpoint.manage_flags to clear flags on departed hook

Change-Id: Ie2e6d8ec460311fa4e63335f322aaae07dca5842
This commit is contained in:
Adam Dyess 2022-11-28 16:06:12 -06:00
parent 3ca251fb01
commit d9f3b53ca0
2 changed files with 20 additions and 0 deletions

View File

@ -72,6 +72,16 @@ class CephRequires(reactive.Endpoint):
else:
log("incomplete request. broker_req not found")
def manage_flags(self):
"""
Set states corresponding to the data we have.
"""
reactive.toggle_flag(
self.expand_name("{endpoint_name}.connected"), self.is_joined
)
if not self.is_joined:
self.broken()
def broken(self):
reactive.clear_flag(
self.expand_name('{endpoint_name}.available'))

View File

@ -180,6 +180,16 @@ class TestCephClientRequires(unittest.TestCase):
# Side effect of asserting pools.available was not set.
self.set_flag.assert_called_once_with('some-relation.available')
def test_manage_flags(self):
self.cr.manage_flags()
self.clear_flag.assert_has_calls(
[
mock.call("some-relation.available"),
mock.call("some-relation.connected"),
mock.call("some-relation.pools.available"),
]
)
def test_broken(self):
self.cr.broken()
self.clear_flag.assert_has_calls([