Skip to content

Commit

Permalink
Merge branch 'main' into AddGameServerStateDurationToGrafana
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentefb authored Oct 8, 2024
2 parents 1f66af1 + c26f737 commit 91d68d4
Show file tree
Hide file tree
Showing 2,442 changed files with 140,078 additions and 74,844 deletions.
13 changes: 7 additions & 6 deletions .github/ISSUE_TEMPLATE/golang_version_upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ Steps to upgrade Golang version:
- [ ] `find . -name 'go.mod' -not -path '*/\.*' -execdir go mod edit -go=<NEW_GOLANG_VERSION_WITHOUT_PATCH> \;`
- [ ] `find . -name 'go.mod' -not -path '*/\.*' -execdir go mod tidy \;`

- [ ] Update the Dockerfiles for `build` directory. At the root of the directory, run:
- [ ] Update the Dockerfiles for `build` directory.

`find build -type f \( -not -path '*/\.*' -and -not -path 'build/tmp/*' \) -exec sed -i 's/GO_VERSION=[0-9]\+\.[0-9]\+\.[0-9]\+/GO_VERSION=<NEW_GOLANG_VERSION>/g' {} \;`
- [ ] At the root of the directory, run: `find build -type f \( -not -path '*/\.*' -and -not -path 'build/tmp/*' \) -exec sed -i 's/GO_VERSION=[0-9]\+\.[0-9]\+\.[0-9]\+/GO_VERSION=<NEW_GOLANG_VERSION>/g' {} \;`
- [ ] Update the `golang` version for file `build/agones-bot/Dockerfile` to <NEW_GOLANG_VERSION_WITHOUT_PATCH>

- [ ] Update the Dockerfiles for `examples` directory. At the root of the directory, run:
- [ ] `find examples -name Dockerfile -exec sed -i 's/golang:[0-9]\+\.[0-9]\+-alpine/golang:<NEW_GOLANG_VERSION_WITHOUT_PATCH>-alpine/g' {} \;`
Expand All @@ -31,9 +32,7 @@ Steps to upgrade Golang version:
- [ ] `make bump-image IMAGENAME=supertuxkart-example VERSION=<current-image-version>`
- [ ] `make bump-image IMAGENAME=xonotic-example VERSION=<current-image-version>`

- [ ] Create a PR for the above changes and send for review

- [ ] After the above PR is approved, **before** merging it, run the following to generate and push the new example images:
- [ ] Run the following to generate and push the new example images:
- [ ] In `examples/allocation-endpoint`, run: `make cloud-build`
- [ ] In `examples/autoscaler-webhook`, run: `make cloud-build`
- [ ] In `examples/crd-client`, run: `make cloud-build`
Expand All @@ -43,4 +42,6 @@ Steps to upgrade Golang version:
- [ ] In `examples/supertuxkart`, run: `make cloud-build`
- [ ] In `examples/xonotic`, run: `make cloud-build`

- [ ] Merge the above PR
- [ ] Create a PR for the above changes and send for review

- [ ] Merge the above PR after it is approved
4 changes: 2 additions & 2 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ KIND_PROFILE ?= agones
KIND_CONTAINER_NAME=$(KIND_PROFILE)-control-plane

# Game Server image to use while doing end-to-end tests
GS_TEST_IMAGE ?= us-docker.pkg.dev/agones-images/examples/simple-game-server:0.34
GS_TEST_IMAGE ?= us-docker.pkg.dev/agones-images/examples/simple-game-server:0.35

# Enable all beta feature gates. Keep in sync with `true` (beta) entries in pkg/util/runtime/features.go:featureDefaults
BETA_FEATURE_GATES ?= "AutopilotPassthroughPort=true&CountsAndLists=true&DisableResyncOnSDKServer=true"
BETA_FEATURE_GATES ?= "AutopilotPassthroughPort=true&CountsAndLists=true&DisableResyncOnSDKServer=true&GKEAutopilotExtendedDurationPods=true"

# Enable all alpha feature gates. Keep in sync with `false` (alpha) entries in pkg/util/runtime/features.go:featureDefaults
ALPHA_FEATURE_GATES ?= "PlayerAllocationFilter=true&PlayerTracking=true&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&ScheduledAutoscaler=true&Example=true"
Expand Down
2 changes: 1 addition & 1 deletion build/agones-bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.21 AS build-env
FROM golang:1.22 AS build-env
COPY . /go-src
WORKDIR /go-src
RUN CGO_ENABLED=0 go build -o /go-app .
Expand Down
2 changes: 1 addition & 1 deletion build/agones-bot/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

module github-bot

go 1.21
go 1.22

