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

Better tracking ConnectedPlayers #48

Merged
merged 6 commits into from
Nov 4, 2021
Merged

Better tracking ConnectedPlayers #48

merged 6 commits into from
Nov 4, 2021

Conversation

dgkanatsios
Copy link
Collaborator

This PR does a bunch of things.

  • introduces a new CRD, GameServerDetail. For the time being it tracks
    • the InitialPlayers string array that can be used by the GameServer process to validate players that connect to the game session when it starts
    • the ConnectedPlayersCount that measures the number of people connected into the game
  • the GameServerDetail has the same name as the GameServer. Moreover, the GameServer is its owner, so when it is deleted, the GameServerDetail will be deleted as well
  • BREAKING CHANGE The InitialPlayers is removed from the GameServer.Status
  • Above fixes Better track ConnectedPlayers #35 (you can also find the design process there)
  • introduces logrus for structure. Partially fixes Structured Log output #36
  • introduces relevant e2e tests

I also wanted to rename the httphandler struct and file as part of #37, but I'll do that on a separate PR, since this one is already big.

@dgkanatsios dgkanatsios added area/tests Make sure things don't break, unit tests. enhancement New feature or request labels Oct 29, 2021
@khaines
Copy link
Collaborator

khaines commented Oct 29, 2021

Some minor comments and nits, but otherwise LGTM!

metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: this field can be removed, since it is null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is auto-generated when running make. Probably the controller-gen utility does it :(


fmt.Printf("Got values from allocation, sessionID:%s, sessionCookie:%s, initialPlayers:%#v\n", sessionID, sessionCookie, initialPlayers)
initialPlayers := h.getInitialPlayersDetails()
log.Infof("Got values from allocation, initialPlayers:%#v", initialPlayers)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could be referencing a nil slice here, if there was an error in getInitialPlayerDetails

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah gotcha - will this panic though?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't, because you are looking at the slice itself, vs a property of it.

sidecar-go/httphandler.go Outdated Show resolved Hide resolved
@@ -157,34 +183,41 @@ func (h *httpHandler) heartbeatHandler(w http.ResponseWriter, req *http.Request)
}

if logEveryHeartbeat {
fmt.Printf("heartbeat received from sessionHostId %s, data %#v\n", sessionHostId, hb)
log.Infof("heartbeat received from sessionHostId %s, data %#v", sessionHostId, hb)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: For outputing regular "succcess" or "it works" text, consider the debug severity. Info has always felt to me to be used for significant events in a system, which don't happen frequently.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Should we have an env variable specifying the log level?

sidecar-go/httphandler.go Outdated Show resolved Hide resolved

func (h *httpHandler) updateConnectedPlayersCountIfNeeded(ctx context.Context, hb *HeartbeatRequest) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a player count metric exposed may be useful as well, so that prometheus can track and graph this in grafana. totally something that can be done in a follow on PR.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome idea, created #49 to track

@dgkanatsios dgkanatsios merged commit 1d903d2 into master Nov 4, 2021
@dgkanatsios dgkanatsios deleted the gameserverdetails branch November 4, 2021 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tests Make sure things don't break, unit tests. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Structured Log output Better track ConnectedPlayers
2 participants