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

Add Autoscaler Buffer CPU to configuration #422

Merged
merged 1 commit into from
Aug 2, 2024
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/codeready-toolchain/toolchain-common
go 1.20

require (
github.com/codeready-toolchain/api v0.0.0-20240801160201-ed4387f19137
github.com/codeready-toolchain/api v0.0.0-20240802163003-cce070815e69
github.com/go-logr/logr v1.2.3
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/lestrrat-go/jwx v1.2.29
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWH
github.com/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo=
github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA=
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI=
github.com/codeready-toolchain/api v0.0.0-20240801160201-ed4387f19137 h1:axAZH/Ku+QHu2eQjlx/a7dctWRgj0T3K4gfnq1fzKFo=
github.com/codeready-toolchain/api v0.0.0-20240801160201-ed4387f19137/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E=
github.com/codeready-toolchain/api v0.0.0-20240802163003-cce070815e69 h1:e6up2k4O7QdG6hu0iOwNGap60b932N0JXlweDmmvCAQ=
github.com/codeready-toolchain/api v0.0.0-20240802163003-cce070815e69/go.mod h1:ie9p4LenCCS0LsnbWp6/xwpFDdCWYE0KWzUO6Sk1g0E=
github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
Expand Down
6 changes: 5 additions & 1 deletion pkg/configuration/memberoperatorconfig/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ func (a AutoscalerConfig) Deploy() bool {
}

func (a AutoscalerConfig) BufferMemory() string {
return commonconfig.GetString(a.autoscaler.BufferMemory, "50Mi") // TODO temporarily changed to e2e value, should be changed back to "" after autoscaler handling is moved to memberoperatorconfig controller
return commonconfig.GetString(a.autoscaler.BufferMemory, "50Mi")
}

func (a AutoscalerConfig) BufferCPU() string {
return commonconfig.GetString(a.autoscaler.BufferCPU, "50m")
}

func (a AutoscalerConfig) BufferReplicas() int {
Expand Down
14 changes: 14 additions & 0 deletions pkg/configuration/memberoperatorconfig/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ func TestAutoscaler(t *testing.T) {
assert.Equal(t, "5GiB", memberOperatorCfg.Autoscaler().BufferMemory())
})
})
t.Run("buffer cpu", func(t *testing.T) {
t.Run("default", func(t *testing.T) {
cfg := commonconfig.NewMemberOperatorConfigWithReset(t)
memberOperatorCfg := Configuration{cfg: &cfg.Spec}

assert.Equal(t, "50m", memberOperatorCfg.Autoscaler().BufferCPU())
})
t.Run("non-default", func(t *testing.T) {
cfg := commonconfig.NewMemberOperatorConfigWithReset(t, testconfig.Autoscaler().BufferCPU("2000m"))
memberOperatorCfg := Configuration{cfg: &cfg.Spec}

assert.Equal(t, "2000m", memberOperatorCfg.Autoscaler().BufferCPU())
})
})
t.Run("buffer replicas", func(t *testing.T) {
t.Run("default", func(t *testing.T) {
cfg := commonconfig.NewMemberOperatorConfigWithReset(t)
Expand Down
7 changes: 7 additions & 0 deletions pkg/test/config/memberoperatorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ func (o AutoscalerOption) BufferMemory(value string) AutoscalerOption {
return o
}

func (o AutoscalerOption) BufferCPU(value string) AutoscalerOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Autoscaler.BufferCPU = &value
})
return o
}

func (o AutoscalerOption) BufferReplicas(value int) AutoscalerOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Autoscaler.BufferReplicas = &value
Expand Down
Loading