Skip to content

Commit a058d6e

Browse files
authored
Do not autoscale up on status requests (#388)
1 parent ea62db5 commit a058d6e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22 AS builder
1+
FROM golang:1.23 AS builder
22

33
WORKDIR /build
44

mcproto/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ type Handshake struct {
5656
NextState int
5757
}
5858

59+
const (
60+
StateStatus State = 1
61+
)
62+
5963
type LegacyServerListPing struct {
6064
ProtocolVersion int
6165
ServerAddress string

server/connector.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
223223
Debug("Got handshake")
224224

225225
serverAddress := handshake.ServerAddress
226+
nextState := mcproto.State(handshake.NextState)
226227

227-
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress)
228+
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress, nextState)
228229
} else if packet.PacketID == mcproto.PacketIdLegacyServerListPing {
229230
handshake, ok := packet.Data.(*mcproto.LegacyServerListPing)
230231
if !ok {
@@ -243,7 +244,7 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
243244

244245
serverAddress := handshake.ServerAddress
245246

246-
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress)
247+
c.findAndConnectBackend(ctx, frontendConn, clientAddr, inspectionBuffer, serverAddress, mcproto.StateStatus)
247248
} else {
248249
logrus.
249250
WithField("client", clientAddr).
@@ -255,10 +256,10 @@ func (c *Connector) HandleConnection(ctx context.Context, frontendConn net.Conn)
255256
}
256257

257258
func (c *Connector) findAndConnectBackend(ctx context.Context, frontendConn net.Conn,
258-
clientAddr net.Addr, preReadContent io.Reader, serverAddress string) {
259+
clientAddr net.Addr, preReadContent io.Reader, serverAddress string, nextState mcproto.State) {
259260

260261
backendHostPort, resolvedHost, waker := Routes.FindBackendForServerAddress(ctx, serverAddress)
261-
if waker != nil {
262+
if waker != nil && nextState > mcproto.StateStatus {
262263
if err := waker(ctx); err != nil {
263264
logrus.WithFields(logrus.Fields{"serverAddress": serverAddress}).WithError(err).Error("failed to wake up backend")
264265
c.metrics.Errors.With("type", "wakeup_failed").Add(1)

0 commit comments

Comments
 (0)