Skip to content

Commit

Permalink
use sync.map
Browse files Browse the repository at this point in the history
  • Loading branch information
dgkanatsios committed Dec 13, 2021
1 parent 8a9d5f0 commit 854cfcf
Show file tree
Hide file tree
Showing 33 changed files with 744 additions and 1,885 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ jobs:
run: cd tools/gameserverapi && GIN_MODE=release go test
- name: initcontainer unit tests
run: cd initcontainer && go test
- name: sidecar unit tests
run: cd sidecar-go && go test
- name: nodeagent unit tests
run: cd nodeagent && go test
- name: operator unit tests
run: IMAGE_NAME_SAMPLE=thundernetes-netcore-sample IMAGE_NAME_INIT_CONTAINER=thundernetes-initcontainer IMAGE_NAME_SIDECAR=thundernetes-sidecar-go TAG=$(git rev-list HEAD --max-count=1 --abbrev-commit) make -C operator test
run: IMAGE_NAME_SAMPLE=thundernetes-netcore-sample IMAGE_NAME_INIT_CONTAINER=thundernetes-initcontainer TAG=$(git rev-list HEAD --max-count=1 --abbrev-commit) make -C operator test
- name: install kind binaries
run: make installkind
- name: create kind cluster
Expand Down
2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
export OPERATOR_TAG=0.1.0
export NODE_AGENT_TAG=0.1.0
export INIT_CONTAINER_TAG=0.1.0
export SIDECAR_TAG=0.1.0
export NETCORE_SAMPLE_TAG=0.1.0
export OPENARENA_SAMPLE_TAG=0.1.0
25 changes: 7 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
NS=ghcr.io/playfab

export IMAGE_NAME_OPERATOR=thundernetes-operator
export IMAGE_NAME_NODE_AGENT=thundernetes-nodeagent
export IMAGE_NAME_INIT_CONTAINER=thundernetes-initcontainer
export IMAGE_NAME_SIDECAR=thundernetes-sidecar-go
export IMAGE_NAME_NETCORE_SAMPLE=thundernetes-netcore-sample
export IMAGE_NAME_OPENARENA_SAMPLE=thundernetes-openarena-sample
export IMAGE_NAME_NODE_AGENT=thundernetes-nodeagent

export OPERATOR_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
export NODE_AGENT_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
export INIT_CONTAINER_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
export SIDECAR_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
export NETCORE_SAMPLE_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
export OPENARENA_SAMPLE_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)
export NODE_AGENT_TAG?=$(shell git rev-list HEAD --max-count=1 --abbrev-commit)

# local e2e with kind
export KIND_CLUSTER_NAME=kind
Expand All @@ -22,33 +20,26 @@ export KIND_CLUSTER_NAME=kind
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

