From 7af0121abef6e6d2fc30c11a8ee4ce9499c1d237 Mon Sep 17 00:00:00 2001 From: castaneai Date: Thu, 31 Oct 2024 16:41:22 +0900 Subject: [PATCH 1/2] chore: bump up tools --- loadtest/aqua.yaml | 10 +++++----- loadtest/go.mod | 6 +++--- loadtest/go.sum | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/loadtest/aqua.yaml b/loadtest/aqua.yaml index db25d91..fc2136b 100644 --- a/loadtest/aqua.yaml +++ b/loadtest/aqua.yaml @@ -8,9 +8,9 @@ # - all registries: - type: standard - ref: v4.107.0 # renovate: depName=aquaproj/aqua-registry + ref: v4.246.0 # renovate: depName=aquaproj/aqua-registry packages: -- name: ko-build/ko@v0.15.1 -- name: helmfile/helmfile@v0.159.0 -- name: GoogleContainerTools/skaffold@v2.9.0 -- name: helm/helm@v3.13.3 +- name: ko-build/ko@v0.17.1 +- name: helmfile/helmfile@v0.169.1 +- name: GoogleContainerTools/skaffold@v2.13.2 +- name: helm/helm@v3.16.2 diff --git a/loadtest/go.mod b/loadtest/go.mod index 87fe899..e2a78fc 100644 --- a/loadtest/go.mod +++ b/loadtest/go.mod @@ -18,6 +18,7 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.44.0 go.opentelemetry.io/otel/metric v1.24.0 go.opentelemetry.io/otel/sdk/metric v1.24.0 + golang.org/x/sync v0.6.0 google.golang.org/grpc v1.62.1 open-match.dev/open-match v1.8.1 ) @@ -41,9 +42,8 @@ require ( go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/exp v0.0.0-20220328175248-053ad81199eb // indirect - golang.org/x/net v0.20.0 // indirect - golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.23.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/genproto v0.0.0-20240123012728-ef4313101c80 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240123012728-ef4313101c80 // indirect diff --git a/loadtest/go.sum b/loadtest/go.sum index 871ead0..1a2a10f 100644 --- a/loadtest/go.sum +++ b/loadtest/go.sum @@ -76,14 +76,14 @@ go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= golang.org/x/exp v0.0.0-20220328175248-053ad81199eb h1:pC9Okm6BVmxEw76PUu0XUbOTQ92JX11hfvqTjAV3qxM= golang.org/x/exp v0.0.0-20220328175248-053ad81199eb/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= -golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 9861d2a76b9926d55cf77d300cc34b79e962f824 Mon Sep 17 00:00:00 2001 From: castaneai Date: Thu, 31 Oct 2024 16:55:34 +0900 Subject: [PATCH 2/2] loadtest: frontend example graceful shutdown --- loadtest/cmd/attacker/main.go | 3 ++- loadtest/cmd/frontend/main.go | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/loadtest/cmd/attacker/main.go b/loadtest/cmd/attacker/main.go index 3a8480e..c39c8ae 100644 --- a/loadtest/cmd/attacker/main.go +++ b/loadtest/cmd/attacker/main.go @@ -78,9 +78,10 @@ func main() { for { select { case <-ctx.Done(): + log.Printf("shutting down attacker...") return case <-ticker.C: - go createAndWatchTicket(ctx, frontendAddr, matchTimeout) + go createAndWatchTicket(context.Background(), frontendAddr, matchTimeout) } } } diff --git a/loadtest/cmd/frontend/main.go b/loadtest/cmd/frontend/main.go index 92ffdc1..7586e8f 100644 --- a/loadtest/cmd/frontend/main.go +++ b/loadtest/cmd/frontend/main.go @@ -1,10 +1,14 @@ package main import ( + "context" "fmt" "log" "net" "net/http" + "os" + "os/signal" + "syscall" "time" cache "github.com/Code-Hex/go-generics-cache" @@ -17,6 +21,7 @@ import ( "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/exporters/prometheus" "go.opentelemetry.io/otel/sdk/metric" + "golang.org/x/sync/errgroup" "google.golang.org/grpc" "open-match.dev/open-match/pkg/pb" @@ -57,8 +62,22 @@ func main() { if err != nil { log.Fatalf("failed to listen gRPC server via %s: %+v", addr, err) } - log.Printf("frontend service is listening on %s...", addr) - if err := sv.Serve(lis); err != nil { + + // start frontend server + ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGTERM, os.Interrupt) + defer cancel() + eg := new(errgroup.Group) + eg.Go(func() error { + log.Printf("frontend service is listening on %s...", addr) + return sv.Serve(lis) + }) + + // wait for stop signal + <-ctx.Done() + log.Printf("shutting down frontend service...") + // shutdown gracefully + sv.GracefulStop() + if err := eg.Wait(); err != nil { log.Fatalf("failed to serve gRPC server: %+v", err) } }