Do not autoscale up on status requests (#388)

This commit is contained in:
Samuel McBroom
2025-04-17 20:07:25 -07:00
committed by GitHub
parent ea62db578c
commit a058d6e21d
3 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.22 AS builder
FROM golang:1.23 AS builder
WORKDIR /build
+4
View File
@@ -56,6 +56,10 @@ type Handshake struct {
NextState int
}
const (
StateStatus State = 1
)
type LegacyServerListPing struct {
ProtocolVersion int
ServerAddress string
+5 -4
View File
@@ -223,8 +223,9 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
Debug("Got handshake")
serverAddress := handshake.ServerAddress
nextState := mcproto.State(handshake.NextState)
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress)
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress, nextState)
} else if packet.PacketID == mcproto.PacketIdLegacyServerListPing {
handshake, ok := packet.Data.(*mcproto.LegacyServerListPing)
if !ok {
@@ -243,7 +244,7 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
serverAddress := handshake.ServerAddress
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress)
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress, mcproto.StateStatus)
} else {
logrus.
WithField("client", clientAddr).
@@ -255,10 +256,10 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
}
func (c *Connector) findAndConnectBackend(ctx context.Context, frontendConn net.Conn,
clientAddr net.Addr, preReadContent io.Reader, serverAddress string) {
clientAddr net.Addr, preReadContent io.Reader, serverAddress string, nextState mcproto.State) {
backendHostPort, resolvedHost, waker := Routes.FindBackendForServerAddress(ctx, serverAddress)
if waker != nil {
if waker != nil && nextState > mcproto.StateStatus {
if err := waker(ctx); err != nil {
logrus.WithFields(logrus.Fields{"serverAddress": serverAddress}).WithError(err).Error("failed to wake up backend")
c.metrics.Errors.With("type", "wakeup_failed").Add(1)