require (
github.com/GoogleCloudPlatform/cloud-build-notifiers/lib/notifiers v0.0.0-20210219212036-163c92a64b27
Expand Down
4 changes: 2 additions & 2 deletions build/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN gem install fpm && \

# install go
WORKDIR /usr/local
ENV GO_VERSION=1.21.12
ENV GO_VERSION=1.22.6
ENV GOPATH /go
ENV GO111MODULE=on
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
Expand Down Expand Up @@ -78,7 +78,7 @@ RUN curl -L ${HELM_URL} > /tmp/helm.tar.gz \
RUN echo "source <(helm completion bash)" >> /root/.bashrc

# install golang-ci linter
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2
RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0

# Install yamllint
RUN apt-get update && \
Expand Down
2 changes: 1 addition & 1 deletion build/build-sdk-images/go/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get --allow-releaseinfo-change update && \

# install go
WORKDIR /usr/local
ENV GO_VERSION=1.21.12
ENV GO_VERSION=1.22.6
ENV GO111MODULE=on
ENV GOPATH /go
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
Expand Down
2 changes: 1 addition & 1 deletion build/build-sdk-images/restapi/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN apt-get --allow-releaseinfo-change update && \

# install go
WORKDIR /usr/local
ENV GO_VERSION=1.21.12
ENV GO_VERSION=1.22.6
ENV GO111MODULE=on
ENV GOPATH /go
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
Expand Down
4 changes: 2 additions & 2 deletions build/e2e-image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM gcr.io/cloud-builders/gcloud

RUN apt-get update && \
apt-get install -y wget psmisc make gcc python jq zip && \
apt-get install -y wget psmisc make gcc jq zip && \
apt-get clean

# install go
WORKDIR /usr/local
ENV GO_VERSION=1.21.12
ENV GO_VERSION=1.22.6
ENV GOPATH /go
ENV GO111MODULE=on
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
Expand Down
2 changes: 1 addition & 1 deletion build/report/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
id: build-report
script: |
#!/usr/bin/env bash
export GO_VERSION=1.21.12
export GO_VERSION=1.22.6
cd /usr/local
curl -SsL https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz | tar -xzf-
export PATH=/usr/local/go/bin:${PATH}
Expand Down
1 change: 0 additions & 1 deletion build/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func main() {
}
if err != nil {
log.Fatalf("error listing builds: %v", err)
break
}
createTime := resp.CreateTime.AsTime()
if createTime.Before(windowStart) {
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/k8s-export-openapi/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/agones/agones/build/scripts/k8s-export-openapi

go 1.21
go 1.22

require github.com/itchyny/json2yaml v0.1.4
2 changes: 1 addition & 1 deletion build/scripts/previousversion/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/agones/agones/build/scripts/previousversion

go 1.21
go 1.22

require github.com/blang/semver/v4 v4.0.0
2 changes: 1 addition & 1 deletion build/scripts/site-config-update-version/go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module github.com/agones/agones/build/scripts/site-config-update-version

go 1.21
go 1.22

require github.com/pelletier/go-toml v1.9.5
5 changes: 2 additions & 3 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,11 @@ steps:
declare -A versionsAndRegions=( [1.28]=us-west1 [1.29]=europe-west1 [1.30]=asia-east1 )
# Keep in sync with (the inverse of) pkg/util/runtime/features.go:featureDefaults
featureWithGate="PlayerAllocationFilter=true&PlayerTracking=true&CountsAndLists=false&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&ScheduledAutoscaler=true&DisableResyncOnSDKServer=false&AutopilotPassthroughPort=false&Example=true"
featureWithGate="PlayerAllocationFilter=true&PlayerTracking=true&CountsAndLists=false&RollingUpdateFix=true&PortRanges=true&PortPolicyNone=true&ScheduledAutoscaler=true&DisableResyncOnSDKServer=false&AutopilotPassthroughPort=false&GKEAutopilotExtendedDurationPods=false&Example=true"
featureWithoutGate=""
# Use this if specific feature gates can only be supported on specific Kubernetes versions.
# TODO: When 1.28 becomes trailing version, promote GKEAutopilotExtendedDurationPods to beta.
declare -A featureWithGateByVersion=( [1.28]="${featureWithGate}&GKEAutopilotExtendedDurationPods=true" [1.29]="${featureWithGate}&GKEAutopilotExtendedDurationPods=true" [1.30]="${featureWithGate}&GKEAutopilotExtendedDurationPods=true")
declare -A featureWithGateByVersion=( [1.28]="${featureWithGate}" [1.29]="${featureWithGate}" [1.30]="${featureWithGate}")
for cloudProduct in ${cloudProducts[@]}
do
Expand Down
18 changes: 9 additions & 9 deletions cmd/allocator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ func runHTTP(listenCtx context.Context, workerCtx context.Context, h *serviceHan
if err == http.ErrServerClosed {
logger.WithError(err).Info("HTTP/HTTPS server closed")
os.Exit(0)
} else {
logger.WithError(err).Fatal("Unable to start HTTP/HTTPS listener")
os.Exit(1)
}
logger.WithError(err).Fatal("Unable to start HTTP/HTTPS listener")
os.Exit(1)

}()
}

Expand All @@ -422,10 +422,10 @@ func runGRPC(ctx context.Context, h *serviceHandler, grpcHealth *grpchealth.Serv
if err != nil {
logger.WithError(err).Fatal("allocation service crashed")
os.Exit(1)
} else {
logger.Info("allocation server closed")
os.Exit(0)
}
logger.Info("allocation server closed")
os.Exit(0)

}()
}

