diff --git a/common/config.go b/common/config.go index 89db0565adcfeb99633845a6681bc59edf944ca6..5acc14525ba843ddb084f856942fe1cdb2e50eee 100644 --- a/common/config.go +++ b/common/config.go @@ -278,7 +278,10 @@ type AutoscalerConfig struct { ConnectorConfig ConnectorConfig `toml:"connector_config,omitempty"` Policy []AutoscalerPolicyConfig `toml:"policy,omitempty" json:",omitempty"` - InstanceReadyCommand string `toml:"instance_ready_command,omitempty"` + InstanceReadyCommand string `toml:"instance_ready_command,omitempty" json:",omitempty"` + UpdateInterval time.Duration `toml:"update_interval,omitempty" json:",omitempty"` + UpdateIntervalWhenExpecting time.Duration `toml:"update_interval_when_expecting,omitempty" json:",omitempty"` + ScaleThrottle AutoscalerScaleThrottle `toml:"scale_throttle,omitempty" json:",omitempty"` DeleteInstancesOnShutdown bool `toml:"delete_instances_on_shutdown,omitempty" json:",omitempty"` @@ -298,6 +301,11 @@ type AutoscalerConfig struct { InstanceLifeDurationBuckets []float64 `toml:"instance_life_duration_buckets,omitempty" json:",omitempty"` } +type AutoscalerScaleThrottle struct { + Limit int `toml:"limit,omitempty" json:",omitempty"` + Burst int `toml:"burst,omitempty" json:",omitempty"` +} + func (c AutoscalerConfig) GetInstanceCreationTimeBuckets() []float64 { if len(c.InstanceCreationTimeBuckets) > 0 { return c.InstanceCreationTimeBuckets diff --git a/executors/internal/autoscaler/provider.go b/executors/internal/autoscaler/provider.go index a4e5baea832962673c1d63714b20ba47b9ac735b..3b718185018d8c7ece0822f289f73bfb683eac42 100644 --- a/executors/internal/autoscaler/provider.go +++ b/executors/internal/autoscaler/provider.go @@ -191,6 +191,15 @@ func (p *provider) init(config *common.RunnerConfig) (taskscaler.Taskscaler, boo taskscaler.WithUpdateInterval(time.Minute), taskscaler.WithUpdateIntervalWhenExpecting(time.Second), taskscaler.WithLogger(logger.Named("taskscaler")), + taskscaler.WithScaleThrottle(config.Autoscaler.ScaleThrottle.Limit, config.Autoscaler.ScaleThrottle.Burst), + } + + if config.Autoscaler.UpdateInterval > 0 { + options = append(options, taskscaler.WithUpdateInterval(config.Autoscaler.UpdateInterval)) + } + + if config.Autoscaler.UpdateIntervalWhenExpecting > 0 { + options = append(options, taskscaler.WithUpdateIntervalWhenExpecting(config.Autoscaler.UpdateIntervalWhenExpecting)) } if config.Autoscaler.DeleteInstancesOnShutdown { diff --git a/go.mod b/go.mod index 75e5e69f57073110fd872cfd38851ee85fa90bd1..a59957fca95f7a35dd7ef72f9c0c37a645ba6e5f 100644 --- a/go.mod +++ b/go.mod @@ -67,7 +67,7 @@ require ( gitlab.com/gitlab-org/fleeting/fleeting-artifact v0.0.0-20240327182014-3a0c2334b19b gitlab.com/gitlab-org/fleeting/fleeting/metrics/prometheus v0.0.0-20230818161800-377d2aa4b1b5 gitlab.com/gitlab-org/fleeting/nesting v0.1.1-0.20230410214021-ab545632193b - gitlab.com/gitlab-org/fleeting/taskscaler v0.0.0-20231205171121-e64f52f2c971 + gitlab.com/gitlab-org/fleeting/taskscaler v0.0.0-20240418203657-a3339bcbff6a gitlab.com/gitlab-org/fleeting/taskscaler/metrics/prometheus v0.0.0-20230821135503-23448d122365 gitlab.com/gitlab-org/gitlab-terminal v0.0.0-20230425133101-519a58790bfd gitlab.com/gitlab-org/golang-cli-helpers v0.0.0-20210929155855-70bef318ae0a diff --git a/go.sum b/go.sum index 2abeb621dad3ba54a765031ead674076abca68e1..86ca54a63520e198e6645eadfc5061cff736f1c9 100644 --- a/go.sum +++ b/go.sum @@ -650,8 +650,8 @@ gitlab.com/gitlab-org/fleeting/fleeting/metrics/prometheus v0.0.0-20230818161800 gitlab.com/gitlab-org/fleeting/fleeting/metrics/prometheus v0.0.0-20230818161800-377d2aa4b1b5/go.mod h1:dNcxkdms9+5vWfke3Infes/+R1VC226bJ43OxtPetmY= gitlab.com/gitlab-org/fleeting/nesting v0.1.1-0.20230410214021-ab545632193b h1:LOc3bwBDPqWiWcaeMuixxgtxz/16VtCNtlnNVsaQp8Q= gitlab.com/gitlab-org/fleeting/nesting v0.1.1-0.20230410214021-ab545632193b/go.mod h1:pst8ukfVL7gkxuaAIhoxzN8F0VbtyT8IPFRmIBayWqU= -gitlab.com/gitlab-org/fleeting/taskscaler v0.0.0-20231205171121-e64f52f2c971 h1:u+1btN5HRRfRjexuiDpAz1kyPIDmbWvetXXRj6HoQOY= -gitlab.com/gitlab-org/fleeting/taskscaler v0.0.0-20231205171121-e64f52f2c971/go.mod h1:78anuJ0QUXuRxfNzhiZYmsPpp7ItWEgB+2V/mrfxiYg= +gitlab.com/gitlab-org/fleeting/taskscaler v0.0.0-20240418203657-a3339bcbff6a h1:Mq2rFxEqR4zfTcWWlmg+V1g2U2FCSdd8yTfzzonSaEE= +gitlab.com/gitlab-org/fleeting/taskscaler v0.0.0-20240418203657-a3339bcbff6a/go.mod h1:1IrIGws/wUN2wxDXepfTolLjEp2ZDI4ZuHLOBVgMPBA= gitlab.com/gitlab-org/fleeting/taskscaler/metrics/prometheus v0.0.0-20230821135503-23448d122365 h1:v+Ffh2wA6RZ3D5aSkMtX1hwjS8fWBsaAxTlVluv63Pg= gitlab.com/gitlab-org/fleeting/taskscaler/metrics/prometheus v0.0.0-20230821135503-23448d122365/go.mod h1:TYPbW5w+nBr+epaz6c5Gj7qQifXAT3qW0gj+lFIAyZA= gitlab.com/gitlab-org/gitlab-terminal v0.0.0-20230425133101-519a58790bfd h1:K0ECR+mbcgKDXPoqqR0bJYKn3y1d/hW/M0/thQxQorI=