Browse code

Fix event filter filtering on "or"

The event filter used two separate filter-conditions for
"namespace" and "topic". As a result, both events matching
"topic" and events matching "namespace" were subscribed to,
causing events to be handled both by the "plugin" client, and
"container" client.

This patch rewrites the filter to match only if both namespace
and topic match.

Thanks to Stephen Day for providing the correct filter :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2017/12/29 10:47:56
Showing 1 changed files
... ...
@@ -715,8 +715,9 @@ func (c *client) processEventStream(ctx context.Context) {
715 715
 
716 716
 	eventStream, err = c.remote.EventService().Subscribe(ctx, &eventsapi.SubscribeRequest{
717 717
 		Filters: []string{
718
-			"namespace==" + c.namespace,
719
-			"topic~=/tasks/",
718
+			// Filter on both namespace *and* topic. To create an "and" filter,
719
+			// this must be a single, comma-separated string
720
+			"namespace==" + c.namespace + ",topic~=|^/tasks/|",
720 721
 		},
721 722
 	}, grpc.FailFast(false))
722 723
 	if err != nil {