Skip to content

Commit

Permalink
Open Match Services: Cleanup and Updates (#261)
Browse files Browse the repository at this point in the history
* Updated dependencies for Open Match Director
* Updated deprecated API calls on Open Match Director.
* Remove fake-frontend as nobody was using it, and its dependencies
where getting out of date
* Update dependencies for the Match Function
* Update deprecated APIs for the Match function.
  • Loading branch information
markmandel committed May 23, 2024
1 parent a0bec03 commit 4148019
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 375 deletions.
9 changes: 1 addition & 8 deletions services/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ steps:
args: [ "build", ".", "-t", "${_OPEN_MATCH_MATCHFUNCTION_IMAGE}" ]
dir: open-match/matchfunction
waitFor: [ '-' ]
- name: gcr.io/cloud-builders/docker
id: open-match-fake-frontend
args: [ "build", ".", "-t", "${_OPEN_MATCH_FAKE_FRONTEND_IMAGE}" ]
dir: open-match/fake-frontend
waitFor: [ '-' ]

#
# Deployment
Expand All @@ -61,7 +56,7 @@ steps:
--annotations=cloud_build=https://console.cloud.google.com/cloud-build/builds/$BUILD_ID \
--delivery-pipeline global-game-services \
--skaffold-file skaffold.yaml \
--images ping-discovery=$_PING_IMAGE,profile=$_PROFILE_IMAGE,frontend=$_FRONTEND_IMAGE,open-match-director=$_OPEN_MATCH_DIRECTOR_IMAGE,open-match-matchfunction=$_OPEN_MATCH_MATCHFUNCTION_IMAGE,open-match-fake-frontend=$_OPEN_MATCH_FAKE_FRONTEND_IMAGE \
--images ping-discovery=$_PING_IMAGE,profile=$_PROFILE_IMAGE,frontend=$_FRONTEND_IMAGE,open-match-director=$_OPEN_MATCH_DIRECTOR_IMAGE,open-match-matchfunction=$_OPEN_MATCH_MATCHFUNCTION_IMAGE \
--region us-central1
automapSubstitutions: true

Expand All @@ -72,14 +67,12 @@ artifacts:
- ${_REGISTRY}/frontend
- ${_REGISTRY}/open-match-director
- ${_REGISTRY}/open-match-matchfunction
- ${_REGISTRY}/open-match-fake-frontend
substitutions:
_PING_IMAGE: ${_REGISTRY}/ping-discovery:${BUILD_ID}
_PROFILE_IMAGE: ${_REGISTRY}/profile:${BUILD_ID}
_FRONTEND_IMAGE: ${_REGISTRY}/frontend:${BUILD_ID}
_OPEN_MATCH_DIRECTOR_IMAGE: ${_REGISTRY}/open-match-director:${BUILD_ID}
_OPEN_MATCH_MATCHFUNCTION_IMAGE: ${_REGISTRY}/open-match-matchfunction:${BUILD_ID}
_OPEN_MATCH_FAKE_FRONTEND_IMAGE: ${_REGISTRY}/open-match-fake-frontend:${BUILD_ID}
_REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/global-game-images
options:
dynamic_substitutions: true
Expand Down
25 changes: 0 additions & 25 deletions services/open-match/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,6 @@ given set of match player's latencies.
It does this by providing the `region` HTTP header to an Anthos Service Mesh Allocation Service - where the `region`
header will route the allocation request to one of the Agones GKE clusters in that region.

## Fake Frontend

The `openmatch-fake-frontend` deployment generates fake tickets for testing of the Open Match services
in thie directory. When enabled, the fake frontend will generate a batch of tickets every period. For
each ticket, the fake frontend waits on an Open Match assignment and then deletes the ticket.

Note that if the Director is tied to a real Agones Fleet, this will generate arbitrary game server
allocations. You may want to use a game server binary that exits after a specific period of time,
otherwise, when enabled, the fake frontend will continue to allocate game servers.

The fake frontend is always deployed, but does nothing unless configured:

```shell
# Edit the `period` and `tickets_per_period` to what you want, e.g. "20s" and "20"
# The fake frontend will generate `tickets_per_period` tickets every `period`, where
# period is expressed as a Go Duration (e.g. "20s", "1m", etc.)
kubectl edit configmap/open-match-fake-frontend

# Restart the deployment to pick up the config
kubectl rollout restart deployment/open-match-fake-frontend

# Verify load has started
kubectl logs deployment/open-match-fake-frontend
```

## Credit

This integration is based on the [Open Match Matchmaker 101 tutorial](https://open-match.dev/site/docs/tutorials/matchmaker101/frontend/) [(source)](https://github.com/googleforgames/open-match/tree/release-1.7/tutorials).
2 changes: 1 addition & 1 deletion services/open-match/director/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

FROM golang:1.19 as build
FROM golang:1.21 as build

WORKDIR /go/src/director
COPY . .
Expand Down
25 changes: 13 additions & 12 deletions services/open-match/director/go.mod
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
module github.com/googleforgames/global-multiplayer-demo/services/open-match/director

go 1.19
go 1.21

toolchain go1.21.9

require (
golang.org/x/oauth2 v0.4.0
google.golang.org/grpc v1.53.0
open-match.dev/open-match v1.7.0
golang.org/x/oauth2 v0.20.0
google.golang.org/grpc v1.64.0
open-match.dev/open-match v1.8.1
)

require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/protobuf v1.28.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/protobuf v1.34.1 // indirect
)
58 changes: 22 additions & 36 deletions services/open-match/director/go.sum
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0 h1:1JYBfzqrWPcCclBwxFCPAou9n+q86mfnu7NAeHfte7A=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.15.0/go.mod h1:YDZoGHuwE+ov0c8smSH49WLF3F2LaWnYYuDVd+EWrc0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
open-match.dev/open-match v1.7.0 h1:EzPPzsMy92i52XNrRWx3KMXIcNzdgHwMd01KsoT7HaI=
open-match.dev/open-match v1.7.0/go.mod h1:JAkoEIVgc8p6GnfpxOC5Aqby2vkQDHrjlCbI2crP3WU=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e h1:SkdGTrROJl2jRGT/Fxv5QUf9jtdKCQh4KQJXbXVLAi0=
google.golang.org/genproto/googleapis/api v0.0.0-20240521202816-d264139d666e/go.mod h1:LweJcLbyVij6rCex8YunD8DYR5VDonap/jYl3ZRxcIU=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e h1:Elxv5MwEkCI9f5SkoL6afed6NTdxaGoAo39eANBwHL8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
open-match.dev/open-match v1.8.1 h1:Tp5fxeUVBugt091zFxMJim6TalE9sFDB2mNGw5zRWQQ=
open-match.dev/open-match v1.8.1/go.mod h1:FjKE1hS+BGFMxVUQvPLqXWMUjjFysYrPESdEfEpDxvM=
11 changes: 6 additions & 5 deletions services/open-match/director/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package main

import (
"context"
"errors"
"fmt"
"io"
"log"
Expand All @@ -24,6 +25,7 @@ import (

allocation "github.com/googleforgames/global-multiplayer-demo/services/open-match/director/agones/swagger"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"open-match.dev/open-match/pkg/pb"
)

Expand Down Expand Up @@ -52,7 +54,7 @@ func main() {
ctx := context.Background()

// Connect to Open Match Backend.
conn, err := grpc.Dial(omBackendEndpoint, grpc.WithInsecure())
conn, err := grpc.NewClient(omBackendEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("Failed to connect to Open Match Backend, got %s", err.Error())
}
Expand Down Expand Up @@ -137,10 +139,9 @@ func fetch(be pb.BackendServiceClient, p *pb.MatchProfile) ([]*pb.Match, error)
func assignMatch(ctx context.Context, be pb.BackendServiceClient, aas *allocation.APIClient, match *pb.Match) {
aar, _, err := aas.AllocationServiceApi.Allocate(ctx, allocation.AllocationAllocationRequest{Namespace: gameNamespace})
if err != nil {
if swErr, ok := err.(allocation.GenericSwaggerError); ok {
var swErr allocation.GenericSwaggerError
if errors.As(err, &swErr) {
log.Printf("Could not allocate game server from Agones for match %s: %s: %s", match.GetMatchId(), swErr.Error(), swErr.Body())
} else {
log.Printf("Could not allocate game server from Agones for match %s (generic error): %v", match.GetMatchId(), err)
}
return
}
Expand All @@ -160,7 +161,7 @@ func assignMatch(ctx context.Context, be pb.BackendServiceClient, aas *allocatio
}

func assignConnToTickets(be pb.BackendServiceClient, conn string, tickets []*pb.Ticket) error {
ticketIDs := []string{}
var ticketIDs []string
for _, t := range tickets {
ticketIDs = append(ticketIDs, t.Id)
}
Expand Down
32 changes: 0 additions & 32 deletions services/open-match/fake-frontend/Dockerfile

This file was deleted.

52 changes: 0 additions & 52 deletions services/open-match/fake-frontend/fake-frontend.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions services/open-match/fake-frontend/go.mod

This file was deleted.

25 changes: 0 additions & 25 deletions services/open-match/fake-frontend/go.sum

This file was deleted.

Loading

0 comments on commit 4148019

Please sign in to comment.