diff --git a/internal/core/services/autoscaler/policies/roomoccupancy/policy.go b/internal/core/services/autoscaler/policies/roomoccupancy/policy.go index c795c308..b88e906b 100644 --- a/internal/core/services/autoscaler/policies/roomoccupancy/policy.go +++ b/internal/core/services/autoscaler/policies/roomoccupancy/policy.go @@ -96,12 +96,12 @@ func (p *Policy) CalculateDesiredNumberOfRooms(policyParameters autoscaling.Poli return -1, errors.New("There are no runningMatches in the currentState") } - maxMatches := currentState[MaxMatchesKey].(int) + maxMatchesPerRoom := currentState[MaxMatchesKey].(int) - occupiedRooms := math.Ceil(float64(runningMatches) / float64(maxMatches)) - desiredNumberOfRoom := int(math.Ceil(float64(occupiedRooms) / (float64(1) - readyTarget))) + desiredNumberOfMatches := math.Ceil(float64(runningMatches) / (float64(1) - readyTarget)) + desiredNumberOfRooms := int(math.Ceil(desiredNumberOfMatches / float64(maxMatchesPerRoom))) - return desiredNumberOfRoom, nil + return desiredNumberOfRooms, nil } func (p *Policy) CanDownscale(policyParameters autoscaling.PolicyParameters, currentState policies.CurrentState) (bool, error) { diff --git a/pkg/api/v1/rooms.pb.go b/pkg/api/v1/rooms.pb.go index 2fefdcc5..d314e34e 100644 --- a/pkg/api/v1/rooms.pb.go +++ b/pkg/api/v1/rooms.pb.go @@ -228,7 +228,7 @@ type UpdateRoomStatusRequest struct { Status string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` // Timestamp of the status update. Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - // The number of running_matches in the game room. + // The number of running matches in the game room. RunningMatches int64 `protobuf:"varint,7,opt,name=running_matches,json=runningMatches,proto3" json:"running_matches,omitempty"` } diff --git a/proto/api/v1/rooms.proto b/proto/api/v1/rooms.proto index e0696e45..961a3f95 100644 --- a/proto/api/v1/rooms.proto +++ b/proto/api/v1/rooms.proto @@ -98,7 +98,7 @@ message UpdateRoomStatusRequest { string status = 4; // Timestamp of the status update. int64 timestamp = 6; - // The number of running_matches in the game room. + // The number of running matches in the game room. int64 running_matches = 7; } diff --git a/proto/apidocs.swagger.json b/proto/apidocs.swagger.json index a559b054..79b2b16b 100644 --- a/proto/apidocs.swagger.json +++ b/proto/apidocs.swagger.json @@ -800,7 +800,7 @@ "runningMatches": { "type": "string", "format": "int64", - "description": "The number of running_matches in the game room." + "description": "The number of running matches in the game room." } }, "description": "The player event request."