Expand Down Expand Up @@ -545,15 +545,15 @@ func (h *serviceHandler) getGRPCServerOptions() []grpc.ServerOption {
return append([]grpc.ServerOption{grpc.Creds(credentials.NewTLS(cfg))}, opts...)
}

func (h *serviceHandler) getTLSCert(ch *tls.ClientHelloInfo) (*tls.Certificate, error) {
func (h *serviceHandler) getTLSCert(_ *tls.ClientHelloInfo) (*tls.Certificate, error) {
h.tlsMutex.RLock()
defer h.tlsMutex.RUnlock()
return h.tlsCert, nil
}

// verifyClientCertificate verifies that the client certificate is accepted
// This method is used as GetConfigForClient is cross lang incompatible.
func (h *serviceHandler) verifyClientCertificate(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
func (h *serviceHandler) verifyClientCertificate(rawCerts [][]byte, _ [][]*x509.Certificate) error {
opts := x509.VerifyOptions{
Roots: h.caCertPool,
CurrentTime: time.Now(),
Expand Down Expand Up @@ -656,7 +656,7 @@ type serviceHandler struct {
}

// Allocate implements the Allocate gRPC method definition
func (h *serviceHandler) Allocate(ctx context.Context, in *pb.AllocationRequest) (*pb.AllocationResponse, error) {
func (h *serviceHandler) Allocate(_ context.Context, in *pb.AllocationRequest) (*pb.AllocationResponse, error) {
logger.WithField("request", in).Infof("allocation request received.")
gsa := converters.ConvertAllocationRequestToGSA(in)
gsa.ApplyDefaults()
Expand Down
8 changes: 4 additions & 4 deletions cmd/allocator/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestAllocateHandler(t *testing.T) {
t.Parallel()

h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return &allocationv1.GameServerAllocation{
ObjectMeta: metav1.ObjectMeta{
Namespace: "default",
Expand Down Expand Up @@ -71,7 +71,7 @@ func TestAllocateHandlerReturnsError(t *testing.T) {
t.Parallel()

h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return nil, k8serror.NewBadRequest("error")
},
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestHandlingStatus(t *testing.T) {

errorMessage := "GameServerAllocation is invalid"
h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return &metav1.Status{
Status: metav1.StatusFailure,
Message: errorMessage,
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestBadReturnType(t *testing.T) {
t.Parallel()

h := serviceHandler{
allocationCallback: func(gsa *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
allocationCallback: func(_ *allocationv1.GameServerAllocation) (k8sruntime.Object, error) {
return &corev1.Secret{}, nil
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ping/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func serveHTTP(ctlConf config, h healthcheck.Handler) func() {
// add health check as well
mux.HandleFunc("/live", h.LiveEndpoint)

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
if _, err := w.Write([]byte(ctlConf.HTTPResponse)); err != nil {
w.WriteHeader(http.StatusInternalServerError)
logger.WithError(err).Error("Error responding to http request")
Expand Down
2 changes: 1 addition & 1 deletion cmd/ping/udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestUDPServerHealth(t *testing.T) {

cancel()

err = wait.PollUntilContextTimeout(context.Background(), time.Second, 5*time.Second, true, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), time.Second, 5*time.Second, true, func(_ context.Context) (bool, error) {
return u.Health() != nil, nil
})

Expand Down
14 changes: 11 additions & 3 deletions cmd/sdk-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ import (
)

const (
defaultGRPCPort = 9357
defaultHTTPPort = 9358
defaultGRPCPort = 9357
defaultHTTPPort = 9358
defaultHealthPort = 8080

// Flags (that can also be env vars)
gameServerNameFlag = "gameserver-name"
Expand All @@ -64,6 +65,7 @@ const (
timeoutFlag = "timeout"
grpcPortFlag = "grpc-port"
httpPortFlag = "http-port"
healthPortFlag = "health-port"
logLevelFlag = "log-level"
)

Expand Down Expand Up @@ -147,7 +149,7 @@ func main() {

var s *sdkserver.SDKServer
s, err = sdkserver.NewSDKServer(ctlConf.GameServerName, ctlConf.PodNamespace,
kubeClient, agonesClient, logLevel)
kubeClient, agonesClient, logLevel, ctlConf.HealthPort)
if err != nil {
logger.WithError(err).Fatalf("Could not start sidecar")
}
Expand Down Expand Up @@ -245,6 +247,7 @@ func runGrpc(grpcServer *grpc.Server, grpcEndpoint string) {

// runGateway runs the grpc-gateway
func runGateway(ctx context.Context, grpcEndpoint string, mux *gwruntime.ServeMux, httpServer *http.Server) {
// nolint: staticcheck
conn, err := grpc.DialContext(ctx, grpcEndpoint, grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
logger.WithError(err).Fatal("Could not dial grpc server...")
Expand Down Expand Up @@ -286,6 +289,7 @@ func parseEnvFlags() config {
viper.SetDefault(gracefulTerminationFlag, true)
viper.SetDefault(grpcPortFlag, defaultGRPCPort)
viper.SetDefault(httpPortFlag, defaultHTTPPort)
viper.SetDefault(healthPortFlag, defaultHealthPort)
viper.SetDefault(logLevelFlag, "Info")
pflag.String(gameServerNameFlag, viper.GetString(gameServerNameFlag),
"Optional flag to set GameServer name. Overrides value given from `GAMESERVER_NAME` environment variable.")
Expand All @@ -297,6 +301,7 @@ func parseEnvFlags() config {
pflag.String(addressFlag, viper.GetString(addressFlag), "The Address to bind the server grpcPort to. Defaults to 'localhost'")
pflag.Int(grpcPortFlag, viper.GetInt(grpcPortFlag), fmt.Sprintf("Port on which to bind the gRPC server. Defaults to %d", defaultGRPCPort))
pflag.Int(httpPortFlag, viper.GetInt(httpPortFlag), fmt.Sprintf("Port on which to bind the HTTP server. Defaults to %d", defaultHTTPPort))
pflag.Int(healthPortFlag, viper.GetInt(healthPortFlag), fmt.Sprintf("Port on which to bind the healthcheck port on the HTTP server. Defaults to %d", defaultHealthPort))
pflag.Int(delayFlag, viper.GetInt(delayFlag), "Time to delay (in seconds) before starting to execute main. Useful for tests")
pflag.Int(timeoutFlag, viper.GetInt(timeoutFlag), "Time of execution (in seconds) before close. Useful for tests")
pflag.String(testFlag, viper.GetString(testFlag), "List functions which should be called during the SDK Conformance test run.")
Expand All @@ -321,6 +326,7 @@ func parseEnvFlags() config {
runtime.Must(viper.BindEnv(timeoutFlag))
runtime.Must(viper.BindEnv(grpcPortFlag))
runtime.Must(viper.BindEnv(httpPortFlag))
runtime.Must(viper.BindEnv(healthPortFlag))
runtime.Must(viper.BindPFlags(pflag.CommandLine))
runtime.Must(viper.BindEnv(logLevelFlag))
runtime.Must(runtime.FeaturesBindEnv())
Expand All @@ -340,6 +346,7 @@ func parseEnvFlags() config {
GracefulTermination: viper.GetBool(gracefulTerminationFlag),
GRPCPort: viper.GetInt(grpcPortFlag),
HTTPPort: viper.GetInt(httpPortFlag),
HealthPort: viper.GetInt(healthPortFlag),
LogLevel: viper.GetString(logLevelFlag),
}
}
Expand All @@ -359,6 +366,7 @@ type config struct {
GracefulTermination bool
GRPCPort int
HTTPPort int
HealthPort int
LogLevel string
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/sdk-server/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestHealthCheckWrapper(t *testing.T) {
{"non-empty body", bytes.NewBuffer([]byte(`{}`)), http.StatusOK},
}

testWrapper := healthCheckWrapper(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testWrapper := healthCheckWrapper(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
}))

Expand Down
2 changes: 1 addition & 1 deletion examples/allocation-endpoint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PROD_REPO ?= us-docker.pkg.dev/agones-images/examples
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
root_path = $(realpath $(project_path)/../..)
version := 0.9
version := 0.10
ifeq ($(REPOSITORY),)
server_tag := allocation-endpoint-proxy:$(version)
else
Expand Down
2 changes: 1 addition & 1 deletion examples/allocation-endpoint/client/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module agones.dev/agones/examples/allocation-endpoint/client

go 1.21
go 1.22

require (
agones.dev/agones v1.35.0
Expand Down
2 changes: 1 addition & 1 deletion examples/allocation-endpoint/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# syntax=docker/dockerfile:1

FROM golang:1.21-alpine
FROM golang:1.22-alpine

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion examples/allocation-endpoint/server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module agones.dev/agones/examples/allocation-endpoint/server

go 1.21
go 1.22

require (
agones.dev/agones v1.35.0
Expand Down
Loading

0 comments on commit 91d68d4

Please sign in to comment.