New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/monitor #1699

Merged
merged 12 commits into from Jun 22, 2018

Conversation

Projects
None yet
3 participants
@mercul3s
Contributor

mercul3s commented Jun 20, 2018

What is this change?

Adds an etcd backed monitor implementation.

Why is this change necessary?

Closes #1674

Does your change need a Changelog entry?

Maybe not yet? This code is not yet integrated and doesn't change any system behavior. Happy to add one if necessary, or can update the changelog when integrated.

Do you need clarification on anything?

Nope!

Were there any complications while making this change?

This refactor exists alongside the current implementation, and shares some naming. Due to that, there are a few long names for functions or variables that exist in both files that should be changed when we factor out the in-memory monitor.

Have you reviewed and updated the documentation for this change? Is new documentation required?

Nope!

@mercul3s mercul3s requested review from echlebek, cyphus and nikkiki Jun 20, 2018

@echlebek

Looking forward to seeing this replacing this our existing monitor. 💪

Show outdated Hide outdated backend/monitor/monitors.go Outdated
Show outdated Hide outdated backend/monitor/monitors.go Outdated
e(err)
}
// EtcdService is an etcd backend monitor service based on leased keys. Each key

This comment has been minimized.

@echlebek

echlebek Jun 20, 2018

Contributor

I think this sentence would be more clear if it were just:

EtcdService is an etcd backend monitor service based on leased keys. Each key
has a watcher that waits for a DELETE or PUT event and calls a handler.
@echlebek

echlebek Jun 20, 2018

Contributor

I think this sentence would be more clear if it were just:

EtcdService is an etcd backend monitor service based on leased keys. Each key
has a watcher that waits for a DELETE or PUT event and calls a handler.
Show outdated Hide outdated backend/monitor/monitors_test.go Outdated
Show outdated Hide outdated backend/monitor/monitors_test.go Outdated
@nikkiki

Excellent test cases.. great work 💯Just those 2 remaining comments and you're good to go 😎

Show outdated Hide outdated backend/monitor/monitors_test.go Outdated
@echlebek

There's a few more doc changes I'd like to see, then SHIP IT 🚢 :shipit: 👍

Show outdated Hide outdated backend/monitor/monitors.go Outdated
Show outdated Hide outdated backend/monitor/monitors.go Outdated
Show outdated Hide outdated backend/monitor/monitors.go Outdated
Show outdated Hide outdated backend/monitor/monitors.go Outdated
@nikkiki

This comment has been minimized.

Show comment
Hide comment
@nikkiki

nikkiki Jun 21, 2018

Contributor

How did "Don't break the build" actually break the build 😆

go : # github.com/sensu/sensu-go/backend/monitor
166At C:\gopath\src\github.com\sensu\sensu-go\build.ps1:215 char:5
167+     go test -timeout=200s -tags=integration $(go list ./... | Select- ...
168+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169    + CategoryInfo          : NotSpecified: (# github.com/se...backend/monitor:String) [], RemoteException
170    + FullyQualifiedErrorId : NativeCommandError
171 
172backend\monitor\monitors_test.go:98:9: no new variables on left side of :=
Contributor

nikkiki commented Jun 21, 2018

How did "Don't break the build" actually break the build 😆

go : # github.com/sensu/sensu-go/backend/monitor
166At C:\gopath\src\github.com\sensu\sensu-go\build.ps1:215 char:5
167+     go test -timeout=200s -tags=integration $(go list ./... | Select- ...
168+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
169    + CategoryInfo          : NotSpecified: (# github.com/se...backend/monitor:String) [], RemoteException
170    + FullyQualifiedErrorId : NativeCommandError
171 
172backend\monitor\monitors_test.go:98:9: no new variables on left side of :=

mercul3s added some commits Jun 13, 2018

WIP sketch of monitors refactor.
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Initial rough draft etcd based monitors
Implementation is based on a leased key and watcher per monitor.
GetMonitor either creates a key or extends a ttl, and starts a watch
operation that is set to trigger a handler when a DELETE operation is
called in etcd.

Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Refactor monitors to use etcd
Monitors are based on a leased key in etcd. A watcher waits for a DELETE
event and fires a failure handler when that event is seen. If a key has
a PUT event, its watcher is terminated to avoid multiple watchers on the
same key.

Co-authored by: Mercedes Coyle <mercedes@sensu.io>
Co-authored by: Eric Chlebek eric@sensu.io

Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Generalized watchMon func and added tests
Co-authored by: Mercedes Coyle <mercedes@sensu.io>
Co-authored by: Eric Chlebek eric@sensu.io

Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Added tests for getting monitors
Tested getMonitor and GetMonitor. Removed TestMonitorsHandleUpdate as it
seemed ineffective.

Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Moar tests for the monitor
Added tests to verify GetMonitor creates new monitors and extends TTLs.
Removed transaction for put since we are occasionally modifying the
keys.

Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Appease linter and ensure comments are useful
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Address PR comments
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
I always forget the printlns
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Don't break the build
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Fix error var assignment
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>
Commentary
Signed-off-by: Mercedes Coyle <mercedes@sensu.io>

@mercul3s mercul3s merged commit 20d5a39 into master Jun 22, 2018

3 checks passed

DCO All commits have a DCO sign-off from the author
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@mercul3s mercul3s deleted the refactor/monitor branch Jun 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment