Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Minimum Buffer Size to 1 #3749

Merged
merged 15 commits into from
May 9, 2024
Merged
12 changes: 12 additions & 0 deletions pkg/fleetautoscalers/fleetautoscalers.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,20 @@ func applyCounterOrListPolicy(c *autoscalingv1.CounterPolicy, l *autoscalingv1.L
}
// The desired TOTAL capacity based on the Aggregated Allocated Counts (see applyBufferPolicy for explanation)
desiredCapacity := int64(math.Ceil(float64(aggAllocatedCount*100) / float64(100-bufferPercent)))

// Ensures desiredCapacity is at least 1
if desiredCapacity < 1 {
Kalaiselvi84 marked this conversation as resolved.
Show resolved Hide resolved
desiredCapacity = 1
}

// Convert into a desired AVAILABLE capacity aka the buffer
buffer = desiredCapacity - aggAllocatedCount

// Ensures buffer is at least 1 if desiredCapacity calculation results in a value less than or equal to aggAllocatedCount
if buffer < 1 {
buffer = 1
}

}

// Current available capacity across the TOTAL fleet
Expand Down
15 changes: 8 additions & 7 deletions pkg/fleetautoscalers/fleetautoscalers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ import (
"net/http/httptest"
"testing"

agonesv1 "agones.dev/agones/pkg/apis/agones/v1"
autoscalingv1 "agones.dev/agones/pkg/apis/autoscaling/v1"
"agones.dev/agones/pkg/gameservers"
agtesting "agones.dev/agones/pkg/testing"
utilruntime "agones.dev/agones/pkg/util/runtime"
"github.com/stretchr/testify/assert"
admregv1 "k8s.io/api/admissionregistration/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
k8stesting "k8s.io/client-go/testing"

agonesv1 "agones.dev/agones/pkg/apis/agones/v1"
autoscalingv1 "agones.dev/agones/pkg/apis/autoscaling/v1"
"agones.dev/agones/pkg/gameservers"
agtesting "agones.dev/agones/pkg/testing"
utilruntime "agones.dev/agones/pkg/util/runtime"
)

const (
Expand Down Expand Up @@ -1950,7 +1951,7 @@ func TestApplyListPolicy(t *testing.T) {
}}}},
},
want: expected{
replicas: 0,
replicas: 1,
Kalaiselvi84 marked this conversation as resolved.
Show resolved Hide resolved
limited: false,
Kalaiselvi84 marked this conversation as resolved.
Show resolved Hide resolved
wantErr: false,
},
Expand Down Expand Up @@ -2097,7 +2098,7 @@ func TestApplyListPolicy(t *testing.T) {
},
want: expected{
replicas: 1,
limited: true,
limited: false,
wantErr: false,
},
},
Expand Down
Loading