sensu / sensu-go

Simple. Scalable. Multi-cloud monitoring.
https://sensu.io
MIT License
1.02k stars 175 forks source link

Silencing is broken when using an entity subscription #707

Closed palourde closed 6 years ago

palourde commented 6 years ago

Expected Behavior

When creating a silenced entry for a particular check of a specific subscription (e.g. entity:i-424242:check_silencing), I expect that only the check_silencing check for the i-424242 entity will be silenced.

Current Behavior

All checks under the i-424242 subscription are silenced:

$ sensuctl silenced list
            ID                 Subscription       Check   Expire   ExpireOnResolve   Creator   Reason   Organization   Environment
 ───────────────────────── ───────────────────── ─────── ──────── ───────────────── ───────── ──────── ────────────── ─────────────
  entity:scotch.local:foo   entity:scotch.local   foo     -1s      true              admin              default        default
$ sensuctl event list
     Entity         Check                  Output               Status   Silenced             Timestamp
 ────────────── ────────────── ─────────────────────────────── ──────── ────────── ───────────────────────────────
  scotch.local   check_echo     sh: echo 0: command not found      127   true       2017-12-08 10:53:39 -0500 EST
  scotch.local   foo                                                 1   true       2017-12-08 10:54:21 -0500 EST
  scotch.local   keepalive                                           0   true       2017-12-08 10:54:19 -0500 EST

To be verified: does it only affect entity:entityid subscriptions?

Possible Solution

I suspect something goes wrong in this function, maybe the additional colon in the subscription? https://github.com/sensu/sensu-go/blob/c979f69ff3d010026b05e7915b9435289efc576c/backend/eventd/silenced.go#L11-L42

palourde commented 6 years ago

This use case can be tested with this chunk of code that exists in: https://github.com/sensu/sensu-go/blob/38067e0d5d40bcb1e773d70211a400ad16a79484/testing/e2e/silencing_test.go#L111-L119