Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/fleetautoscalers/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type fasState struct {
// fasThread is used for tracking each Fleet's autoscaling jobs
type fasThread struct {
cancel context.CancelFunc
state fasState
state *fasState
generation int64
}

Expand Down Expand Up @@ -360,7 +360,7 @@ func (c *Controller) syncFleetAutoscaler(ctx context.Context, key string) error

currentReplicas := fleet.Status.Replicas
gameServerNamespacedLister := c.gameServerLister.GameServers(fleet.ObjectMeta.Namespace)
desiredReplicas, scalingLimited, err := computeDesiredFleetSize(ctx, &thread.state, fas.Spec.Policy, fleet, gameServerNamespacedLister, c.counter.Counts(), &fasLog)
desiredReplicas, scalingLimited, err := computeDesiredFleetSize(ctx, thread.state, fas.Spec.Policy, fleet, gameServerNamespacedLister, c.counter.Counts(), &fasLog)

// If the err is not nil and not an inactive schedule error (ignorable in this case), then record the event
if err != nil {
Expand Down Expand Up @@ -498,7 +498,7 @@ func (c *Controller) addFasThread(fas *autoscalingv1.FleetAutoscaler, lock bool)
thread := fasThread{
cancel: cancel,
generation: fas.Generation,
state: fasState{},
state: &fasState{},
}

if lock {
Expand Down
6 changes: 3 additions & 3 deletions pkg/fleetautoscalers/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1178,9 +1178,9 @@ func TestControllerCleanFasThreads(t *testing.T) {

c.fasThreadMutex.Lock()
c.fasThreads = map[types.UID]fasThread{
"1": {func() {}, fasState{}, 1},
"2": {func() {}, fasState{}, 2},
fas.ObjectMeta.UID: {func() {}, fasState{}, 3},
"1": {func() {}, &fasState{}, 1},
"2": {func() {}, &fasState{}, 2},
fas.ObjectMeta.UID: {func() {}, &fasState{}, 3},
}
c.fasThreadMutex.Unlock()

Expand Down
2 changes: 2 additions & 0 deletions pkg/fleetautoscalers/fleetautoscalers.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ func applyWebhookPolicy(state *fasState, w *autoscalingv1.URLConfiguration, f *a
return 0, false, err
}
defer func() {
// Drain any unread body so the underlying connection can be reused by http.Transport.
_, _ = io.Copy(io.Discard, res.Body)
if cerr := res.Body.Close(); cerr != nil {
if err != nil {
err = errors.Wrap(err, cerr.Error())
Expand Down
Loading