Documentation
¶
Index ¶
- Variables
- func LoadAWSConfig(ctx context.Context) (aws.Config, error)
- func RetrieveFromParameterStore(cfg aws.Config, key string) (string, error)
- type ASGDriver
- func (a *ASGDriver) CleanupDanglingInstances(ctx context.Context, minimumInstanceUptime time.Duration, ...) error
- func (a *ASGDriver) Describe(ctx context.Context) (AutoscaleGroupDetails, error)
- func (a *ASGDriver) GetAutoscalingActivities(ctx context.Context, nextToken *string) (*autoscaling.DescribeScalingActivitiesOutput, error)
- func (a *ASGDriver) GetLastScalingInAndOutActivity(ctx context.Context, findScaleOut, findScaleIn bool) (*types.Activity, *types.Activity, error)
- func (a *ASGDriver) SendSIGTERMToAgents(ctx context.Context, instanceID string) error
- func (a *ASGDriver) SetDesiredCapacity(ctx context.Context, count int64) error
- type AutoscaleGroupDetails
- type Params
- type ScaleParams
- type Scaler
- type ScalingCalculator
Constants ¶
This section is empty.
Variables ¶
var ErrWindowsGracefulScaleInNotSupported = errors.New("graceful scale-in not supported on Windows")
ErrWindowsGracefulScaleInNotSupported is returned when attempting graceful scale-in on Windows instances. Windows instances don't support SIGTERM-based graceful shutdown; they rely on lifecycle hooks instead.
Functions ¶
func LoadAWSConfig ¶ added in v1.12.0
LoadAWSConfig loads the AWS SDK config with adaptive retry mode and 8 max attempts. The SDK default (3 attempts, no client-side rate limiting) gives up on throttling errors when many scaler Lambdas hit the same APIs at once.
Set AWS_RETRY_MODE or AWS_MAX_ATTEMPTS to override.
Types ¶
type ASGDriver ¶ added in v1.2.0
type ASGDriver struct {
Name string
Cfg aws.Config
MaxDescribeScalingActivitiesPages int
ElasticCIMode bool
MinimumInstanceUptime time.Duration
MaxDanglingInstancesToCheck int // Maximum number of instances to check for dangling instances (only used for dangling instance scanning, not for normal scale-in)
DanglingInstancesCheckInterval time.Duration // Interval between dangling-instance checks; used to rotate the check window. Defaults to 60s when 0.
// contains filtered or unexported fields
}
func (*ASGDriver) CleanupDanglingInstances ¶ added in v1.9.3
func (a *ASGDriver) CleanupDanglingInstances(ctx context.Context, minimumInstanceUptime time.Duration, maxDanglingInstancesToCheck int) error
CleanupDanglingInstances finds and marks unhealthy any "zombie" instances where the buildkite-agent service has stopped running but the EC2 instance is still alive.
This is different from normal scale-in: - Normal scale-in: instances are healthy, jobs may be running -> uses SIGTERM for graceful shutdown - This function: agent service is stopped, no jobs can be running -> safe to mark as unhealthy
Marking instances unhealthy (via autoscaling:SetInstanceHealth) causes the ASG to terminate and replace them according to its configured policies.
func (*ASGDriver) Describe ¶ added in v1.2.0
func (a *ASGDriver) Describe(ctx context.Context) (AutoscaleGroupDetails, error)
func (*ASGDriver) GetAutoscalingActivities ¶ added in v1.2.0
func (a *ASGDriver) GetAutoscalingActivities(ctx context.Context, nextToken *string) (*autoscaling.DescribeScalingActivitiesOutput, error)
func (*ASGDriver) GetLastScalingInAndOutActivity ¶ added in v1.2.0
func (*ASGDriver) SendSIGTERMToAgents ¶ added in v1.9.3
type AutoscaleGroupDetails ¶
type Params ¶
type Params struct {
AutoScalingGroupName string
AgentsPerInstance int
BuildkiteAgentToken string
BuildkiteQueue string
UserAgent string
PublishCloudWatchMetrics bool
DryRun bool
IncludeWaiting bool
ScaleInParams ScaleParams
ScaleOutParams ScaleParams
InstanceBuffer int
ScaleOnlyAfterAllEvent bool
AvailabilityThreshold float64 // Threshold for agent availability (default 50%, all modes)
ASGActivityCooldown time.Duration // How long to wait after an ASG activity before scaling again
ElasticCIMode bool // Special mode for Elastic CI Stack with additional safety checks
MinimumInstanceUptime time.Duration // How long instance should be online before being eligible for dangling instance check
MaxDanglingInstancesToCheck int // Maximum number of instances to check for dangling instances (only used for dangling instance scanning, not for normal scale-in)
MaxInstanceCap int // Maximum instance count cap (0 means no cap)
DanglingInstancesCheckInterval time.Duration // Interval between dangling-instance checks; used to rotate the check window. Defaults to 60s when 0.
}
type ScaleParams ¶
type Scaler ¶
type Scaler struct {
// contains filtered or unexported fields
}
func (*Scaler) LastScaleIn ¶
func (*Scaler) LastScaleOut ¶
type ScalingCalculator ¶ added in v1.1.0
type ScalingCalculator struct {
// contains filtered or unexported fields
}
func (*ScalingCalculator) DesiredCount ¶ added in v1.1.0
func (sc *ScalingCalculator) DesiredCount(metrics *buildkite.AgentMetrics, asg *AutoscaleGroupDetails) int64