Do not autoscale up on status requests (#388)
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.22 AS builder
|
FROM golang:1.23 AS builder
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ type Handshake struct {
|
|||||||
NextState int
|
NextState int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
StateStatus State = 1
|
||||||
|
)
|
||||||
|
|
||||||
type LegacyServerListPing struct {
|
type LegacyServerListPing struct {
|
||||||
ProtocolVersion int
|
ProtocolVersion int
|
||||||
ServerAddress string
|
ServerAddress string
|
||||||
|
|||||||
+5
-4
@@ -223,8 +223,9 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
|
|||||||
Debug("Got handshake")
|
Debug("Got handshake")
|
||||||
|
|
||||||
serverAddress := handshake.ServerAddress
|
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 {
|
} else if packet.PacketID == mcproto.PacketIdLegacyServerListPing {
|
||||||
handshake, ok := packet.Data.(*mcproto.LegacyServerListPing)
|
handshake, ok := packet.Data.(*mcproto.LegacyServerListPing)
|
||||||
if !ok {
|
if !ok {
|
||||||
@@ -243,7 +244,7 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
|
|||||||
|
|
||||||
serverAddress := handshake.ServerAddress
|
serverAddress := handshake.ServerAddress
|
||||||
|
|
||||||
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress)
|
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress, mcproto.StateStatus)
|
||||||
} else {
|
} else {
|
||||||
logrus.
|
logrus.
|
||||||
WithField("client", clientAddr).
|
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,
|
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)
|
backendHostPort, resolvedHost, waker := Routes.FindBackendForServerAddress(ctx, serverAddress)
|
||||||
if waker != nil {
|
if waker != nil && nextState > mcproto.StateStatus {
|
||||||
if err := waker(ctx); err != nil {
|
if err := waker(ctx); err != nil {
|
||||||
logrus.WithFields(logrus.Fields{"serverAddress": serverAddress}).WithError(err).Error("failed to wake up backend")
|
logrus.WithFields(logrus.Fields{"serverAddress": serverAddress}).WithError(err).Error("failed to wake up backend")
|
||||||
c.metrics.Errors.With("type", "wakeup_failed").Add(1)
|
c.metrics.Errors.With("type", "wakeup_failed").Add(1)
|
||||||
|
|||||||
Reference in New Issue
Block a user