Repository navigation
[management] Add peer connected and disconnected activity events #8620
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
Closed
+366
−4
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
544e703
[management] Add peer connected and disconnected activity events
mlsmaycon 46a767e
[management] Record source IP and location on dashboard login events
mlsmaycon addea7b
[management] Skip peer session events while management restarts
mlsmaycon 519f222
[management] Address review findings on session and login events
mlsmaycon a5a96cb
[management] Stop peer session events before gRPC starts draining
mlsmaycon 8040360
[management] Move dashboard login location to its own change
mlsmaycon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package server | ||
|
|
||
| import ( | ||
| "os" | ||
| "time" | ||
|
|
||
| log "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| const ( | ||
| // EnvPeerSessionEventsStartupGrace is a Go duration, such as "2m" or "90s", during which | ||
| // a freshly started instance records no peer connect or disconnect events. "0" disables it. | ||
| EnvPeerSessionEventsStartupGrace = "NB_PEER_SESSION_EVENTS_STARTUP_GRACE" | ||
|
|
||
| defaultPeerSessionEventsStartupGrace = 2 * time.Minute | ||
| ) | ||
|
|
||
| // peerSessionEventsStartupGrace reads the startup grace window once. A missing, negative or | ||
| // unparseable value falls back to the default, and the unparseable one is logged. | ||
| func peerSessionEventsStartupGrace() time.Duration { | ||
| val := os.Getenv(EnvPeerSessionEventsStartupGrace) | ||
| if val == "" { | ||
| return defaultPeerSessionEventsStartupGrace | ||
| } | ||
| grace, err := time.ParseDuration(val) | ||
| if err != nil { | ||
| log.Warnf("failed to parse %s, using %s: %v", EnvPeerSessionEventsStartupGrace, defaultPeerSessionEventsStartupGrace, err) | ||
| return defaultPeerSessionEventsStartupGrace | ||
| } | ||
| if grace < 0 { | ||
| log.Warnf("%s must not be negative, using %s", EnvPeerSessionEventsStartupGrace, defaultPeerSessionEventsStartupGrace) | ||
| return defaultPeerSessionEventsStartupGrace | ||
| } | ||
| return grace | ||
| } | ||
|
|
||
| // StartDraining marks the instance as shutting down, so peers disconnecting from here on | ||
| // leave no peer.disconnect event. It does not change what a disconnect writes. | ||
| func (am *DefaultAccountManager) StartDraining() { | ||
| am.draining.Store(true) | ||
| } | ||
|
|
||
| // sessionEventsSuppressed reports whether peer session events are skipped: during the | ||
| // startup window, when every peer reconnects to the new instance, and while draining. | ||
| func (am *DefaultAccountManager) sessionEventsSuppressed(disconnect bool) bool { | ||
| if time.Now().Before(am.sessionEventsFrom) { | ||
| return true | ||
| } | ||
| return disconnect && am.draining.Load() | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.