docker-compose:
rm -rf samples/data/GameLogs/*
docker-compose up --build

build:
docker build -f ./operator/Dockerfile -t $(NS)/$(IMAGE_NAME_OPERATOR):$(OPERATOR_TAG) ./operator
docker build -f ./nodeagent/Dockerfile -t $(NS)/$(IMAGE_NAME_NODE_AGENT):$(NODE_AGENT_TAG) ./nodeagent
docker build -f ./initcontainer/Dockerfile -t $(NS)/$(IMAGE_NAME_INIT_CONTAINER):$(INIT_CONTAINER_TAG) ./initcontainer
docker build -f ./sidecar-go/Dockerfile -t $(NS)/$(IMAGE_NAME_SIDECAR):$(SIDECAR_TAG) ./sidecar-go
docker build -f ./samples/netcore/Dockerfile -t $(NS)/$(IMAGE_NAME_NETCORE_SAMPLE):$(NETCORE_SAMPLE_TAG) ./samples/netcore
docker build -f ./samples/openarena/Dockerfile -t $(NS)/$(IMAGE_NAME_OPENARENA_SAMPLE):$(OPENARENA_SAMPLE_TAG) ./samples/openarena
docker build -f ./nodeagent/Dockerfile -t $(NS)/$(IMAGE_NAME_NODE_AGENT):$(NODE_AGENT_TAG) ./nodeagent


push:
docker push $(NS)/$(IMAGE_NAME_OPERATOR):$(OPERATOR_TAG)
docker push $(NS)/$(IMAGE_NAME_NODE_AGENT):$(NODE_AGENT_TAG)
docker push $(NS)/$(IMAGE_NAME_INIT_CONTAINER):$(INIT_CONTAINER_TAG)
docker push $(NS)/$(IMAGE_NAME_SIDECAR):$(SIDECAR_TAG)
docker push $(NS)/$(IMAGE_NAME_NETCORE_SAMPLE):$(NETCORE_SAMPLE_TAG)
docker push $(NS)/$(IMAGE_NAME_OPENARENA_SAMPLE):$(OPENARENA_SAMPLE_TAG)
docker push $(NS)/$(IMAGE_NAME_NODE_AGENT):$(NODE_AGENT_TAG)

builddockerlocal:
docker build -f operator/Dockerfile -t $(IMAGE_NAME_OPERATOR):$(OPERATOR_TAG) ./operator
docker build -f operator/Dockerfile -t $(IMAGE_NAME_OPERATOR):$(OPERATOR_TAG) ./operator
docker build -f nodeagent/Dockerfile -t $(IMAGE_NAME_NODE_AGENT):$(NODE_AGENT_TAG) ./nodeagent
docker build -f initcontainer/Dockerfile -t $(IMAGE_NAME_INIT_CONTAINER):$(INIT_CONTAINER_TAG) ./initcontainer
docker build -f sidecar-go/Dockerfile -t $(IMAGE_NAME_SIDECAR):$(SIDECAR_TAG) ./sidecar-go
docker build -f samples/netcore/Dockerfile -t $(IMAGE_NAME_NETCORE_SAMPLE):$(NETCORE_SAMPLE_TAG) ./samples/netcore
docker build -f samples/openarena/Dockerfile -t $(IMAGE_NAME_OPENARENA_SAMPLE):$(OPENARENA_SAMPLE_TAG) ./samples/openarena
docker build -f nodeagent/Dockerfile -t $(IMAGE_NAME_NODE_AGENT):$(NODE_AGENT_TAG) ./nodeagent

installkind:
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
Expand Down Expand Up @@ -79,9 +70,7 @@ create-install-files:
. .versions && \
IMG=$(NS)/$(IMAGE_NAME_OPERATOR):$${OPERATOR_TAG} \
IMAGE_NAME_INIT_CONTAINER=$(NS)/$(IMAGE_NAME_INIT_CONTAINER) \
IMAGE_NAME_SIDECAR=$(NS)/$(IMAGE_NAME_SIDECAR) \
IMAGE_NAME_NODE_AGENT=$(NS)/$(IMAGE_NAME_NODE_AGENT) \
SIDECAR_TAG=$${SIDECAR_TAG} \
INIT_CONTAINER_TAG=$${INIT_CONTAINER_TAG} \
NODE_AGENT_TAG=$${NODE_AGENT_TAG} \
make -C operator create-install-files
32 changes: 0 additions & 32 deletions docker-compose.yml

This file was deleted.

4 changes: 0 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,3 @@ PF_SERVER_LOG_DIRECTORY=/data/GameLogs/
PF_TITLE_ID=1E03
_=/usr/bin/env
```

## Docker compose

The docker-compose.yml file on the root of this repo was created to facilitate sidecar development.
26 changes: 19 additions & 7 deletions e2e/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
LabelBuildID = "BuildID"
invalidStatusCode string = "invalid status code"
containerName string = "netcore-sample" // this must be the same as the GameServer name
nodeAgentName string = "nodeagent"
)

type AllocationResult struct {
Expand Down Expand Up @@ -525,15 +526,26 @@ func validateThatAllocatedServersHaveReadyForPlayersUnblocked(ctx context.Contex
}
}

var nodeAgentPodList corev1.PodList
if err := kubeClient.List(ctx, &nodeAgentPodList, client.MatchingLabels{"name": nodeAgentName}); err != nil {
handleError(err)
}

if len(nodeAgentPodList.Items) != 1 {
handleError(fmt.Errorf("expected 1 node agent pod, got %d", len(nodeAgentPodList.Items)))
}
nodeAgentPod := nodeAgentPodList.Items[0]

nodeAgentLogs, err := getContainerLogs(ctx, coreClient, nodeAgentPod.Name, nodeAgentName, "thundernetes-system")
if err != nil {
handleError(err)
}

for _, gameServer := range activeGameServers {
err := retry(loopTimes, time.Duration(delayInSecondsForLoopTest)*time.Second, func() error {
// sidecarLogs, err := getContainerLogs(ctx, coreClient, gameServer.Name, sidecarName, gameServer.Namespace)
// if err != nil {
// return err
// }
// if !strings.Contains(sidecarLogs, "sessionCookie:randomCookie") {
// return fmt.Errorf("expected to find 'sessionCookie:randomCookie' in sidecar logs, got %s", sidecarLogs)
// }
if !strings.Contains(nodeAgentLogs, "sessionCookie:randomCookie") {
return fmt.Errorf("expected to find 'sessionCookie:randomCookie' in nodeAgent logs, got %s", nodeAgentLogs)
}

containerLogs, err := getContainerLogs(ctx, coreClient, gameServer.Name, containerName, gameServer.Namespace)

Expand Down
1 change: 0 additions & 1 deletion e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ BUILD=${2:-remote} # setting a default value for $BUILD
if [ "$BUILD" = "local" ]; then
./operator/testbin/bin/kind load docker-image ${IMAGE_NAME_OPERATOR}:${OPERATOR_TAG} --name kind
./operator/testbin/bin/kind load docker-image ${IMAGE_NAME_INIT_CONTAINER}:${INIT_CONTAINER_TAG} --name kind
./operator/testbin/bin/kind load docker-image ${IMAGE_NAME_SIDECAR}:${SIDECAR_TAG} --name kind
./operator/testbin/bin/kind load docker-image ${IMAGE_NAME_NETCORE_SAMPLE}:${NETCORE_SAMPLE_TAG} --name kind
./operator/testbin/bin/kind load docker-image ${IMAGE_NAME_NODE_AGENT}:${NODE_AGENT_TAG} --name kind
fi
Expand Down
1 change: 0 additions & 1 deletion nodeagent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/playfab/thundernetes/nodeagent
go 1.16

require (
github.com/cornelk/hashmap v1.0.1
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.15.0
github.com/sirupsen/logrus v1.8.1
Expand Down
4 changes: 0 additions & 4 deletions nodeagent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,12 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cornelk/hashmap v1.0.1 h1:RXGcy29hEdLLV8T6aK4s+BAd4tq4+3Hq50N2GoG0uIg=
github.com/cornelk/hashmap v1.0.1/go.mod h1:8wbysTUDnwJGrPZ1Iwsou3m+An6sldFrJItjRhfegCw=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dchest/siphash v1.1.0 h1:1Rs9eTUlZLPBEvV+2sTaM8O0NWn0ppbgqS7p11aWawI=
github.com/dchest/siphash v1.1.0/go.mod h1:q+IRvb2gOSrUnYoPqHiyHXS0FOBBOdl6tONBlVnOnt4=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
Expand Down
Loading

0 comments on commit 854cfcf

Please sign in to comment.