Skip to content
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

Add controller performance metrics #391

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9283e2f
Added GameServer control performance metrics;
dsmith111 Sep 15, 2022
466f2af
Merge branch 'main' of https://github.com/dsmith111/thundernetes into…
dsmith111 Sep 15, 2022
71fd931
Merge branch 'main' into smithdavi/add-controller-performance-metrics
dsmith111 Sep 15, 2022
f432e82
Update monitoring documentation;
dsmith111 Sep 15, 2022
baa71f4
Merge branch 'smithdavi/add-controller-performance-metrics' of https:…
dsmith111 Sep 15, 2022
41e68da
Update yaml
dsmith111 Sep 17, 2022
e9cd4fb
Fix capitalization
dsmith111 Sep 17, 2022
293efc1
Revert extra changes triggering installfile alret
dsmith111 Sep 17, 2022
dc28b13
Handle dereferencing;
dsmith111 Sep 18, 2022
c2a122e
Add pointers
dsmith111 Sep 19, 2022
38c7592
Decreasing time diff
dsmith111 Sep 19, 2022
dbd8b71
Merge branch 'main' into smithdavi/add-controller-performance-metrics
dsmith111 Sep 19, 2022
ecebe2b
PR Updates;
dsmith111 Sep 19, 2022
d8f0d88
Merge branch 'smithdavi/add-controller-performance-metrics' of github…
dsmith111 Sep 19, 2022
e41d915
Add patching exception
dsmith111 Sep 21, 2022
b7ed55e
Merge branch 'main' into smithdavi/add-controller-performance-metrics
dsmith111 Sep 21, 2022
0be080c
Change metric emission to nodeagent
dsmith111 Sep 25, 2022
20be9c0
Update dashboard
dsmith111 Sep 25, 2022
6e30235
Merge branch 'main' of github.com:dsmith111/thundernetes into smithda…
dsmith111 Sep 25, 2022
e0fc978
Revert test
dsmith111 Sep 25, 2022
a67fbb9
Cleanup deletes
dsmith111 Sep 25, 2022
0cd6e86
Minor tweaks
dsmith111 Sep 25, 2022
c4217f8
Conditional
dsmith111 Sep 25, 2022
77b1c88
PR Suggested changes
dsmith111 Sep 26, 2022
feab86c
Remove spacing added to gameserverbuild
dsmith111 Sep 26, 2022
d0dbb61
Remove empty line in nodeagent
dsmith111 Sep 26, 2022
b3e07d9
Renaming
dsmith111 Sep 26, 2022
fd2fbae
Update dashboard
dsmith111 Sep 26, 2022
9318c35
Remove metric
dsmith111 Sep 26, 2022
1861a24
Merge branch 'main' into smithdavi/add-controller-performance-metrics
dgkanatsios Sep 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@ installfilesdev

.uptodate

# vscode settings
.vscode

# allocator compiled plugin
kubectl-gameserver
4 changes: 4 additions & 0 deletions cmd/nodeagent/nodeagentmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,12 @@ func (n *NodeAgentManager) updateHealthAndStateIfNeeded(ctx context.Context, hb
now := metav1.Time{Time: n.nowFunc()}
if hb.CurrentGameState == GameStateInitializing {
status.ReachedInitializingOn = &now
timeDif := time.Now().UnixMilli() - gsd.CreationTime
GameServerReachedInitializingDuration.WithLabelValues(gsd.BuildName).Set(float64(timeDif))
} else if hb.CurrentGameState == GameStateStandingBy {
status.ReachedStandingByOn = &now
timeDif := time.Now().UnixMilli() - gsd.CreationTime
GameServerReachedStandingByDuration.WithLabelValues(gsd.BuildName).Set(float64(timeDif))
}
}

Expand Down
18 changes: 18 additions & 0 deletions cmd/nodeagent/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ var (
Name: "connected_players",
Help: "Number of connected players per GameServer",
}, []string{"namespace", "ServerName", "BuildName"})

GameServerReachedStandingByDuration = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "thundernetes",
Name: "gameserver_standing_by_duration",
Help: "Time taken for a GameServer to reach StandingBy",
},
[]string{"BuildName"},
)

GameServerReachedInitializingDuration = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "thundernetes",
Name: "gameserver_initialization_duration",
Help: "Time taken for a GameServer to reach initialization",
},
[]string{"BuildName"},
)
)

// HeartbeatRequest contains data for the heartbeat request coming from the GSDK running alongside GameServer
Expand Down
2 changes: 2 additions & 0 deletions docs/howtos/monitoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ There is a custom Grafana dashboard example that visualizes some of this data in
| --- | --- | --- |
| gameserver_states | Gauge | nodeagent |
| connected_players | Gauge | nodeagent |
| gameserver_initialization_duration | Gauge | nodeagent |
| gameserver_standing_by_duration | Gauge | nodeagent |
| gameservers_current_state_per_build | Gauge | controller-manager |
| gameservers_created_total | Counter | controller-manager |
| gameservers_sessionended_total | Counter | controller-manager |
Expand Down
15 changes: 7 additions & 8 deletions pkg/operator/controllers/gameserverbuild_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,18 @@ func (r *GameServerBuildReconciler) Reconcile(ctx context.Context, req ctrl.Requ
// calculate the total amount of servers not in the active state
nonActiveGameServersCount := standingByCount + initializingCount + pendingCount

// Evaluate desired number of servers against actual
var totalNumberOfGameServersToDelete int = 0
// user has decreased standingBy numbers
if nonActiveGameServersCount > gsb.Spec.StandingBy {
totalNumberOfGameServersToDelete := int(math.Min(float64(nonActiveGameServersCount-gsb.Spec.StandingBy), maxNumberOfGameServersToDelete))
err := r.deleteNonActiveGameServers(ctx, &gsb, &gameServers, totalNumberOfGameServersToDelete)
if err != nil {
return ctrl.Result{}, err
}
totalNumberOfGameServersToDelete += int(math.Min(float64(nonActiveGameServersCount-gsb.Spec.StandingBy), maxNumberOfGameServersToDelete))
}

// we need to check if we are above the max
// we also need to check if we are above the max
// this can happen if the user modifies the spec.Max during the GameServerBuild's lifetime
if nonActiveGameServersCount+activeCount > gsb.Spec.Max {
totalNumberOfGameServersToDelete := int(math.Min(float64(nonActiveGameServersCount+activeCount-gsb.Spec.Max), maxNumberOfGameServersToDelete))
totalNumberOfGameServersToDelete += int(math.Min(float64(totalNumberOfGameServersToDelete+(nonActiveGameServersCount+activeCount-gsb.Spec.Max)), maxNumberOfGameServersToDelete))
}
if totalNumberOfGameServersToDelete > 0 {
err := r.deleteNonActiveGameServers(ctx, &gsb, &gameServers, totalNumberOfGameServersToDelete)
if err != nil {
return ctrl.Result{}, err
Expand Down
Loading