Merge lp://staging/~tealeg/landscape-client/scoped_session_ids into lp://staging/~landscape/landscape-client/trunk

Proposed by Geoff Teale
Status: Merged
Approved by: Geoff Teale
Approved revision: 711
Merged at revision: 704
Proposed branch: lp://staging/~tealeg/landscape-client/scoped_session_ids
Merge into: lp://staging/~landscape/landscape-client/trunk
Prerequisite: lp://staging/~tealeg/landscape-client/broker_handles_scoped_resynch
Diff against target: 229 lines (+81/-18)
9 files modified
landscape/broker/amp.py (+1/-1)
landscape/broker/client.py (+2/-1)
landscape/broker/exchange.py (+1/-1)
landscape/broker/server.py (+2/-2)
landscape/broker/store.py (+3/-3)
landscape/broker/tests/test_client.py (+12/-0)
landscape/broker/tests/test_exchange.py (+29/-6)
landscape/broker/tests/test_server.py (+12/-0)
landscape/broker/tests/test_store.py (+19/-4)
To merge this branch: bzr merge lp://staging/~tealeg/landscape-client/scoped_session_ids
Reviewer Review Type Date Requested Status
Chris Glass (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+173232@code.staging.launchpad.net

This proposal supersedes a proposal from 2013-07-05.

Commit message

This branch propogates the scopes parameter of get_session_id
up from the MessageStore to the MessageExchange and utilises
this parameter when registering a BrokerClientPlugin with the BrokerClient (taking the scope of the BrokerClientPlugin).

Additionally, when handling the resynchronize event (which
gets the scope from the incoming ResynchronizeRequest) we
pass the scopes parameter into drop_session_ids, which will
limit the dropping/blocking of messages to those sent with the
old session ids of those scopes.

Description of the change

This branch propogates the scopes parameter of get_session_id up from the MessageStore to the MessageExchange and utilises this parameter when registering a BrokerClientPlugin with the BrokerClient (taking the scope of the BrokerClientPlugin). Additionally, when handling the resynchronize event (which gets the scope from the incoming ResynchronizeRequest) we pass the scopes parameter into drop_session_ids, which will limit the dropping/blocking of messages to those sent with the old session ids of those scopes.

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

Nice work in keeping these branches small, it really helps. +1!

#1

         # When re-synchronisation occurs we don't want any previous messages
         # being sent to the server, dropping the existing session_ids means
         # that messages sent with those IDs will be dropped by the broker.
- self._message_store.drop_session_ids()
+ self._message_store.drop_session_ids(scopes)

Please expand the comment mentioning that only the session IDs for the specified scopes will be dropped (or all of them if scopes is None).

#2

- def get_session_id(self):
+ def get_session_id(self, scope=None):

There should be a @param entry for the new parameter, in the method docstring.

#3

- def drop_session_ids(self, scope=None):
+ def drop_session_ids(self, scopes=None):
         """
         Drop all session ids.
         """

Please update the method docstring and document the new parameter.

#4

+ test_session_id = self.successResultOf(
+ self.client.broker.get_session_id(scope="test"))

Opinionated nitpick: since this is using 2 lines anyways, I find it generally better to split it like this:

        deferred = self.client.broker.get_session_id(scope="test")
        test_session_id = self.successResultOf(deferred)

because imo there's less parsing work going on in one's mind when reading the code. This is really minor (and I guess a counter argument could be made), so your call.

#5

+ global_scope = []
+ self.reactor.fire("resynchronize-clients", global_scope)

This is probably a leftover, you can just:

        self.reactor.fire("resynchronize-clients")

which defaults to the global scope.

#6

+ self.assertMessages(messages, [{"type": "empty"}])

This doesn't test which one of the 2 sessions IDs generated the message exactly, it'd be nice to use 2 different message types I guess. Maybe it's not needed from a strict unit-test point of view, since I believe test_drop_multiple_scopes from test_store.py covers that. Your call.

review: Approve
Revision history for this message
Chris Glass (tribaal) wrote :

I was going to add comments similar to free's #1 , #2 and #3, but he did already.

# WARNING #
This branch will break trunk pretty badly until all other plugin branches have landed. This branch must therefore land *last*, since the plugins branches have a backwards-compatible behavior (they treat resynchronize events as global events by default).

I will disapprove this branch until all plugin branches have landed, and test pass again.

review: Disapprove
Revision history for this message
Chris Glass (tribaal) wrote :

I will retract my previous statement - this *can* land first, with the following fix: https://pastebin.canonical.com/94185/

So, +1, and sorry for the drama :)

review: Approve
Revision history for this message
Geoff Teale (tealeg) wrote :

> I will retract my previous statement - this *can* land first, with the
> following fix: https://pastebin.canonical.com/94185/
>
> So, +1, and sorry for the drama :)

No trouble, I love a drama queen, me :-)

Done.

Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: