From b61e9e8d14f5ab1ed4e0bf45cc1657a313855713 Mon Sep 17 00:00:00 2001 From: Cameron Johnston Date: Wed, 3 Aug 2016 23:58:39 -0600 Subject: [PATCH] Treat fanout (client) subscriptions as a no-op As documented in [issue #5][1], clients with subscriptions defined encounter exceptions when they attempt to process check results as check requests. With Sensu's forthcoming [native silencing implementation][2], each client definition will include a subscription for "client:$CLIENT_NAME". For the purposes of this silencing implementation, it's not important that the client consume check requests from this subscription, but it is important that the subscription is present in the client definition sent via keepalive messages. When Sensu processes call `subscribe()` on the transport object, they pass a queue type. Sensu server processes subscribe with type `:direct` while Sensu client processes use type `:fanout`. This distinction makes it possible for us to treat client subscriptions for this transport as a no-op. [1]: https://github.com/SimpleFinance/sensu-transport-snssqs/issues/5 [2]: https://github.com/sensu/sensu/issues/1328 --- lib/sensu/transport/snssqs.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/sensu/transport/snssqs.rb b/lib/sensu/transport/snssqs.rb index 84832da..2c40ce3 100644 --- a/lib/sensu/transport/snssqs.rb +++ b/lib/sensu/transport/snssqs.rb @@ -65,6 +65,10 @@ def statsd_time(stat) # subscribe will begin "subscribing" to the consuming sqs queue. # + # This method is intended for use by the Sensu server; fanout + # subscriptions initiated by the Sensu client process are + # treated as a no-op. + # # What this really means is that we will start polling for # messages from the SQS queue, and, depending on the message # type, it will call the appropriate callback. @@ -77,6 +81,11 @@ def statsd_time(stat) # # "funnel" and "type" parameters are completely ignored. def subscribe(type, pipe, funnel = nil, options = {}, &callback) + if type == :fanout + self.logger.debug("skipping unsupported fanout subscription type=#{type}, pipe=#{pipe}, funnel=#{funnel}") + return + end + self.logger.info("subscribing to type=#{type}, pipe=#{pipe}, funnel=#{funnel}") if pipe == KEEPALIVES_STR