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
13 changes: 10 additions & 3 deletions pkg/fleetautoscalers/fleetautoscalers.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,17 @@ import (
"strings"
"time"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/uuid"

agonesv1 "agones.dev/agones/pkg/apis/agones/v1"
autoscalingv1 "agones.dev/agones/pkg/apis/autoscaling/v1"
listeragonesv1 "agones.dev/agones/pkg/client/listers/agones/v1"
"agones.dev/agones/pkg/fleets"
"agones.dev/agones/pkg/gameservers"
gssets "agones.dev/agones/pkg/gameserversets"
"agones.dev/agones/pkg/util/runtime"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/uuid"
)

var tlsConfig = &tls.Config{}
Expand Down Expand Up @@ -323,6 +324,12 @@ func applyCounterOrListPolicy(c *autoscalingv1.CounterPolicy, l *autoscalingv1.L
desiredCapacity := int64(math.Ceil(float64(aggAllocatedCount*100) / float64(100-bufferPercent)))
// Convert into a desired AVAILABLE capacity aka the buffer
buffer = desiredCapacity - aggAllocatedCount

// Ensures buffer is at least 1
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