mirror of https://github.com/kubernetes/kops.git
Migrate autoscaling to aws-sdk-go-v2
This commit is contained in:
parent
f3b215992b
commit
d4d39eb0fe
|
@ -19,18 +19,18 @@ package mockautoscaling
|
|||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"k8s.io/kops/util/pkg/awsinterfaces"
|
||||
)
|
||||
|
||||
type MockAutoscaling struct {
|
||||
// Mock out interface
|
||||
autoscalingiface.AutoScalingAPI
|
||||
awsinterfaces.AutoScalingAPI
|
||||
|
||||
mutex sync.Mutex
|
||||
Groups map[string]*autoscaling.Group
|
||||
WarmPoolInstances map[string][]*autoscaling.Instance
|
||||
LifecycleHooks map[string]*autoscaling.LifecycleHook
|
||||
Groups map[string]*autoscalingtypes.AutoScalingGroup
|
||||
WarmPoolInstances map[string][]autoscalingtypes.Instance
|
||||
LifecycleHooks map[string]*autoscalingtypes.LifecycleHook
|
||||
}
|
||||
|
||||
var _ autoscalingiface.AutoScalingAPI = &MockAutoscaling{}
|
||||
var _ awsinterfaces.AutoScalingAPI = &MockAutoscaling{}
|
||||
|
|
|
@ -20,13 +20,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func (m *MockAutoscaling) AttachLoadBalancers(request *autoscaling.AttachLoadBalancersInput) (*autoscaling.AttachLoadBalancersOutput, error) {
|
||||
func (m *MockAutoscaling) AttachLoadBalancers(ctx context.Context, request *autoscaling.AttachLoadBalancersInput, optFns ...func(*autoscaling.Options)) (*autoscaling.AttachLoadBalancersOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
@ -43,17 +41,7 @@ func (m *MockAutoscaling) AttachLoadBalancers(request *autoscaling.AttachLoadBal
|
|||
return &autoscaling.AttachLoadBalancersOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) AttachLoadBalancersWithContext(aws.Context, *autoscaling.AttachLoadBalancersInput, ...request.Option) (*autoscaling.AttachLoadBalancersOutput, error) {
|
||||
klog.Fatalf("Not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) AttachLoadBalancersRequest(*autoscaling.AttachLoadBalancersInput) (*request.Request, *autoscaling.AttachLoadBalancersOutput) {
|
||||
klog.Fatalf("Not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) AttachLoadBalancerTargetGroupsWithContext(ctx aws.Context, request *autoscaling.AttachLoadBalancerTargetGroupsInput, opts ...request.Option) (*autoscaling.AttachLoadBalancerTargetGroupsOutput, error) {
|
||||
func (m *MockAutoscaling) AttachLoadBalancerTargetGroups(ctx context.Context, request *autoscaling.AttachLoadBalancerTargetGroupsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.AttachLoadBalancerTargetGroupsOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
@ -69,7 +57,3 @@ func (m *MockAutoscaling) AttachLoadBalancerTargetGroupsWithContext(ctx aws.Cont
|
|||
asg.TargetGroupARNs = append(asg.TargetGroupARNs, request.TargetGroupARNs...)
|
||||
return &autoscaling.AttachLoadBalancerTargetGroupsOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) AttachLoadBalancerTargetGroups(request *autoscaling.AttachLoadBalancerTargetGroupsInput) (*autoscaling.AttachLoadBalancerTargetGroupsOutput, error) {
|
||||
return m.AttachLoadBalancerTargetGroupsWithContext(context.TODO(), request)
|
||||
}
|
||||
|
|
|
@ -17,8 +17,10 @@ limitations under the License.
|
|||
package mockautoscaling
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"context"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||
)
|
||||
|
@ -36,6 +38,7 @@ func (m *MockAutoscaling) GetEC2Shim(e ec2iface.EC2API) ec2iface.EC2API {
|
|||
}
|
||||
|
||||
func (e *ec2Shim) TerminateInstances(input *ec2.TerminateInstancesInput) (*ec2.TerminateInstancesOutput, error) {
|
||||
ctx := context.TODO()
|
||||
if input.DryRun != nil && *input.DryRun {
|
||||
return &ec2.TerminateInstancesOutput{}, nil
|
||||
}
|
||||
|
@ -44,7 +47,7 @@ func (e *ec2Shim) TerminateInstances(input *ec2.TerminateInstancesInput) (*ec2.T
|
|||
InstanceId: id,
|
||||
ShouldDecrementDesiredCapacity: aws.Bool(false),
|
||||
}
|
||||
if _, err := e.mockAutoscaling.TerminateInstanceInAutoScalingGroup(request); err != nil {
|
||||
if _, err := e.mockAutoscaling.TerminateInstanceInAutoScalingGroup(ctx, request); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,33 +19,56 @@ package mockautoscaling
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func (m *MockAutoscaling) AttachInstances(input *autoscaling.AttachInstancesInput) (*autoscaling.AttachInstancesOutput, error) {
|
||||
func (m *MockAutoscaling) AttachInstances(ctx context.Context, input *autoscaling.AttachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.AttachInstancesOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
klog.V(2).Infof("Mock AttachInstances %v", input)
|
||||
|
||||
g := m.Groups[aws.StringValue(input.AutoScalingGroupName)]
|
||||
g := m.Groups[aws.ToString(input.AutoScalingGroupName)]
|
||||
if g == nil {
|
||||
return nil, fmt.Errorf("AutoScaling Group not found")
|
||||
}
|
||||
|
||||
for _, instanceID := range input.InstanceIds {
|
||||
g.Instances = append(g.Instances, &autoscaling.Instance{InstanceId: instanceID})
|
||||
g.Instances = append(g.Instances, autoscalingtypes.Instance{InstanceId: aws.String(instanceID)})
|
||||
}
|
||||
|
||||
return &autoscaling.AttachInstancesOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) CreateAutoScalingGroupWithContext(ctx aws.Context, input *autoscaling.CreateAutoScalingGroupInput, options ...request.Option) (*autoscaling.CreateAutoScalingGroupOutput, error) {
|
||||
func (m *MockAutoscaling) DetachInstances(ctx context.Context, input *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
klog.V(2).Infof("Mock AttachInstances %v", input)
|
||||
|
||||
g := m.Groups[aws.ToString(input.AutoScalingGroupName)]
|
||||
if g == nil {
|
||||
return nil, fmt.Errorf("AutoScaling Group not found")
|
||||
}
|
||||
|
||||
instances := make([]autoscalingtypes.Instance, 0)
|
||||
for _, instance := range g.Instances {
|
||||
if !slices.Contains(input.InstanceIds, aws.ToString(instance.InstanceId)) {
|
||||
instances = append(instances, instance)
|
||||
}
|
||||
}
|
||||
g.Instances = instances
|
||||
|
||||
return &autoscaling.DetachInstancesOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) CreateAutoScalingGroup(ctx context.Context, input *autoscaling.CreateAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.CreateAutoScalingGroupOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
@ -53,7 +76,7 @@ func (m *MockAutoscaling) CreateAutoScalingGroupWithContext(ctx aws.Context, inp
|
|||
|
||||
createdTime := time.Now().UTC()
|
||||
|
||||
g := &autoscaling.Group{
|
||||
g := &autoscalingtypes.AutoScalingGroup{
|
||||
AutoScalingGroupName: input.AutoScalingGroupName,
|
||||
AvailabilityZones: input.AvailabilityZones,
|
||||
CreatedTime: &createdTime,
|
||||
|
@ -62,7 +85,7 @@ func (m *MockAutoscaling) CreateAutoScalingGroupWithContext(ctx aws.Context, inp
|
|||
// EnabledMetrics: input.EnabledMetrics,
|
||||
HealthCheckGracePeriod: input.HealthCheckGracePeriod,
|
||||
HealthCheckType: input.HealthCheckType,
|
||||
Instances: []*autoscaling.Instance{},
|
||||
Instances: []autoscalingtypes.Instance{},
|
||||
LaunchConfigurationName: input.LaunchConfigurationName,
|
||||
LaunchTemplate: input.LaunchTemplate,
|
||||
LoadBalancerNames: input.LoadBalancerNames,
|
||||
|
@ -71,7 +94,7 @@ func (m *MockAutoscaling) CreateAutoScalingGroupWithContext(ctx aws.Context, inp
|
|||
NewInstancesProtectedFromScaleIn: input.NewInstancesProtectedFromScaleIn,
|
||||
PlacementGroup: input.PlacementGroup,
|
||||
// Status: input.Status,
|
||||
SuspendedProcesses: make([]*autoscaling.SuspendedProcess, 0),
|
||||
SuspendedProcesses: make([]autoscalingtypes.SuspendedProcess, 0),
|
||||
TargetGroupARNs: input.TargetGroupARNs,
|
||||
TerminationPolicies: input.TerminationPolicies,
|
||||
VPCZoneIdentifier: input.VPCZoneIdentifier,
|
||||
|
@ -86,7 +109,7 @@ func (m *MockAutoscaling) CreateAutoScalingGroupWithContext(ctx aws.Context, inp
|
|||
}
|
||||
|
||||
for _, tag := range input.Tags {
|
||||
g.Tags = append(g.Tags, &autoscaling.TagDescription{
|
||||
g.Tags = append(g.Tags, autoscalingtypes.TagDescription{
|
||||
Key: tag.Key,
|
||||
PropagateAtLaunch: tag.PropagateAtLaunch,
|
||||
ResourceId: tag.ResourceId,
|
||||
|
@ -96,14 +119,14 @@ func (m *MockAutoscaling) CreateAutoScalingGroupWithContext(ctx aws.Context, inp
|
|||
}
|
||||
|
||||
if m.Groups == nil {
|
||||
m.Groups = make(map[string]*autoscaling.Group)
|
||||
m.Groups = make(map[string]*autoscalingtypes.AutoScalingGroup)
|
||||
}
|
||||
m.Groups[*g.AutoScalingGroupName] = g
|
||||
|
||||
return &autoscaling.CreateAutoScalingGroupOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) UpdateAutoScalingGroupWithContext(ctx context.Context, request *autoscaling.UpdateAutoScalingGroupInput, opts ...request.Option) (*autoscaling.UpdateAutoScalingGroupOutput, error) {
|
||||
func (m *MockAutoscaling) UpdateAutoScalingGroup(ctx context.Context, request *autoscaling.UpdateAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.UpdateAutoScalingGroupOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
klog.V(2).Infof("Mock UpdateAutoScalingGroup %v", request)
|
||||
|
@ -164,7 +187,7 @@ func (m *MockAutoscaling) UpdateAutoScalingGroupWithContext(ctx context.Context,
|
|||
return &autoscaling.UpdateAutoScalingGroupOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) EnableMetricsCollectionWithContext(ctx aws.Context, request *autoscaling.EnableMetricsCollectionInput, opts ...request.Option) (*autoscaling.EnableMetricsCollectionOutput, error) {
|
||||
func (m *MockAutoscaling) EnableMetricsCollection(ctx context.Context, request *autoscaling.EnableMetricsCollectionInput, optFns ...func(*autoscaling.Options)) (*autoscaling.EnableMetricsCollectionOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
@ -175,20 +198,20 @@ func (m *MockAutoscaling) EnableMetricsCollectionWithContext(ctx aws.Context, re
|
|||
return nil, fmt.Errorf("AutoScalingGroup not found")
|
||||
}
|
||||
|
||||
metrics := make(map[string]*autoscaling.EnabledMetric)
|
||||
metrics := make(map[string]*autoscalingtypes.EnabledMetric)
|
||||
for _, m := range g.EnabledMetrics {
|
||||
metrics[*m.Metric] = m
|
||||
metrics[*m.Metric] = &m
|
||||
}
|
||||
for _, m := range request.Metrics {
|
||||
metrics[*m] = &autoscaling.EnabledMetric{
|
||||
Metric: m,
|
||||
metrics[m] = &autoscalingtypes.EnabledMetric{
|
||||
Metric: &m,
|
||||
Granularity: request.Granularity,
|
||||
}
|
||||
}
|
||||
|
||||
g.EnabledMetrics = nil
|
||||
for _, m := range metrics {
|
||||
g.EnabledMetrics = append(g.EnabledMetrics, m)
|
||||
g.EnabledMetrics = append(g.EnabledMetrics, *m)
|
||||
}
|
||||
|
||||
response := &autoscaling.EnableMetricsCollectionOutput{}
|
||||
|
@ -196,7 +219,7 @@ func (m *MockAutoscaling) EnableMetricsCollectionWithContext(ctx aws.Context, re
|
|||
return response, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) SuspendProcessesWithContext(ctx aws.Context, input *autoscaling.ScalingProcessQuery, opts ...request.Option) (*autoscaling.SuspendProcessesOutput, error) {
|
||||
func (m *MockAutoscaling) SuspendProcesses(ctx context.Context, input *autoscaling.SuspendProcessesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.SuspendProcessesOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
@ -210,13 +233,13 @@ func (m *MockAutoscaling) SuspendProcessesWithContext(ctx aws.Context, input *au
|
|||
for _, p := range input.ScalingProcesses {
|
||||
found := false
|
||||
for _, asgProc := range g.SuspendedProcesses {
|
||||
if aws.StringValue(asgProc.ProcessName) == aws.StringValue(p) {
|
||||
if aws.ToString(asgProc.ProcessName) == p {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
g.SuspendedProcesses = append(g.SuspendedProcesses, &autoscaling.SuspendedProcess{
|
||||
ProcessName: p,
|
||||
g.SuspendedProcesses = append(g.SuspendedProcesses, autoscalingtypes.SuspendedProcess{
|
||||
ProcessName: aws.String(p),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -224,19 +247,19 @@ func (m *MockAutoscaling) SuspendProcessesWithContext(ctx aws.Context, input *au
|
|||
return &autoscaling.SuspendProcessesOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeAutoScalingGroups(input *autoscaling.DescribeAutoScalingGroupsInput) (*autoscaling.DescribeAutoScalingGroupsOutput, error) {
|
||||
func (m *MockAutoscaling) DescribeAutoScalingGroups(ctx context.Context, input *autoscaling.DescribeAutoScalingGroupsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeAutoScalingGroupsOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
klog.V(2).Infof("Mock DescribeAutoScalingGroups: %v", input)
|
||||
|
||||
groups := []*autoscaling.Group{}
|
||||
groups := []autoscalingtypes.AutoScalingGroup{}
|
||||
for _, group := range m.Groups {
|
||||
match := false
|
||||
|
||||
if len(input.AutoScalingGroupNames) > 0 {
|
||||
for _, inputGroupName := range input.AutoScalingGroupNames {
|
||||
if aws.StringValue(group.AutoScalingGroupName) == aws.StringValue(inputGroupName) {
|
||||
if aws.ToString(group.AutoScalingGroupName) == inputGroupName {
|
||||
match = true
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +268,7 @@ func (m *MockAutoscaling) DescribeAutoScalingGroups(input *autoscaling.DescribeA
|
|||
}
|
||||
|
||||
if match {
|
||||
groups = append(groups, group)
|
||||
groups = append(groups, *group)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,13 +277,13 @@ func (m *MockAutoscaling) DescribeAutoScalingGroups(input *autoscaling.DescribeA
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) TerminateInstanceInAutoScalingGroup(input *autoscaling.TerminateInstanceInAutoScalingGroupInput) (*autoscaling.TerminateInstanceInAutoScalingGroupOutput, error) {
|
||||
func (m *MockAutoscaling) TerminateInstanceInAutoScalingGroup(ctx context.Context, input *autoscaling.TerminateInstanceInAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.TerminateInstanceInAutoScalingGroupOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
for _, group := range m.Groups {
|
||||
for i := range group.Instances {
|
||||
if aws.StringValue(group.Instances[i].InstanceId) == aws.StringValue(input.InstanceId) {
|
||||
if aws.ToString(group.Instances[i].InstanceId) == aws.ToString(input.InstanceId) {
|
||||
group.Instances = append(group.Instances[:i], group.Instances[i+1:]...)
|
||||
return &autoscaling.TerminateInstanceInAutoScalingGroupOutput{
|
||||
Activity: nil, // TODO
|
||||
|
@ -269,7 +292,7 @@ func (m *MockAutoscaling) TerminateInstanceInAutoScalingGroup(input *autoscaling
|
|||
}
|
||||
wp := m.WarmPoolInstances[*group.AutoScalingGroupName]
|
||||
for i := range wp {
|
||||
if aws.StringValue(wp[i].InstanceId) == aws.StringValue(input.InstanceId) {
|
||||
if aws.ToString(wp[i].InstanceId) == aws.ToString(input.InstanceId) {
|
||||
m.WarmPoolInstances[*group.AutoScalingGroupName] = append(wp[:i], wp[i+1:]...)
|
||||
return &autoscaling.TerminateInstanceInAutoScalingGroupOutput{
|
||||
Activity: nil, // TODO
|
||||
|
@ -281,46 +304,13 @@ func (m *MockAutoscaling) TerminateInstanceInAutoScalingGroup(input *autoscaling
|
|||
return nil, fmt.Errorf("Instance not found")
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeAutoScalingGroupsWithContext(aws.Context, *autoscaling.DescribeAutoScalingGroupsInput, ...request.Option) (*autoscaling.DescribeAutoScalingGroupsOutput, error) {
|
||||
klog.Fatalf("Not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeAutoScalingGroupsRequest(*autoscaling.DescribeAutoScalingGroupsInput) (*request.Request, *autoscaling.DescribeAutoScalingGroupsOutput) {
|
||||
klog.Fatalf("Not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeAutoScalingGroupsPagesWithContext(ctx aws.Context, request *autoscaling.DescribeAutoScalingGroupsInput, callback func(*autoscaling.DescribeAutoScalingGroupsOutput, bool) bool, options ...request.Option) error {
|
||||
if request.MaxRecords != nil {
|
||||
klog.Fatalf("MaxRecords not implemented")
|
||||
}
|
||||
if request.NextToken != nil {
|
||||
klog.Fatalf("NextToken not implemented")
|
||||
}
|
||||
|
||||
// For the mock, we just send everything in one page
|
||||
page, err := m.DescribeAutoScalingGroups(request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
callback(page, false)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeAutoScalingGroupsPages(request *autoscaling.DescribeAutoScalingGroupsInput, callback func(*autoscaling.DescribeAutoScalingGroupsOutput, bool) bool) error {
|
||||
return m.DescribeAutoScalingGroupsPagesWithContext(context.TODO(), request, callback)
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DeleteAutoScalingGroupWithContext(ctx aws.Context, request *autoscaling.DeleteAutoScalingGroupInput, options ...request.Option) (*autoscaling.DeleteAutoScalingGroupOutput, error) {
|
||||
func (m *MockAutoscaling) DeleteAutoScalingGroup(ctx context.Context, request *autoscaling.DeleteAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteAutoScalingGroupOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
klog.V(2).Infof("Mock DeleteAutoScalingGroup: %v", request)
|
||||
|
||||
id := aws.StringValue(request.AutoScalingGroupName)
|
||||
id := aws.ToString(request.AutoScalingGroupName)
|
||||
o := m.Groups[id]
|
||||
if o == nil {
|
||||
return nil, fmt.Errorf("AutoScalingGroup %q not found", id)
|
||||
|
@ -330,15 +320,10 @@ func (m *MockAutoscaling) DeleteAutoScalingGroupWithContext(ctx aws.Context, req
|
|||
return &autoscaling.DeleteAutoScalingGroupOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DeleteAutoScalingGroupRequest(*autoscaling.DeleteAutoScalingGroupInput) (*request.Request, *autoscaling.DeleteAutoScalingGroupOutput) {
|
||||
klog.Fatalf("Not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) PutLifecycleHookWithContext(ctx aws.Context, input *autoscaling.PutLifecycleHookInput, options ...request.Option) (*autoscaling.PutLifecycleHookOutput, error) {
|
||||
func (m *MockAutoscaling) PutLifecycleHook(ctx context.Context, input *autoscaling.PutLifecycleHookInput, optFns ...func(*autoscaling.Options)) (*autoscaling.PutLifecycleHookOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
hook := &autoscaling.LifecycleHook{
|
||||
hook := &autoscalingtypes.LifecycleHook{
|
||||
AutoScalingGroupName: input.AutoScalingGroupName,
|
||||
DefaultResult: input.DefaultResult,
|
||||
GlobalTimeout: input.HeartbeatTimeout,
|
||||
|
@ -351,7 +336,7 @@ func (m *MockAutoscaling) PutLifecycleHookWithContext(ctx aws.Context, input *au
|
|||
}
|
||||
|
||||
if m.LifecycleHooks == nil {
|
||||
m.LifecycleHooks = make(map[string]*autoscaling.LifecycleHook)
|
||||
m.LifecycleHooks = make(map[string]*autoscalingtypes.LifecycleHook)
|
||||
}
|
||||
name := *input.AutoScalingGroupName + "::" + *input.LifecycleHookName
|
||||
m.LifecycleHooks[name] = hook
|
||||
|
@ -359,17 +344,17 @@ func (m *MockAutoscaling) PutLifecycleHookWithContext(ctx aws.Context, input *au
|
|||
return &autoscaling.PutLifecycleHookOutput{}, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeLifecycleHooksWithContext(ctx aws.Context, input *autoscaling.DescribeLifecycleHooksInput, options ...request.Option) (*autoscaling.DescribeLifecycleHooksOutput, error) {
|
||||
func (m *MockAutoscaling) DescribeLifecycleHooks(ctx context.Context, input *autoscaling.DescribeLifecycleHooksInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeLifecycleHooksOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
response := &autoscaling.DescribeLifecycleHooksOutput{}
|
||||
for _, lifecycleHookName := range input.LifecycleHookNames {
|
||||
name := *input.AutoScalingGroupName + "::" + *lifecycleHookName
|
||||
name := *input.AutoScalingGroupName + "::" + lifecycleHookName
|
||||
|
||||
hook := m.LifecycleHooks[name]
|
||||
if hook != nil {
|
||||
response.LifecycleHooks = append(response.LifecycleHooks, hook)
|
||||
response.LifecycleHooks = append(response.LifecycleHooks, *hook)
|
||||
}
|
||||
}
|
||||
return response, nil
|
||||
|
|
|
@ -19,13 +19,12 @@ package mockautoscaling
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
func (m *MockAutoscaling) DescribeTagsWithContext(ctx aws.Context, request *autoscaling.DescribeTagsInput, opt ...request.Option) (*autoscaling.DescribeTagsOutput, error) {
|
||||
func (m *MockAutoscaling) DescribeTags(ctx context.Context, request *autoscaling.DescribeTagsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeTagsOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
|
@ -35,10 +34,10 @@ func (m *MockAutoscaling) DescribeTagsWithContext(ctx aws.Context, request *auto
|
|||
allFiltersMatch := true
|
||||
for _, filter := range request.Filters {
|
||||
match := false
|
||||
switch aws.StringValue(filter.Name) {
|
||||
switch aws.ToString(filter.Name) {
|
||||
case "value":
|
||||
for _, v := range filter.Values {
|
||||
if aws.StringValue(tag.Value) == aws.StringValue(v) {
|
||||
if aws.ToString(tag.Value) == v {
|
||||
match = true
|
||||
}
|
||||
}
|
||||
|
@ -63,24 +62,3 @@ func (m *MockAutoscaling) DescribeTagsWithContext(ctx aws.Context, request *auto
|
|||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeTags(request *autoscaling.DescribeTagsInput) (*autoscaling.DescribeTagsOutput, error) {
|
||||
return m.DescribeTagsWithContext(context.TODO(), request)
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeTagsRequest(*autoscaling.DescribeTagsInput) (*request.Request, *autoscaling.DescribeTagsOutput) {
|
||||
klog.Fatalf("Not implemented")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DescribeTagsPagesWithContext(ctx aws.Context, request *autoscaling.DescribeTagsInput, callback func(*autoscaling.DescribeTagsOutput, bool) bool, options ...request.Option) error {
|
||||
// For the mock, we just send everything in one page
|
||||
page, err := m.DescribeTagsWithContext(ctx, request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
callback(page, false)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -17,12 +17,12 @@ limitations under the License.
|
|||
package mockautoscaling
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"context"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
)
|
||||
|
||||
func (m *MockAutoscaling) DescribeWarmPoolWithContext(ctx aws.Context, input *autoscaling.DescribeWarmPoolInput, options ...request.Option) (*autoscaling.DescribeWarmPoolOutput, error) {
|
||||
func (m *MockAutoscaling) DescribeWarmPool(ctx context.Context, input *autoscaling.DescribeWarmPoolInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeWarmPoolOutput, error) {
|
||||
instances, found := m.WarmPoolInstances[*input.AutoScalingGroupName]
|
||||
if !found {
|
||||
return &autoscaling.DescribeWarmPoolOutput{}, nil
|
||||
|
@ -33,6 +33,6 @@ func (m *MockAutoscaling) DescribeWarmPoolWithContext(ctx aws.Context, input *au
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
func (m *MockAutoscaling) DeleteWarmPool(*autoscaling.DeleteWarmPoolInput) (*autoscaling.DeleteWarmPoolOutput, error) {
|
||||
func (m *MockAutoscaling) DeleteWarmPool(ctx context.Context, input *autoscaling.DeleteWarmPoolInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteWarmPoolOutput, error) {
|
||||
return &autoscaling.DeleteWarmPoolOutput{}, nil
|
||||
}
|
||||
|
|
|
@ -17,16 +17,18 @@ limitations under the License.
|
|||
package instancegroups
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
kopsapi "k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/pkg/cloudinstances"
|
||||
)
|
||||
|
||||
func TestWarmPoolOnlyRoll(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
c, cloud := getTestSetup()
|
||||
|
||||
groupName := "warmPoolOnly"
|
||||
|
@ -45,9 +47,9 @@ func TestWarmPoolOnlyRoll(t *testing.T) {
|
|||
MaxSurge: &maxSurge,
|
||||
}
|
||||
|
||||
cloud.Autoscaling().AttachInstances(&autoscaling.AttachInstancesInput{
|
||||
cloud.Autoscaling().AttachInstances(ctx, &autoscaling.AttachInstancesInput{
|
||||
AutoScalingGroupName: &groupName,
|
||||
InstanceIds: []*string{&instanceID},
|
||||
InstanceIds: []string{instanceID},
|
||||
})
|
||||
|
||||
instance, err := group.NewCloudInstance("node-1", cloudinstances.CloudInstanceStatusNeedsUpdate, nil)
|
||||
|
|
|
@ -25,10 +25,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -44,6 +43,7 @@ import (
|
|||
"k8s.io/kops/pkg/validation"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||
"k8s.io/kops/util/pkg/awsinterfaces"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -57,7 +57,7 @@ func getTestSetup() (*RollingUpdateCluster, *awsup.MockAWSCloud) {
|
|||
|
||||
mockcloud := awsup.BuildMockAWSCloud("us-east-1", "abc")
|
||||
mockAutoscaling := &mockautoscaling.MockAutoscaling{
|
||||
WarmPoolInstances: make(map[string][]*autoscaling.Instance),
|
||||
WarmPoolInstances: make(map[string][]autoscalingtypes.Instance),
|
||||
}
|
||||
mockcloud.MockAutoscaling = mockAutoscaling
|
||||
mockcloud.MockEC2 = mockAutoscaling.GetEC2Shim(mockcloud.MockEC2)
|
||||
|
@ -152,18 +152,18 @@ func makeGroup(groups map[string]*cloudinstances.CloudInstanceGroup, k8sClient k
|
|||
Role: role,
|
||||
},
|
||||
},
|
||||
Raw: &autoscaling.Group{AutoScalingGroupName: aws.String("asg-" + name)},
|
||||
Raw: &autoscalingtypes.AutoScalingGroup{AutoScalingGroupName: aws.String("asg-" + name)},
|
||||
}
|
||||
groups[name] = group
|
||||
|
||||
cloud.Autoscaling().CreateAutoScalingGroupWithContext(ctx, &autoscaling.CreateAutoScalingGroupInput{
|
||||
cloud.Autoscaling().CreateAutoScalingGroup(ctx, &autoscaling.CreateAutoScalingGroupInput{
|
||||
AutoScalingGroupName: aws.String(name),
|
||||
DesiredCapacity: aws.Int64(int64(count)),
|
||||
MinSize: aws.Int64(1),
|
||||
MaxSize: aws.Int64(5),
|
||||
DesiredCapacity: aws.Int32(int32(count)),
|
||||
MinSize: aws.Int32(1),
|
||||
MaxSize: aws.Int32(5),
|
||||
})
|
||||
|
||||
var instanceIds []*string
|
||||
var instanceIds []string
|
||||
for i := 0; i < count; i++ {
|
||||
id := name + string(rune('a'+i))
|
||||
var node *v1.Node
|
||||
|
@ -183,9 +183,9 @@ func makeGroup(groups map[string]*cloudinstances.CloudInstanceGroup, k8sClient k
|
|||
|
||||
group.NewCloudInstance(id, status, node)
|
||||
|
||||
instanceIds = append(instanceIds, aws.String(id))
|
||||
instanceIds = append(instanceIds, id)
|
||||
}
|
||||
cloud.Autoscaling().AttachInstances(&autoscaling.AttachInstancesInput{
|
||||
cloud.Autoscaling().AttachInstances(ctx, &autoscaling.AttachInstancesInput{
|
||||
AutoScalingGroupName: aws.String(name),
|
||||
InstanceIds: instanceIds,
|
||||
})
|
||||
|
@ -210,6 +210,7 @@ func getGroupsAllNeedUpdate(k8sClient kubernetes.Interface, cloud awsup.AWSCloud
|
|||
}
|
||||
|
||||
func TestRollingUpdateAllNeedUpdate(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
c, cloud := getTestSetup()
|
||||
|
||||
groups := getGroupsAllNeedUpdate(c.K8sClient, cloud)
|
||||
|
@ -255,13 +256,14 @@ func TestRollingUpdateAllNeedUpdate(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
assert.Emptyf(t, group.Instances, "Not all instances terminated in group %s", group.AutoScalingGroupName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRollingUpdateAllNeedUpdateCloudonly(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
c, cloud := getTestSetup()
|
||||
|
||||
c.CloudOnly = true
|
||||
|
@ -273,13 +275,14 @@ func TestRollingUpdateAllNeedUpdateCloudonly(t *testing.T) {
|
|||
|
||||
assert.Empty(t, c.K8sClient.(*fake.Clientset).Actions())
|
||||
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
assert.Emptyf(t, group.Instances, "Not all instances terminated in group %s", group.AutoScalingGroupName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRollingUpdateAllNeedUpdateNoFailOnValidate(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
c, cloud := getTestSetup()
|
||||
|
||||
c.FailOnValidate = false
|
||||
|
@ -289,7 +292,7 @@ func TestRollingUpdateAllNeedUpdateNoFailOnValidate(t *testing.T) {
|
|||
err := c.RollingUpdate(groups, &kopsapi.InstanceGroupList{})
|
||||
assert.NoError(t, err, "rolling update")
|
||||
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
assert.Emptyf(t, group.Instances, "Not all instances terminated in group %s", group.AutoScalingGroupName)
|
||||
}
|
||||
|
@ -311,6 +314,7 @@ func TestRollingUpdateNoneNeedUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRollingUpdateNoneNeedUpdateWithForce(t *testing.T) {
|
||||
ctx := context.TODO()
|
||||
c, cloud := getTestSetup()
|
||||
groups := getGroups(c.K8sClient, cloud)
|
||||
|
||||
|
@ -319,7 +323,7 @@ func TestRollingUpdateNoneNeedUpdateWithForce(t *testing.T) {
|
|||
err := c.RollingUpdate(groups, &kopsapi.InstanceGroupList{})
|
||||
assert.NoError(t, err, "rolling update")
|
||||
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
assert.Emptyf(t, group.Instances, "Not all instances terminated in group %s", group.AutoScalingGroupName)
|
||||
}
|
||||
|
@ -417,11 +421,12 @@ type failAfterOneNodeClusterValidator struct {
|
|||
}
|
||||
|
||||
func (v *failAfterOneNodeClusterValidator) Validate() (*validation.ValidationCluster, error) {
|
||||
asgGroups, _ := v.Cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{aws.String(v.Group)},
|
||||
ctx := context.TODO()
|
||||
asgGroups, _ := v.Cloud.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []string{v.Group},
|
||||
})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
if int64(len(group.Instances)) < *group.DesiredCapacity {
|
||||
if int32(len(group.Instances)) < *group.DesiredCapacity {
|
||||
if v.ReturnError {
|
||||
return nil, errors.New("testing validation error")
|
||||
}
|
||||
|
@ -631,8 +636,9 @@ type flappingClusterValidator struct {
|
|||
}
|
||||
|
||||
func (v *flappingClusterValidator) Validate() (*validation.ValidationCluster, error) {
|
||||
asgGroups, _ := v.Cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{aws.String("master-1")},
|
||||
ctx := context.TODO()
|
||||
asgGroups, _ := v.Cloud.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []string{"master-1"},
|
||||
})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
switch len(group.Instances) {
|
||||
|
@ -935,18 +941,18 @@ func TestRollingUpdateDisabled(t *testing.T) {
|
|||
}
|
||||
|
||||
type disabledSurgeTest struct {
|
||||
autoscalingiface.AutoScalingAPI
|
||||
awsinterfaces.AutoScalingAPI
|
||||
t *testing.T
|
||||
mutex sync.Mutex
|
||||
numDetached int
|
||||
}
|
||||
|
||||
func (m *disabledSurgeTest) DetachInstancesWithContext(ctx context.Context, input *autoscaling.DetachInstancesInput, option ...request.Option) (*autoscaling.DetachInstancesOutput, error) {
|
||||
func (m *disabledSurgeTest) DetachInstances(ctx context.Context, input *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error) {
|
||||
m.mutex.Lock()
|
||||
defer m.mutex.Unlock()
|
||||
|
||||
for _, id := range input.InstanceIds {
|
||||
assert.NotContains(m.t, *id, "master")
|
||||
assert.NotContains(m.t, id, "master")
|
||||
m.numDetached++
|
||||
}
|
||||
return &autoscaling.DetachInstancesOutput{}, nil
|
||||
|
@ -1232,11 +1238,11 @@ func TestRollingUpdateMaxUnavailableAllNeedUpdateMaster(t *testing.T) {
|
|||
}
|
||||
|
||||
type concurrentTestAutoscaling struct {
|
||||
autoscalingiface.AutoScalingAPI
|
||||
awsinterfaces.AutoScalingAPI
|
||||
ConcurrentTest *concurrentTest
|
||||
}
|
||||
|
||||
func (m *concurrentTestAutoscaling) DetachInstancesWithContext(ctx context.Context, input *autoscaling.DetachInstancesInput, option ...request.Option) (*autoscaling.DetachInstancesOutput, error) {
|
||||
func (m *concurrentTestAutoscaling) DetachInstances(ctx context.Context, input *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error) {
|
||||
m.ConcurrentTest.mutex.Lock()
|
||||
defer m.ConcurrentTest.mutex.Unlock()
|
||||
|
||||
|
@ -1245,8 +1251,8 @@ func (m *concurrentTestAutoscaling) DetachInstancesWithContext(ctx context.Conte
|
|||
|
||||
for _, id := range input.InstanceIds {
|
||||
assert.Less(m.ConcurrentTest.t, len(m.ConcurrentTest.detached), m.ConcurrentTest.surge, "Number of detached instances")
|
||||
assert.False(m.ConcurrentTest.t, m.ConcurrentTest.detached[*id], *id+" already detached")
|
||||
m.ConcurrentTest.detached[*id] = true
|
||||
assert.False(m.ConcurrentTest.t, m.ConcurrentTest.detached[id], id+" already detached")
|
||||
m.ConcurrentTest.detached[id] = true
|
||||
}
|
||||
return &autoscaling.DetachInstancesOutput{}, nil
|
||||
}
|
||||
|
@ -1314,11 +1320,11 @@ func TestRollingUpdateMaxSurgeAllButOneNeedUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
type countDetach struct {
|
||||
autoscalingiface.AutoScalingAPI
|
||||
awsinterfaces.AutoScalingAPI
|
||||
Count int
|
||||
}
|
||||
|
||||
func (c *countDetach) DetachInstancesWithContext(ctx context.Context, input *autoscaling.DetachInstancesInput, option ...request.Option) (*autoscaling.DetachInstancesOutput, error) {
|
||||
func (c *countDetach) DetachInstances(ctx context.Context, input *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error) {
|
||||
c.Count += len(input.InstanceIds)
|
||||
return &autoscaling.DetachInstancesOutput{}, nil
|
||||
}
|
||||
|
@ -1345,10 +1351,10 @@ func TestRollingUpdateMaxSurgeGreaterThanNeedUpdate(t *testing.T) {
|
|||
}
|
||||
|
||||
type failDetachAutoscaling struct {
|
||||
autoscalingiface.AutoScalingAPI
|
||||
awsinterfaces.AutoScalingAPI
|
||||
}
|
||||
|
||||
func (m *failDetachAutoscaling) DetachInstancesWithContext(ctx context.Context, input *autoscaling.DetachInstancesInput, option ...request.Option) (*autoscaling.DetachInstancesOutput, error) {
|
||||
func (m *failDetachAutoscaling) DetachInstances(ctx context.Context, input *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error) {
|
||||
return nil, fmt.Errorf("testing error")
|
||||
}
|
||||
|
||||
|
@ -1452,18 +1458,18 @@ func (t *alreadyDetachedTest) TerminateInstances(input *ec2.TerminateInstancesIn
|
|||
}
|
||||
|
||||
type alreadyDetachedTestAutoscaling struct {
|
||||
autoscalingiface.AutoScalingAPI
|
||||
awsinterfaces.AutoScalingAPI
|
||||
AlreadyDetachedTest *alreadyDetachedTest
|
||||
}
|
||||
|
||||
func (m *alreadyDetachedTestAutoscaling) DetachInstancesWithContext(ctx aws.Context, input *autoscaling.DetachInstancesInput, options ...request.Option) (*autoscaling.DetachInstancesOutput, error) {
|
||||
func (m *alreadyDetachedTestAutoscaling) DetachInstances(ctx context.Context, input *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error) {
|
||||
m.AlreadyDetachedTest.mutex.Lock()
|
||||
defer m.AlreadyDetachedTest.mutex.Unlock()
|
||||
|
||||
for _, id := range input.InstanceIds {
|
||||
assert.Less(m.AlreadyDetachedTest.t, len(m.AlreadyDetachedTest.detached), 3, "Number of detached instances")
|
||||
assert.False(m.AlreadyDetachedTest.t, m.AlreadyDetachedTest.detached[*id], *id+" already detached")
|
||||
m.AlreadyDetachedTest.detached[*id] = true
|
||||
assert.False(m.AlreadyDetachedTest.t, m.AlreadyDetachedTest.detached[id], id+" already detached")
|
||||
m.AlreadyDetachedTest.detached[id] = true
|
||||
}
|
||||
return &autoscaling.DetachInstancesOutput{}, nil
|
||||
}
|
||||
|
@ -1550,8 +1556,8 @@ func assertTaint(t *testing.T, action testingclient.PatchAction) {
|
|||
}
|
||||
|
||||
func assertGroupInstanceCount(t *testing.T, cloud awsup.AWSCloud, groupName string, expected int) {
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(&autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{aws.String(groupName)},
|
||||
asgGroups, _ := cloud.Autoscaling().DescribeAutoScalingGroups(context.Background(), &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []string{groupName},
|
||||
})
|
||||
for _, group := range asgGroups.AutoScalingGroups {
|
||||
assert.Lenf(t, group.Instances, expected, "%s instances", groupName)
|
||||
|
|
|
@ -19,7 +19,7 @@ package instancegroups
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -82,13 +82,12 @@ func makeGroupWithWarmPool(groups map[string]*cloudinstances.CloudInstanceGroup,
|
|||
|
||||
group := groups[name]
|
||||
|
||||
wpInstances := []*autoscaling.Instance{}
|
||||
warmStoppedState := autoscaling.LifecycleStateWarmedStopped
|
||||
wpInstances := []autoscalingtypes.Instance{}
|
||||
for i := 0; i < warmCount; i++ {
|
||||
id := name + "-wp-" + string(rune('a'+i))
|
||||
instance := &autoscaling.Instance{
|
||||
instance := autoscalingtypes.Instance{
|
||||
InstanceId: &id,
|
||||
LifecycleState: &warmStoppedState,
|
||||
LifecycleState: autoscalingtypes.LifecycleStateWarmedStopped,
|
||||
}
|
||||
wpInstances = append(wpInstances, instance)
|
||||
|
||||
|
|
|
@ -99,8 +99,10 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e
|
|||
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
|
||||
}
|
||||
if warmPool.IsEnabled() {
|
||||
warmPoolTask.MinSize = warmPool.MinSize
|
||||
warmPoolTask.MaxSize = warmPool.MaxSize
|
||||
warmPoolTask.MinSize = int32(warmPool.MinSize)
|
||||
if warmPool.MaxSize != nil {
|
||||
warmPoolTask.MaxSize = fi.PtrTo(int32(aws.ToInt64(warmPool.MaxSize)))
|
||||
}
|
||||
tsk.WarmPool = warmPoolTask
|
||||
} else {
|
||||
tsk.WarmPool = nil
|
||||
|
@ -120,7 +122,7 @@ func (b *AutoscalingGroupModelBuilder) Build(c *fi.CloudupModelBuilderContext) e
|
|||
DefaultResult: aws.String("ABANDON"),
|
||||
// We let nodeup have 10 min to complete. Normally this should happen much faster,
|
||||
// but CP nodes need 5 min or so to start on new clusters, and we need to wait for that.
|
||||
HeartbeatTimeout: aws.Int64(600),
|
||||
HeartbeatTimeout: aws.Int32(600),
|
||||
LifecycleTransition: aws.String("autoscaling:EC2_INSTANCE_LAUNCHING"),
|
||||
Enabled: &enableHook,
|
||||
}
|
||||
|
@ -407,17 +409,17 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo
|
|||
InstanceProtection: fi.PtrTo(false),
|
||||
}
|
||||
|
||||
minSize := fi.PtrTo(int64(1))
|
||||
maxSize := fi.PtrTo(int64(1))
|
||||
minSize := fi.PtrTo(int32(1))
|
||||
maxSize := fi.PtrTo(int32(1))
|
||||
if ig.Spec.MinSize != nil {
|
||||
minSize = fi.PtrTo(int64(*ig.Spec.MinSize))
|
||||
minSize = fi.PtrTo(int32(*ig.Spec.MinSize))
|
||||
} else if ig.Spec.Role == kops.InstanceGroupRoleNode {
|
||||
minSize = fi.PtrTo(int64(2))
|
||||
minSize = fi.PtrTo(int32(2))
|
||||
}
|
||||
if ig.Spec.MaxSize != nil {
|
||||
maxSize = fi.PtrTo(int64(*ig.Spec.MaxSize))
|
||||
maxSize = fi.PtrTo(int32(*ig.Spec.MaxSize))
|
||||
} else if ig.Spec.Role == kops.InstanceGroupRoleNode {
|
||||
maxSize = fi.PtrTo(int64(2))
|
||||
maxSize = fi.PtrTo(int32(2))
|
||||
}
|
||||
|
||||
t.MinSize = minSize
|
||||
|
@ -521,38 +523,44 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo
|
|||
if cpu != nil {
|
||||
if cpu.Max != nil {
|
||||
cpuMax, _ := spec.InstanceRequirements.CPU.Max.AsInt64()
|
||||
ir.CPUMax = &cpuMax
|
||||
ir.CPUMax = fi.PtrTo(int32(cpuMax))
|
||||
}
|
||||
if cpu.Min != nil {
|
||||
cpuMin, _ := spec.InstanceRequirements.CPU.Min.AsInt64()
|
||||
ir.CPUMin = &cpuMin
|
||||
ir.CPUMin = fi.PtrTo(int32(cpuMin))
|
||||
}
|
||||
} else {
|
||||
ir.CPUMin = fi.PtrTo(int64(0))
|
||||
ir.CPUMin = fi.PtrTo(int32(0))
|
||||
}
|
||||
|
||||
memory := spec.InstanceRequirements.Memory
|
||||
if memory != nil {
|
||||
if memory.Max != nil {
|
||||
memoryMax := spec.InstanceRequirements.Memory.Max.ScaledValue(resource.Mega)
|
||||
ir.MemoryMax = &memoryMax
|
||||
ir.MemoryMax = fi.PtrTo(int32(memoryMax))
|
||||
}
|
||||
if memory.Min != nil {
|
||||
memoryMin := spec.InstanceRequirements.Memory.Min.ScaledValue(resource.Mega)
|
||||
ir.MemoryMin = &memoryMin
|
||||
ir.MemoryMin = fi.PtrTo(int32(memoryMin))
|
||||
}
|
||||
} else {
|
||||
ir.MemoryMin = fi.PtrTo(int64(0))
|
||||
ir.MemoryMin = fi.PtrTo(int32(0))
|
||||
}
|
||||
t.InstanceRequirements = ir
|
||||
}
|
||||
|
||||
t.MixedInstanceOverrides = spec.Instances
|
||||
t.MixedOnDemandAboveBase = spec.OnDemandAboveBase
|
||||
if spec.OnDemandAboveBase != nil {
|
||||
t.MixedOnDemandAboveBase = aws.Int32(int32(aws.ToInt64(spec.OnDemandAboveBase)))
|
||||
}
|
||||
t.MixedOnDemandAllocationStrategy = spec.OnDemandAllocationStrategy
|
||||
t.MixedOnDemandBase = spec.OnDemandBase
|
||||
if spec.OnDemandBase != nil {
|
||||
t.MixedOnDemandBase = aws.Int32(int32(aws.ToInt64(spec.OnDemandBase)))
|
||||
}
|
||||
t.MixedSpotAllocationStrategy = spec.SpotAllocationStrategy
|
||||
t.MixedSpotInstancePools = spec.SpotInstancePools
|
||||
if spec.SpotInstancePools != nil {
|
||||
t.MixedSpotInstancePools = aws.Int32(int32(aws.ToInt64(spec.SpotInstancePools)))
|
||||
}
|
||||
// In order to unset maxprice, the value needs to be ""
|
||||
if ig.Spec.MaxPrice == nil {
|
||||
t.MixedSpotMaxPrice = fi.PtrTo("")
|
||||
|
@ -562,10 +570,10 @@ func (b *AutoscalingGroupModelBuilder) buildAutoScalingGroupTask(c *fi.CloudupMo
|
|||
}
|
||||
|
||||
if ig.Spec.MaxInstanceLifetime != nil {
|
||||
lifetimeSec := int64(ig.Spec.MaxInstanceLifetime.Seconds())
|
||||
lifetimeSec := int32(ig.Spec.MaxInstanceLifetime.Seconds())
|
||||
t.MaxInstanceLifetime = fi.PtrTo(lifetimeSec)
|
||||
} else {
|
||||
t.MaxInstanceLifetime = fi.PtrTo(int64(0))
|
||||
t.MaxInstanceLifetime = fi.PtrTo(int32(0))
|
||||
}
|
||||
return t, nil
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ func (b *NodeTerminationHandlerBuilder) configureASG(c *fi.CloudupModelBuilderCo
|
|||
Lifecycle: b.Lifecycle,
|
||||
AutoscalingGroup: b.LinkToAutoscalingGroup(ig),
|
||||
DefaultResult: aws.String("CONTINUE"),
|
||||
HeartbeatTimeout: aws.Int64(DefaultMessageRetentionPeriod),
|
||||
HeartbeatTimeout: aws.Int32(DefaultMessageRetentionPeriod),
|
||||
LifecycleTransition: aws.String("autoscaling:EC2_INSTANCE_TERMINATING"),
|
||||
Enabled: aws.Bool(true),
|
||||
}
|
||||
|
|
|
@ -24,13 +24,14 @@ import (
|
|||
"sync"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
elb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
|
||||
elbtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
|
||||
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
|
||||
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
|
||||
"github.com/aws/aws-sdk-go-v2/service/iam"
|
||||
iamtypes "github.com/aws/aws-sdk-go-v2/service/iam/types"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
@ -1205,7 +1206,7 @@ func DeleteAutoScalingGroup(cloud fi.Cloud, r *resources.Resource) error {
|
|||
AutoScalingGroupName: &id,
|
||||
ForceDelete: aws.Bool(true),
|
||||
}
|
||||
_, err := c.Autoscaling().DeleteAutoScalingGroupWithContext(ctx, request)
|
||||
_, err := c.Autoscaling().DeleteAutoScalingGroup(ctx, request)
|
||||
if err != nil {
|
||||
if IsDependencyViolation(err) {
|
||||
return err
|
||||
|
@ -2137,7 +2138,7 @@ func FindName(tags []*ec2.Tag) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func FindASGName(tags []*autoscaling.TagDescription) string {
|
||||
func FindASGName(tags []autoscalingtypes.TagDescription) string {
|
||||
if name, found := awsup.FindASGTag(tags, "Name"); found {
|
||||
return name
|
||||
}
|
||||
|
|
|
@ -24,7 +24,8 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
|
@ -61,13 +62,13 @@ type AutoscalingGroup struct {
|
|||
// LoadBalancers is a list of elastic load balancer names to add to the autoscaling group
|
||||
LoadBalancers []*ClassicLoadBalancer
|
||||
// MaxInstanceLifetime is the maximum amount of time, in seconds, that an instance can be in service.
|
||||
MaxInstanceLifetime *int64
|
||||
MaxInstanceLifetime *int32
|
||||
// MaxSize is the max number of nodes in asg
|
||||
MaxSize *int64
|
||||
MaxSize *int32
|
||||
// Metrics is a collection of metrics to monitor
|
||||
Metrics []string
|
||||
// MinSize is the smallest number of nodes in the asg
|
||||
MinSize *int64
|
||||
MinSize *int32
|
||||
// MixedInstanceOverrides is a collection of instance types to use with fleet policy
|
||||
MixedInstanceOverrides []string
|
||||
// InstanceRequirements is a list of requirements for any instance type we are willing to run in the EC2 fleet.
|
||||
|
@ -76,17 +77,17 @@ type AutoscalingGroup struct {
|
|||
MixedOnDemandAllocationStrategy *string
|
||||
// MixedOnDemandBase is percentage split of On-Demand Instances and Spot Instances for your
|
||||
// additional capacity beyond the base portion
|
||||
MixedOnDemandBase *int64
|
||||
MixedOnDemandBase *int32
|
||||
// MixedOnDemandAboveBase is the percentage split of On-Demand Instances and Spot Instances
|
||||
// for your additional capacity beyond the base portion.
|
||||
MixedOnDemandAboveBase *int64
|
||||
MixedOnDemandAboveBase *int32
|
||||
// MixedSpotAllocationStrategy diversifies your Spot capacity across multiple instance types to
|
||||
// find the best pricing. Higher Spot availability may result from a larger number of
|
||||
// instance types to choose from.
|
||||
MixedSpotAllocationStrategy *string
|
||||
// MixedSpotInstancePools is the number of Spot pools to use to allocate your Spot capacity (defaults to 2)
|
||||
// pools are determined from the different instance types in the Overrides array of LaunchTemplate
|
||||
MixedSpotInstancePools *int64
|
||||
MixedSpotInstancePools *int32
|
||||
// MixedSpotMaxPrice is the maximum price per unit hour you are willing to pay for a Spot Instance
|
||||
MixedSpotMaxPrice *string
|
||||
// Subnets is a collection of subnets to attach the nodes to
|
||||
|
@ -162,7 +163,7 @@ func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error)
|
|||
|
||||
// Use 0 as default value when api returns nil (same as model)
|
||||
if g.MaxInstanceLifetime == nil {
|
||||
actual.MaxInstanceLifetime = fi.PtrTo(int64(0))
|
||||
actual.MaxInstanceLifetime = fi.PtrTo(int32(0))
|
||||
} else {
|
||||
actual.MaxInstanceLifetime = g.MaxInstanceLifetime
|
||||
}
|
||||
|
@ -170,8 +171,8 @@ func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error)
|
|||
actual.LoadBalancers = []*ClassicLoadBalancer{}
|
||||
for _, lb := range g.LoadBalancerNames {
|
||||
actual.LoadBalancers = append(actual.LoadBalancers, &ClassicLoadBalancer{
|
||||
Name: aws.String(*lb),
|
||||
LoadBalancerName: aws.String(*lb),
|
||||
Name: aws.String(lb),
|
||||
LoadBalancerName: aws.String(lb),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -223,13 +224,13 @@ func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error)
|
|||
}
|
||||
}
|
||||
for _, arn := range g.TargetGroupARNs {
|
||||
tg := byARN[aws.ToString(arn)]
|
||||
tg := byARN[arn]
|
||||
if tg != nil {
|
||||
actual.TargetGroups = append(actual.TargetGroups, tg)
|
||||
continue
|
||||
}
|
||||
actual.TargetGroups = append(actual.TargetGroups, &TargetGroup{ARN: arn})
|
||||
e.deletions = append(e.deletions, buildDeleteAutoscalingTargetGroupAttachment(aws.ToString(g.AutoScalingGroupName), aws.ToString(arn)))
|
||||
actual.TargetGroups = append(actual.TargetGroups, &TargetGroup{ARN: aws.String(arn)})
|
||||
e.deletions = append(e.deletions, buildDeleteAutoscalingTargetGroupAttachment(aws.ToString(g.AutoScalingGroupName), arn))
|
||||
}
|
||||
}
|
||||
sort.Stable(OrderTargetGroupsByName(actual.TargetGroups))
|
||||
|
@ -319,14 +320,19 @@ func (e *AutoscalingGroup) Find(c *fi.CloudupContext) (*AutoscalingGroup, error)
|
|||
}
|
||||
|
||||
// findAutoscalingGroup is responsible for finding all the autoscaling groups for us
|
||||
func findAutoscalingGroup(ctx context.Context, cloud awsup.AWSCloud, name string) (*autoscaling.Group, error) {
|
||||
func findAutoscalingGroup(ctx context.Context, cloud awsup.AWSCloud, name string) (*autoscalingtypes.AutoScalingGroup, error) {
|
||||
request := &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{&name},
|
||||
AutoScalingGroupNames: []string{name},
|
||||
}
|
||||
|
||||
var found []*autoscaling.Group
|
||||
err := cloud.Autoscaling().DescribeAutoScalingGroupsPagesWithContext(ctx, request, func(p *autoscaling.DescribeAutoScalingGroupsOutput, lastPage bool) (shouldContinue bool) {
|
||||
for _, g := range p.AutoScalingGroups {
|
||||
var found []*autoscalingtypes.AutoScalingGroup
|
||||
paginator := autoscaling.NewDescribeAutoScalingGroupsPaginator(cloud.Autoscaling(), request)
|
||||
for paginator.HasMorePages() {
|
||||
page, err := paginator.NextPage(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing AutoScalingGroups: %v", err)
|
||||
}
|
||||
for _, g := range page.AutoScalingGroups {
|
||||
// Check for "Delete in progress" (the only use .Status). We won't be able to update or create while
|
||||
// this is true, but filtering it out here makes the messages slightly clearer.
|
||||
if g.Status != nil {
|
||||
|
@ -335,16 +341,11 @@ func findAutoscalingGroup(ctx context.Context, cloud awsup.AWSCloud, name string
|
|||
}
|
||||
|
||||
if aws.ToString(g.AutoScalingGroupName) == name {
|
||||
found = append(found, g)
|
||||
found = append(found, &g)
|
||||
} else {
|
||||
klog.Warningf("Got ASG with unexpected name %q", fi.ValueOf(g.AutoScalingGroupName))
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing AutoscalingGroups: %v", err)
|
||||
}
|
||||
|
||||
switch len(found) {
|
||||
|
@ -414,28 +415,28 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
if lbDesc == nil {
|
||||
return fmt.Errorf("could not find load balancer to attach")
|
||||
}
|
||||
request.LoadBalancerNames = append(request.LoadBalancerNames, lbDesc.LoadBalancerName)
|
||||
request.LoadBalancerNames = append(request.LoadBalancerNames, aws.ToString(lbDesc.LoadBalancerName))
|
||||
} else {
|
||||
request.LoadBalancerNames = append(request.LoadBalancerNames, k.LoadBalancerName)
|
||||
request.LoadBalancerNames = append(request.LoadBalancerNames, aws.ToString(k.LoadBalancerName))
|
||||
}
|
||||
}
|
||||
|
||||
for _, tg := range e.TargetGroups {
|
||||
request.TargetGroupARNs = append(request.TargetGroupARNs, tg.ARN)
|
||||
request.TargetGroupARNs = append(request.TargetGroupARNs, aws.ToString(tg.ARN))
|
||||
}
|
||||
|
||||
// @check are we using mixed instances policy, or launch template
|
||||
if e.UseMixedInstancesPolicy() {
|
||||
request.MixedInstancesPolicy = &autoscaling.MixedInstancesPolicy{
|
||||
InstancesDistribution: &autoscaling.InstancesDistribution{
|
||||
request.MixedInstancesPolicy = &autoscalingtypes.MixedInstancesPolicy{
|
||||
InstancesDistribution: &autoscalingtypes.InstancesDistribution{
|
||||
OnDemandPercentageAboveBaseCapacity: e.MixedOnDemandAboveBase,
|
||||
OnDemandBaseCapacity: e.MixedOnDemandBase,
|
||||
SpotAllocationStrategy: e.MixedSpotAllocationStrategy,
|
||||
SpotInstancePools: e.MixedSpotInstancePools,
|
||||
SpotMaxPrice: e.MixedSpotMaxPrice,
|
||||
},
|
||||
LaunchTemplate: &autoscaling.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
||||
LaunchTemplate: &autoscalingtypes.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscalingtypes.LaunchTemplateSpecification{
|
||||
LaunchTemplateId: e.LaunchTemplate.ID,
|
||||
Version: aws.String("$Latest"),
|
||||
},
|
||||
|
@ -443,7 +444,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
}
|
||||
p := request.MixedInstancesPolicy.LaunchTemplate
|
||||
for _, x := range e.MixedInstanceOverrides {
|
||||
p.Overrides = append(p.Overrides, &autoscaling.LaunchTemplateOverrides{
|
||||
p.Overrides = append(p.Overrides, autoscalingtypes.LaunchTemplateOverrides{
|
||||
InstanceType: fi.PtrTo(x),
|
||||
},
|
||||
)
|
||||
|
@ -452,7 +453,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
p.Overrides = append(p.Overrides, overridesFromInstanceRequirements(e.InstanceRequirements))
|
||||
}
|
||||
} else if e.LaunchTemplate != nil {
|
||||
request.LaunchTemplate = &autoscaling.LaunchTemplateSpecification{
|
||||
request.LaunchTemplate = &autoscalingtypes.LaunchTemplateSpecification{
|
||||
LaunchTemplateId: e.LaunchTemplate.ID,
|
||||
Version: aws.String("$Latest"),
|
||||
}
|
||||
|
@ -461,7 +462,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
}
|
||||
|
||||
// @step: attempt to create the autoscaling group for us
|
||||
if _, err := t.Cloud.Autoscaling().CreateAutoScalingGroupWithContext(ctx, request); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().CreateAutoScalingGroup(ctx, request); err != nil {
|
||||
code := awsup.AWSErrorCode(err)
|
||||
message := awsup.AWSErrorMessage(err)
|
||||
if code == "ValidationError" && strings.Contains(message, "Invalid IAM Instance Profile name") {
|
||||
|
@ -472,25 +473,20 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
}
|
||||
|
||||
// @step: attempt to enable the metrics for us
|
||||
if _, err := t.Cloud.Autoscaling().EnableMetricsCollectionWithContext(ctx, &autoscaling.EnableMetricsCollectionInput{
|
||||
if _, err := t.Cloud.Autoscaling().EnableMetricsCollection(ctx, &autoscaling.EnableMetricsCollectionInput{
|
||||
AutoScalingGroupName: e.Name,
|
||||
Granularity: e.Granularity,
|
||||
Metrics: aws.StringSlice(e.Metrics),
|
||||
Metrics: e.Metrics,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("error enabling metrics collection for AutoscalingGroup: %v", err)
|
||||
}
|
||||
|
||||
if len(*e.SuspendProcesses) > 0 {
|
||||
toSuspend := []*string{}
|
||||
for _, p := range *e.SuspendProcesses {
|
||||
toSuspend = append(toSuspend, &p)
|
||||
}
|
||||
|
||||
processQuery := &autoscaling.ScalingProcessQuery{}
|
||||
processQuery := &autoscaling.SuspendProcessesInput{}
|
||||
processQuery.AutoScalingGroupName = e.Name
|
||||
processQuery.ScalingProcesses = toSuspend
|
||||
processQuery.ScalingProcesses = *e.SuspendProcesses
|
||||
|
||||
if _, err := t.Cloud.Autoscaling().SuspendProcessesWithContext(ctx, processQuery); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().SuspendProcesses(ctx, processQuery); err != nil {
|
||||
return fmt.Errorf("error suspending processes: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -501,10 +497,10 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
AutoScalingGroupName: e.Name,
|
||||
}
|
||||
|
||||
setup := func(req *autoscaling.UpdateAutoScalingGroupInput) *autoscaling.MixedInstancesPolicy {
|
||||
setup := func(req *autoscaling.UpdateAutoScalingGroupInput) *autoscalingtypes.MixedInstancesPolicy {
|
||||
if req.MixedInstancesPolicy == nil {
|
||||
req.MixedInstancesPolicy = &autoscaling.MixedInstancesPolicy{
|
||||
InstancesDistribution: &autoscaling.InstancesDistribution{},
|
||||
req.MixedInstancesPolicy = &autoscalingtypes.MixedInstancesPolicy{
|
||||
InstancesDistribution: &autoscalingtypes.InstancesDistribution{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -513,12 +509,12 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
|
||||
// We have to update LaunchTemplate to remove mixedInstancesPolicy when it is removed from spec.
|
||||
if changes.LaunchTemplate != nil || a.UseMixedInstancesPolicy() && !e.UseMixedInstancesPolicy() {
|
||||
spec := &autoscaling.LaunchTemplateSpecification{
|
||||
spec := &autoscalingtypes.LaunchTemplateSpecification{
|
||||
LaunchTemplateId: e.LaunchTemplate.ID,
|
||||
Version: aws.String("$Latest"),
|
||||
}
|
||||
if e.UseMixedInstancesPolicy() {
|
||||
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{LaunchTemplateSpecification: spec}
|
||||
setup(request).LaunchTemplate = &autoscalingtypes.LaunchTemplate{LaunchTemplateSpecification: spec}
|
||||
} else {
|
||||
request.LaunchTemplate = spec
|
||||
}
|
||||
|
@ -547,8 +543,8 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
}
|
||||
if changes.MixedInstanceOverrides != nil || changes.InstanceRequirements != nil {
|
||||
if setup(request).LaunchTemplate == nil {
|
||||
setup(request).LaunchTemplate = &autoscaling.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscaling.LaunchTemplateSpecification{
|
||||
setup(request).LaunchTemplate = &autoscalingtypes.LaunchTemplate{
|
||||
LaunchTemplateSpecification: &autoscalingtypes.LaunchTemplateSpecification{
|
||||
LaunchTemplateId: e.LaunchTemplate.ID,
|
||||
Version: aws.String("$Latest"),
|
||||
},
|
||||
|
@ -558,7 +554,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
if changes.MixedInstanceOverrides != nil {
|
||||
p := request.MixedInstancesPolicy.LaunchTemplate
|
||||
for _, x := range changes.MixedInstanceOverrides {
|
||||
p.Overrides = append(p.Overrides, &autoscaling.LaunchTemplateOverrides{InstanceType: fi.PtrTo(x)})
|
||||
p.Overrides = append(p.Overrides, autoscalingtypes.LaunchTemplateOverrides{InstanceType: fi.PtrTo(x)})
|
||||
}
|
||||
changes.MixedInstanceOverrides = nil
|
||||
}
|
||||
|
@ -588,7 +584,7 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
request.MaxInstanceLifetime = e.MaxInstanceLifetime
|
||||
changes.MaxInstanceLifetime = nil
|
||||
} else {
|
||||
request.MaxInstanceLifetime = fi.PtrTo(int64(0))
|
||||
request.MaxInstanceLifetime = fi.PtrTo(int32(0))
|
||||
}
|
||||
|
||||
var updateTagsRequest *autoscaling.CreateOrUpdateTagsInput
|
||||
|
@ -641,10 +637,10 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
if changes.Metrics != nil || changes.Granularity != nil {
|
||||
// TODO: Support disabling metrics?
|
||||
if len(e.Metrics) != 0 {
|
||||
_, err := t.Cloud.Autoscaling().EnableMetricsCollectionWithContext(ctx, &autoscaling.EnableMetricsCollectionInput{
|
||||
_, err := t.Cloud.Autoscaling().EnableMetricsCollection(ctx, &autoscaling.EnableMetricsCollectionInput{
|
||||
AutoScalingGroupName: e.Name,
|
||||
Granularity: e.Granularity,
|
||||
Metrics: aws.StringSlice(e.Metrics),
|
||||
Metrics: e.Metrics,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error enabling metrics collection for AutoscalingGroup: %v", err)
|
||||
|
@ -659,21 +655,21 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
toResume := processCompare(a.SuspendProcesses, e.SuspendProcesses)
|
||||
|
||||
if len(toSuspend) > 0 {
|
||||
suspendProcessQuery := &autoscaling.ScalingProcessQuery{}
|
||||
suspendProcessQuery := &autoscaling.SuspendProcessesInput{}
|
||||
suspendProcessQuery.AutoScalingGroupName = e.Name
|
||||
suspendProcessQuery.ScalingProcesses = toSuspend
|
||||
suspendProcessQuery.ScalingProcesses = aws.ToStringSlice(toSuspend)
|
||||
|
||||
_, err := t.Cloud.Autoscaling().SuspendProcessesWithContext(ctx, suspendProcessQuery)
|
||||
_, err := t.Cloud.Autoscaling().SuspendProcesses(ctx, suspendProcessQuery)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error suspending processes: %v", err)
|
||||
}
|
||||
}
|
||||
if len(toResume) > 0 {
|
||||
resumeProcessQuery := &autoscaling.ScalingProcessQuery{}
|
||||
resumeProcessQuery := &autoscaling.ResumeProcessesInput{}
|
||||
resumeProcessQuery.AutoScalingGroupName = e.Name
|
||||
resumeProcessQuery.ScalingProcesses = toResume
|
||||
resumeProcessQuery.ScalingProcesses = aws.ToStringSlice(toResume)
|
||||
|
||||
_, err := t.Cloud.Autoscaling().ResumeProcessesWithContext(ctx, resumeProcessQuery)
|
||||
_, err := t.Cloud.Autoscaling().ResumeProcesses(ctx, resumeProcessQuery)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error resuming processes: %v", err)
|
||||
}
|
||||
|
@ -698,34 +694,34 @@ func (v *AutoscalingGroup) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Autos
|
|||
|
||||
klog.V(2).Infof("Updating autoscaling group %s", fi.ValueOf(e.Name))
|
||||
|
||||
if _, err := t.Cloud.Autoscaling().UpdateAutoScalingGroupWithContext(ctx, request); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().UpdateAutoScalingGroup(ctx, request); err != nil {
|
||||
return fmt.Errorf("error updating AutoscalingGroup: %v", err)
|
||||
}
|
||||
|
||||
if deleteTagsRequest != nil && len(deleteTagsRequest.Tags) > 0 {
|
||||
if _, err := t.Cloud.Autoscaling().DeleteTagsWithContext(ctx, deleteTagsRequest); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().DeleteTags(ctx, deleteTagsRequest); err != nil {
|
||||
return fmt.Errorf("error deleting old AutoscalingGroup tags: %v", err)
|
||||
}
|
||||
}
|
||||
if updateTagsRequest != nil {
|
||||
if _, err := t.Cloud.Autoscaling().CreateOrUpdateTagsWithContext(ctx, updateTagsRequest); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().CreateOrUpdateTags(ctx, updateTagsRequest); err != nil {
|
||||
return fmt.Errorf("error updating AutoscalingGroup tags: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
if detachLBRequest != nil {
|
||||
if _, err := t.Cloud.Autoscaling().DetachLoadBalancersWithContext(ctx, detachLBRequest); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().DetachLoadBalancers(ctx, detachLBRequest); err != nil {
|
||||
return fmt.Errorf("error detatching LoadBalancers: %v", err)
|
||||
}
|
||||
}
|
||||
if attachLBRequest != nil {
|
||||
if _, err := t.Cloud.Autoscaling().AttachLoadBalancersWithContext(ctx, attachLBRequest); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().AttachLoadBalancers(ctx, attachLBRequest); err != nil {
|
||||
return fmt.Errorf("error attaching LoadBalancers: %v", err)
|
||||
}
|
||||
}
|
||||
if len(attachTGRequests) > 0 {
|
||||
for _, attachTGRequest := range attachTGRequests {
|
||||
if _, err := t.Cloud.Autoscaling().AttachLoadBalancerTargetGroupsWithContext(ctx, attachTGRequest); err != nil {
|
||||
if _, err := t.Cloud.Autoscaling().AttachLoadBalancerTargetGroups(ctx, attachTGRequest); err != nil {
|
||||
return fmt.Errorf("failed to attach target groups: %v", err)
|
||||
}
|
||||
}
|
||||
|
@ -767,11 +763,11 @@ func (e *AutoscalingGroup) UseMixedInstancesPolicy() bool {
|
|||
}
|
||||
|
||||
// AutoscalingGroupTags is responsible for generating the tagging for the asg
|
||||
func (e *AutoscalingGroup) AutoscalingGroupTags() []*autoscaling.Tag {
|
||||
var list []*autoscaling.Tag
|
||||
func (e *AutoscalingGroup) AutoscalingGroupTags() []autoscalingtypes.Tag {
|
||||
var list []autoscalingtypes.Tag
|
||||
|
||||
for k, v := range e.Tags {
|
||||
list = append(list, &autoscaling.Tag{
|
||||
list = append(list, autoscalingtypes.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v),
|
||||
ResourceId: e.Name,
|
||||
|
@ -795,22 +791,22 @@ func (e *AutoscalingGroup) AutoscalingGroupSubnets() []string {
|
|||
}
|
||||
|
||||
// AutoscalingLoadBalancers returns a list of LBs attatched to the ASG
|
||||
func (e *AutoscalingGroup) AutoscalingLoadBalancers() []*string {
|
||||
var list []*string
|
||||
func (e *AutoscalingGroup) AutoscalingLoadBalancers() []string {
|
||||
var list []string
|
||||
|
||||
for _, v := range e.LoadBalancers {
|
||||
list = append(list, v.LoadBalancerName)
|
||||
list = append(list, aws.ToString(v.LoadBalancerName))
|
||||
}
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
// AutoscalingTargetGroups returns a list of TGs attatched to the ASG
|
||||
func (e *AutoscalingGroup) AutoscalingTargetGroups() []*string {
|
||||
var list []*string
|
||||
func (e *AutoscalingGroup) AutoscalingTargetGroups() []string {
|
||||
var list []string
|
||||
|
||||
for _, v := range e.TargetGroups {
|
||||
list = append(list, v.ARN)
|
||||
list = append(list, aws.ToString(v.ARN))
|
||||
}
|
||||
|
||||
return list
|
||||
|
@ -837,12 +833,12 @@ func processCompare(a *[]string, b *[]string) []*string {
|
|||
|
||||
// getASGTagsToDelete loops through the currently set tags and builds a list of
|
||||
// tags to be deleted from the Autoscaling Group
|
||||
func (e *AutoscalingGroup) getASGTagsToDelete(currentTags map[string]string) []*autoscaling.Tag {
|
||||
tagsToDelete := []*autoscaling.Tag{}
|
||||
func (e *AutoscalingGroup) getASGTagsToDelete(currentTags map[string]string) []autoscalingtypes.Tag {
|
||||
tagsToDelete := []autoscalingtypes.Tag{}
|
||||
|
||||
for k, v := range currentTags {
|
||||
if _, ok := e.Tags[k]; !ok {
|
||||
tagsToDelete = append(tagsToDelete, &autoscaling.Tag{
|
||||
tagsToDelete = append(tagsToDelete, autoscalingtypes.Tag{
|
||||
Key: aws.String(k),
|
||||
Value: aws.String(v),
|
||||
ResourceId: e.Name,
|
||||
|
@ -855,8 +851,8 @@ func (e *AutoscalingGroup) getASGTagsToDelete(currentTags map[string]string) []*
|
|||
|
||||
// getLBsToDetach loops through the currently set LBs and builds a list of
|
||||
// LBs to be detached from the Autoscaling Group
|
||||
func (e *AutoscalingGroup) getLBsToDetach(currentLBs []*ClassicLoadBalancer) []*string {
|
||||
lbsToDetach := []*string{}
|
||||
func (e *AutoscalingGroup) getLBsToDetach(currentLBs []*ClassicLoadBalancer) []string {
|
||||
lbsToDetach := []string{}
|
||||
desiredLBs := map[string]bool{}
|
||||
|
||||
for _, v := range e.LoadBalancers {
|
||||
|
@ -865,7 +861,7 @@ func (e *AutoscalingGroup) getLBsToDetach(currentLBs []*ClassicLoadBalancer) []*
|
|||
|
||||
for _, v := range currentLBs {
|
||||
if _, ok := desiredLBs[*v.Name]; !ok {
|
||||
lbsToDetach = append(lbsToDetach, v.Name)
|
||||
lbsToDetach = append(lbsToDetach, aws.ToString(v.Name))
|
||||
}
|
||||
}
|
||||
return lbsToDetach
|
||||
|
@ -890,10 +886,10 @@ func (e *AutoscalingGroup) getTGsToDetach(currentTGs []*TargetGroup) []*string {
|
|||
}
|
||||
|
||||
// sliceChunks returns a chunked slice
|
||||
func sliceChunks(slice []*string, chunkSize int) [][]*string {
|
||||
var chunks [][]*string
|
||||
func sliceChunks(slice []string, chunkSize int) [][]string {
|
||||
var chunks [][]string
|
||||
for i := 0; i < len(slice); i = i + chunkSize {
|
||||
var chunk []*string
|
||||
var chunk []string
|
||||
if i+chunkSize < len(slice) {
|
||||
chunk = slice[i : i+chunkSize]
|
||||
} else {
|
||||
|
@ -940,13 +936,13 @@ type terraformAutoscalingInstanceDistribution struct {
|
|||
// OnDemandAllocationStrategy
|
||||
OnDemandAllocationStrategy *string `cty:"on_demand_allocation_strategy"`
|
||||
// OnDemandBaseCapacity is the base ondemand requirement
|
||||
OnDemandBaseCapacity *int64 `cty:"on_demand_base_capacity"`
|
||||
OnDemandBaseCapacity *int32 `cty:"on_demand_base_capacity"`
|
||||
// OnDemandPercentageAboveBaseCapacity is the percentage above base for on-demand instances
|
||||
OnDemandPercentageAboveBaseCapacity *int64 `cty:"on_demand_percentage_above_base_capacity"`
|
||||
OnDemandPercentageAboveBaseCapacity *int32 `cty:"on_demand_percentage_above_base_capacity"`
|
||||
// SpotAllocationStrategy is the spot allocation stratergy
|
||||
SpotAllocationStrategy *string `cty:"spot_allocation_strategy"`
|
||||
// SpotInstancePool is the number of pools
|
||||
SpotInstancePool *int64 `cty:"spot_instance_pools"`
|
||||
SpotInstancePool *int32 `cty:"spot_instance_pools"`
|
||||
// SpotMaxPrice is the max bid on spot instance, defaults to demand value
|
||||
SpotMaxPrice *string `cty:"spot_max_price"`
|
||||
}
|
||||
|
@ -959,16 +955,16 @@ type terraformMixedInstancesPolicy struct {
|
|||
}
|
||||
|
||||
type terraformWarmPool struct {
|
||||
MinSize *int64 `cty:"min_size"`
|
||||
MaxSize *int64 `cty:"max_group_prepared_capacity"`
|
||||
MinSize *int32 `cty:"min_size"`
|
||||
MaxSize *int32 `cty:"max_group_prepared_capacity"`
|
||||
}
|
||||
|
||||
type terraformAutoscalingGroup struct {
|
||||
Name *string `cty:"name"`
|
||||
LaunchConfigurationName *terraformWriter.Literal `cty:"launch_configuration"`
|
||||
LaunchTemplate *terraformAutoscalingLaunchTemplateSpecification `cty:"launch_template"`
|
||||
MaxSize *int64 `cty:"max_size"`
|
||||
MinSize *int64 `cty:"min_size"`
|
||||
MaxSize *int32 `cty:"max_size"`
|
||||
MinSize *int32 `cty:"min_size"`
|
||||
MixedInstancesPolicy []*terraformMixedInstancesPolicy `cty:"mixed_instances_policy"`
|
||||
VPCZoneIdentifier []*terraformWriter.Literal `cty:"vpc_zone_identifier"`
|
||||
Tags []*terraformASGTag `cty:"tag"`
|
||||
|
@ -978,7 +974,7 @@ type terraformAutoscalingGroup struct {
|
|||
InstanceProtection *bool `cty:"protect_from_scale_in"`
|
||||
LoadBalancers []*terraformWriter.Literal `cty:"load_balancers"`
|
||||
TargetGroupARNs []*terraformWriter.Literal `cty:"target_group_arns"`
|
||||
MaxInstanceLifetime *int64 `cty:"max_instance_lifetime"`
|
||||
MaxInstanceLifetime *int32 `cty:"max_instance_lifetime"`
|
||||
CapacityRebalance *bool `cty:"capacity_rebalance"`
|
||||
WarmPool *terraformWarmPool `cty:"warm_pool"`
|
||||
}
|
||||
|
@ -1147,9 +1143,9 @@ func (d *deleteAutoscalingTargetGroupAttachment) Delete(t fi.CloudupTarget) erro
|
|||
|
||||
req := &autoscaling.DetachLoadBalancerTargetGroupsInput{
|
||||
AutoScalingGroupName: aws.String(d.autoScalingGroupName),
|
||||
TargetGroupARNs: aws.StringSlice([]string{d.targetGroupARN}),
|
||||
TargetGroupARNs: []string{d.targetGroupARN},
|
||||
}
|
||||
if _, err := awsTarget.Cloud.Autoscaling().DetachLoadBalancerTargetGroupsWithContext(ctx, req); err != nil {
|
||||
if _, err := awsTarget.Cloud.Autoscaling().DetachLoadBalancerTargetGroups(ctx, req); err != nil {
|
||||
return fmt.Errorf("failed to detach target groups from autoscaling group: %v", err)
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import (
|
|||
"k8s.io/kops/upup/pkg/fi"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
|
@ -40,27 +40,27 @@ func TestGetASGTagsToDelete(t *testing.T) {
|
|||
|
||||
cases := []struct {
|
||||
CurrentTags map[string]string
|
||||
ExpectedTagsToDelete []*autoscaling.Tag
|
||||
ExpectedTagsToDelete []autoscalingtypes.Tag
|
||||
}{
|
||||
{
|
||||
CurrentTags: map[string]string{
|
||||
"KubernetesCluster": "MyCluster",
|
||||
"Name": "nodes.cluster.k8s.local",
|
||||
},
|
||||
ExpectedTagsToDelete: []*autoscaling.Tag{},
|
||||
ExpectedTagsToDelete: []autoscalingtypes.Tag{},
|
||||
},
|
||||
{
|
||||
CurrentTags: map[string]string{
|
||||
"KubernetesCluster": "MyCluster",
|
||||
"Name": "nodes.cluster.k8s.locall",
|
||||
},
|
||||
ExpectedTagsToDelete: []*autoscaling.Tag{},
|
||||
ExpectedTagsToDelete: []autoscalingtypes.Tag{},
|
||||
},
|
||||
{
|
||||
CurrentTags: map[string]string{
|
||||
"KubernetesCluster": "MyCluster",
|
||||
},
|
||||
ExpectedTagsToDelete: []*autoscaling.Tag{},
|
||||
ExpectedTagsToDelete: []autoscalingtypes.Tag{},
|
||||
},
|
||||
{
|
||||
CurrentTags: map[string]string{
|
||||
|
@ -68,7 +68,7 @@ func TestGetASGTagsToDelete(t *testing.T) {
|
|||
"Name": "nodes.cluster.k8s.local",
|
||||
"OldTag": "OldValue",
|
||||
},
|
||||
ExpectedTagsToDelete: []*autoscaling.Tag{
|
||||
ExpectedTagsToDelete: []autoscalingtypes.Tag{
|
||||
{
|
||||
Key: aws.String("OldTag"),
|
||||
Value: aws.String("OldValue"),
|
||||
|
@ -84,7 +84,7 @@ func TestGetASGTagsToDelete(t *testing.T) {
|
|||
"MyCustomTag": "MyCustomValue",
|
||||
"k8s.io/cluster-autoscaler/node-template/taint/sometaint": "somevalue:NoSchedule",
|
||||
},
|
||||
ExpectedTagsToDelete: []*autoscaling.Tag{
|
||||
ExpectedTagsToDelete: []autoscalingtypes.Tag{
|
||||
{
|
||||
Key: aws.String("MyCustomTag"),
|
||||
Value: aws.String("MyCustomValue"),
|
||||
|
@ -205,9 +205,9 @@ func TestAutoscalingGroupTerraformRender(t *testing.T) {
|
|||
Name: fi.PtrTo("test"),
|
||||
Granularity: fi.PtrTo("5min"),
|
||||
LaunchTemplate: &LaunchTemplate{Name: fi.PtrTo("test_lc")},
|
||||
MaxSize: fi.PtrTo(int64(10)),
|
||||
MaxSize: fi.PtrTo(int32(10)),
|
||||
Metrics: []string{"test"},
|
||||
MinSize: fi.PtrTo(int64(1)),
|
||||
MinSize: fi.PtrTo(int32(1)),
|
||||
Subnets: []*Subnet{
|
||||
{
|
||||
Name: fi.PtrTo("test-sg"),
|
||||
|
@ -261,12 +261,12 @@ terraform {
|
|||
Resource: &AutoscalingGroup{
|
||||
Name: fi.PtrTo("test1"),
|
||||
LaunchTemplate: &LaunchTemplate{Name: fi.PtrTo("test_lt")},
|
||||
MaxSize: fi.PtrTo(int64(10)),
|
||||
MaxSize: fi.PtrTo(int32(10)),
|
||||
Metrics: []string{"test"},
|
||||
MinSize: fi.PtrTo(int64(5)),
|
||||
MinSize: fi.PtrTo(int32(5)),
|
||||
MixedInstanceOverrides: []string{"t2.medium", "t2.large"},
|
||||
MixedOnDemandBase: fi.PtrTo(int64(4)),
|
||||
MixedOnDemandAboveBase: fi.PtrTo(int64(30)),
|
||||
MixedOnDemandBase: fi.PtrTo(int32(4)),
|
||||
MixedOnDemandAboveBase: fi.PtrTo(int32(30)),
|
||||
MixedSpotAllocationStrategy: fi.PtrTo("capacity-optimized"),
|
||||
Subnets: []*Subnet{
|
||||
{
|
||||
|
@ -335,17 +335,17 @@ terraform {
|
|||
Resource: &AutoscalingGroup{
|
||||
Name: fi.PtrTo("test1"),
|
||||
LaunchTemplate: &LaunchTemplate{Name: fi.PtrTo("test_lt")},
|
||||
MaxSize: fi.PtrTo(int64(10)),
|
||||
MaxSize: fi.PtrTo(int32(10)),
|
||||
Metrics: []string{"test"},
|
||||
MinSize: fi.PtrTo(int64(5)),
|
||||
MinSize: fi.PtrTo(int32(5)),
|
||||
MixedInstanceOverrides: []string{"t2.medium", "t2.large"},
|
||||
MixedOnDemandBase: fi.PtrTo(int64(4)),
|
||||
MixedOnDemandAboveBase: fi.PtrTo(int64(30)),
|
||||
MixedOnDemandBase: fi.PtrTo(int32(4)),
|
||||
MixedOnDemandAboveBase: fi.PtrTo(int32(30)),
|
||||
MixedSpotAllocationStrategy: fi.PtrTo("capacity-optimized"),
|
||||
WarmPool: &WarmPool{
|
||||
Enabled: fi.PtrTo(true),
|
||||
MinSize: 3,
|
||||
MaxSize: fi.PtrTo(int64(5)),
|
||||
MaxSize: fi.PtrTo(int32(5)),
|
||||
},
|
||||
Subnets: []*Subnet{
|
||||
{
|
||||
|
@ -420,60 +420,60 @@ terraform {
|
|||
}
|
||||
|
||||
func TestTGsARNsChunks(t *testing.T) {
|
||||
var tgsARNs []*string
|
||||
var tgsARNs []string
|
||||
for i := 0; i < 30; i++ {
|
||||
tgsARNs = append(tgsARNs, fi.PtrTo(fmt.Sprintf("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/00000000000000%02d", i)))
|
||||
tgsARNs = append(tgsARNs, fmt.Sprintf("arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/00000000000000%02d", i))
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
tgsARNs []*string
|
||||
tgsARNs []string
|
||||
chunkSize int
|
||||
expected [][]*string
|
||||
expected [][]string
|
||||
}{
|
||||
{
|
||||
tgsARNs: tgsARNs[0:1],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:1]},
|
||||
expected: [][]string{tgsARNs[0:1]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:5],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:5]},
|
||||
expected: [][]string{tgsARNs[0:5]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:10],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10]},
|
||||
expected: [][]string{tgsARNs[0:10]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:11],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10], tgsARNs[10:11]},
|
||||
expected: [][]string{tgsARNs[0:10], tgsARNs[10:11]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:15],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10], tgsARNs[10:15]},
|
||||
expected: [][]string{tgsARNs[0:10], tgsARNs[10:15]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:20],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10], tgsARNs[10:20]},
|
||||
expected: [][]string{tgsARNs[0:10], tgsARNs[10:20]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:21],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10], tgsARNs[10:20], tgsARNs[20:21]},
|
||||
expected: [][]string{tgsARNs[0:10], tgsARNs[10:20], tgsARNs[20:21]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:25],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10], tgsARNs[10:20], tgsARNs[20:25]},
|
||||
expected: [][]string{tgsARNs[0:10], tgsARNs[10:20], tgsARNs[20:25]},
|
||||
},
|
||||
{
|
||||
tgsARNs: tgsARNs[0:30],
|
||||
chunkSize: 10,
|
||||
expected: [][]*string{tgsARNs[0:10], tgsARNs[10:20], tgsARNs[20:30]},
|
||||
expected: [][]string{tgsARNs[0:10], tgsARNs[10:20], tgsARNs[20:30]},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||
|
@ -41,7 +42,7 @@ type AutoscalingLifecycleHook struct {
|
|||
|
||||
AutoscalingGroup *AutoscalingGroup
|
||||
DefaultResult *string
|
||||
HeartbeatTimeout *int64
|
||||
HeartbeatTimeout *int32
|
||||
LifecycleTransition *string
|
||||
|
||||
Enabled *bool
|
||||
|
@ -59,10 +60,10 @@ func (h *AutoscalingLifecycleHook) Find(c *fi.CloudupContext) (*AutoscalingLifec
|
|||
|
||||
request := &autoscaling.DescribeLifecycleHooksInput{
|
||||
AutoScalingGroupName: h.AutoscalingGroup.Name,
|
||||
LifecycleHookNames: []*string{h.GetHookName()},
|
||||
LifecycleHookNames: []string{aws.ToString(h.GetHookName())},
|
||||
}
|
||||
|
||||
response, err := cloud.Autoscaling().DescribeLifecycleHooksWithContext(ctx, request)
|
||||
response, err := cloud.Autoscaling().DescribeLifecycleHooks(ctx, request)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing ASG Lifecycle Hooks: %v", err)
|
||||
}
|
||||
|
@ -122,7 +123,7 @@ func (*AutoscalingLifecycleHook) RenderAWS(t *awsup.AWSAPITarget, a, e, changes
|
|||
LifecycleHookName: e.GetHookName(),
|
||||
LifecycleTransition: e.LifecycleTransition,
|
||||
}
|
||||
_, err := t.Cloud.Autoscaling().PutLifecycleHookWithContext(ctx, request)
|
||||
_, err := t.Cloud.Autoscaling().PutLifecycleHook(ctx, request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -131,7 +132,7 @@ func (*AutoscalingLifecycleHook) RenderAWS(t *awsup.AWSAPITarget, a, e, changes
|
|||
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||
LifecycleHookName: e.GetHookName(),
|
||||
}
|
||||
_, err := t.Cloud.Autoscaling().DeleteLifecycleHookWithContext(ctx, request)
|
||||
_, err := t.Cloud.Autoscaling().DeleteLifecycleHook(ctx, request)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -145,7 +146,7 @@ type terraformASGLifecycleHook struct {
|
|||
Name *string `cty:"name"`
|
||||
AutoScalingGroupName *terraformWriter.Literal `cty:"autoscaling_group_name"`
|
||||
DefaultResult *string `cty:"default_result"`
|
||||
HeartbeatTimeout *int64 `cty:"heartbeat_timeout"`
|
||||
HeartbeatTimeout *int32 `cty:"heartbeat_timeout"`
|
||||
LifecycleTransition *string `cty:"lifecycle_transition"`
|
||||
}
|
||||
|
||||
|
|
|
@ -17,17 +17,17 @@ limitations under the License.
|
|||
package awstasks
|
||||
|
||||
import (
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
)
|
||||
|
||||
type InstanceRequirements struct {
|
||||
Architecture *string
|
||||
CPUMin *int64
|
||||
CPUMax *int64
|
||||
MemoryMin *int64
|
||||
MemoryMax *int64
|
||||
CPUMin *int32
|
||||
CPUMax *int32
|
||||
MemoryMin *int32
|
||||
MemoryMax *int32
|
||||
}
|
||||
|
||||
var _ fi.CloudupHasDependencies = &InstanceRequirements{}
|
||||
|
@ -36,7 +36,7 @@ func (e *InstanceRequirements) GetDependencies(tasks map[string]fi.CloudupTask)
|
|||
return nil
|
||||
}
|
||||
|
||||
func findInstanceRequirements(asg *autoscaling.Group) (*InstanceRequirements, error) {
|
||||
func findInstanceRequirements(asg *autoscalingtypes.AutoScalingGroup) (*InstanceRequirements, error) {
|
||||
actual := &InstanceRequirements{}
|
||||
if asg.MixedInstancesPolicy != nil {
|
||||
for _, override := range asg.MixedInstancesPolicy.LaunchTemplate.Overrides {
|
||||
|
@ -56,18 +56,18 @@ func findInstanceRequirements(asg *autoscaling.Group) (*InstanceRequirements, er
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func overridesFromInstanceRequirements(ir *InstanceRequirements) *autoscaling.LaunchTemplateOverrides {
|
||||
return &autoscaling.LaunchTemplateOverrides{
|
||||
InstanceRequirements: &autoscaling.InstanceRequirements{
|
||||
VCpuCount: &autoscaling.VCpuCountRequest{
|
||||
func overridesFromInstanceRequirements(ir *InstanceRequirements) autoscalingtypes.LaunchTemplateOverrides {
|
||||
return autoscalingtypes.LaunchTemplateOverrides{
|
||||
InstanceRequirements: &autoscalingtypes.InstanceRequirements{
|
||||
VCpuCount: &autoscalingtypes.VCpuCountRequest{
|
||||
Max: ir.CPUMax,
|
||||
Min: ir.CPUMin,
|
||||
},
|
||||
MemoryMiB: &autoscaling.MemoryMiBRequest{
|
||||
MemoryMiB: &autoscalingtypes.MemoryMiBRequest{
|
||||
Max: ir.MemoryMax,
|
||||
Min: ir.MemoryMin,
|
||||
},
|
||||
BurstablePerformance: fi.PtrTo("included"),
|
||||
BurstablePerformance: autoscalingtypes.BurstablePerformanceIncluded,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||
"k8s.io/kops/upup/pkg/fi/cloudup/terraform"
|
||||
|
@ -37,9 +37,9 @@ type WarmPool struct {
|
|||
|
||||
Enabled *bool
|
||||
// MaxSize is the max number of nodes in the warm pool.
|
||||
MaxSize *int64
|
||||
MaxSize *int32
|
||||
// MinSize is the smallest number of nodes in the warm pool.
|
||||
MinSize int64
|
||||
MinSize int32
|
||||
|
||||
AutoscalingGroup *AutoscalingGroup
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ func (e *WarmPool) Find(c *fi.CloudupContext) (*WarmPool, error) {
|
|||
ctx := c.Context()
|
||||
cloud := c.T.Cloud.(awsup.AWSCloud)
|
||||
svc := cloud.Autoscaling()
|
||||
warmPool, err := svc.DescribeWarmPoolWithContext(ctx, &autoscaling.DescribeWarmPoolInput{
|
||||
warmPool, err := svc.DescribeWarmPool(ctx, &autoscaling.DescribeWarmPoolInput{
|
||||
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -94,7 +94,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
|
|||
minSize := e.MinSize
|
||||
maxSize := e.MaxSize
|
||||
if maxSize == nil {
|
||||
maxSize = fi.PtrTo(int64(-1))
|
||||
maxSize = fi.PtrTo(int32(-1))
|
||||
}
|
||||
request := &autoscaling.PutWarmPoolInput{
|
||||
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||
|
@ -102,7 +102,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
|
|||
MinSize: fi.PtrTo(minSize),
|
||||
}
|
||||
|
||||
_, err := svc.PutWarmPoolWithContext(ctx, request)
|
||||
_, err := svc.PutWarmPool(ctx, request)
|
||||
if err != nil {
|
||||
if awsup.AWSErrorCode(err) == "ValidationError" {
|
||||
return fi.NewTryAgainLaterError("waiting for ASG to become ready").WithError(err)
|
||||
|
@ -110,7 +110,7 @@ func (*WarmPool) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *WarmPool) error
|
|||
return fmt.Errorf("error modifying warm pool: %w", err)
|
||||
}
|
||||
} else if a != nil {
|
||||
_, err := svc.DeleteWarmPoolWithContext(ctx, &autoscaling.DeleteWarmPoolInput{
|
||||
_, err := svc.DeleteWarmPool(ctx, &autoscaling.DeleteWarmPoolInput{
|
||||
AutoScalingGroupName: e.AutoscalingGroup.Name,
|
||||
// We don't need to do any cleanup so, the faster the better
|
||||
ForceDelete: fi.PtrTo(true),
|
||||
|
|
|
@ -35,6 +35,8 @@ import (
|
|||
"github.com/aws/aws-sdk-go-v2/aws/arn"
|
||||
"github.com/aws/aws-sdk-go-v2/aws/retry"
|
||||
stscredsv2 "github.com/aws/aws-sdk-go-v2/credentials/stscreds"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
elb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing"
|
||||
elbtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
|
||||
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
|
||||
|
@ -46,8 +48,6 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
|
||||
"github.com/aws/aws-sdk-go/aws/request"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||
"github.com/aws/aws-sdk-go/service/route53"
|
||||
|
@ -131,7 +131,7 @@ type AWSCloud interface {
|
|||
IAM() awsinterfaces.IAMAPI
|
||||
ELB() awsinterfaces.ELBAPI
|
||||
ELBV2() awsinterfaces.ELBV2API
|
||||
Autoscaling() autoscalingiface.AutoScalingAPI
|
||||
Autoscaling() awsinterfaces.AutoScalingAPI
|
||||
Route53() route53iface.Route53API
|
||||
Spotinst() spotinst.Cloud
|
||||
SQS() awsinterfaces.SQSAPI
|
||||
|
@ -200,7 +200,7 @@ type awsCloudImplementation struct {
|
|||
iam *iam.Client
|
||||
elb *elb.Client
|
||||
elbv2 *elbv2.Client
|
||||
autoscaling *autoscaling.AutoScaling
|
||||
autoscaling *autoscaling.Client
|
||||
route53 *route53.Route53
|
||||
spotinst spotinst.Cloud
|
||||
sts *sts.Client
|
||||
|
@ -349,16 +349,7 @@ func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error) {
|
|||
c.elbv2 = elbv2.NewFromConfig(cfgV2)
|
||||
c.sts = sts.NewFromConfig(cfgV2)
|
||||
|
||||
sess, err = session.NewSessionWithOptions(session.Options{
|
||||
Config: *config,
|
||||
SharedConfigState: session.SharedConfigEnable,
|
||||
})
|
||||
if err != nil {
|
||||
return c, err
|
||||
}
|
||||
c.autoscaling = autoscaling.New(sess, config)
|
||||
c.autoscaling.Handlers.Send.PushFront(requestLogger)
|
||||
c.addHandlers(region, &c.autoscaling.Handlers)
|
||||
c.autoscaling = autoscaling.NewFromConfig(cfgV2)
|
||||
|
||||
sess, err = session.NewSessionWithOptions(session.Options{
|
||||
Config: *config,
|
||||
|
@ -466,7 +457,7 @@ func (c *awsCloudImplementation) DeleteGroup(g *cloudinstances.CloudInstanceGrou
|
|||
|
||||
if c.spotinst != nil {
|
||||
if featureflag.SpotinstHybrid.Enabled() {
|
||||
if _, ok := g.Raw.(*autoscaling.Group); ok {
|
||||
if _, ok := g.Raw.(*autoscalingtypes.AutoScalingGroup); ok {
|
||||
return deleteGroup(ctx, c, g)
|
||||
}
|
||||
}
|
||||
|
@ -478,7 +469,7 @@ func (c *awsCloudImplementation) DeleteGroup(g *cloudinstances.CloudInstanceGrou
|
|||
}
|
||||
|
||||
func deleteGroup(ctx context.Context, c AWSCloud, g *cloudinstances.CloudInstanceGroup) error {
|
||||
asg := g.Raw.(*autoscaling.Group)
|
||||
asg := g.Raw.(*autoscalingtypes.AutoScalingGroup)
|
||||
|
||||
name := aws.StringValue(asg.AutoScalingGroupName)
|
||||
template := aws.StringValue(asg.LaunchConfigurationName)
|
||||
|
@ -511,7 +502,7 @@ func deleteGroup(ctx context.Context, c AWSCloud, g *cloudinstances.CloudInstanc
|
|||
AutoScalingGroupName: aws.String(name),
|
||||
ForceDelete: aws.Bool(true),
|
||||
}
|
||||
_, err := c.Autoscaling().DeleteAutoScalingGroupWithContext(ctx, request)
|
||||
_, err := c.Autoscaling().DeleteAutoScalingGroup(ctx, request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error deleting autoscaling group %q: %v", name, err)
|
||||
}
|
||||
|
@ -537,7 +528,7 @@ func deleteGroup(ctx context.Context, c AWSCloud, g *cloudinstances.CloudInstanc
|
|||
request := &autoscaling.DeleteLaunchConfigurationInput{
|
||||
LaunchConfigurationName: aws.String(template),
|
||||
}
|
||||
_, err := c.Autoscaling().DeleteLaunchConfigurationWithContext(ctx, request)
|
||||
_, err := c.Autoscaling().DeleteLaunchConfiguration(ctx, request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error deleting autoscaling launch configuration %q: %v", template, err)
|
||||
}
|
||||
|
@ -553,7 +544,7 @@ func deleteGroup(ctx context.Context, c AWSCloud, g *cloudinstances.CloudInstanc
|
|||
func (c *awsCloudImplementation) DeleteInstance(i *cloudinstances.CloudInstance) error {
|
||||
if c.spotinst != nil {
|
||||
if featureflag.SpotinstHybrid.Enabled() {
|
||||
if _, ok := i.CloudInstanceGroup.Raw.(*autoscaling.Group); ok {
|
||||
if _, ok := i.CloudInstanceGroup.Raw.(*autoscalingtypes.AutoScalingGroup); ok {
|
||||
return deleteInstance(c, i)
|
||||
}
|
||||
}
|
||||
|
@ -605,10 +596,10 @@ func deleteInstance(c AWSCloud, i *cloudinstances.CloudInstance) error {
|
|||
|
||||
// deregisterInstance ensures that the instance is fully drained/removed from all associated loadBalancers and targetGroups before termination.
|
||||
func deregisterInstance(ctx context.Context, c AWSCloud, i *cloudinstances.CloudInstance) error {
|
||||
asg := i.CloudInstanceGroup.Raw.(*autoscaling.Group)
|
||||
asg := i.CloudInstanceGroup.Raw.(*autoscalingtypes.AutoScalingGroup)
|
||||
|
||||
asgDetails, err := c.Autoscaling().DescribeAutoScalingGroupsWithContext(ctx, &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []*string{asg.AutoScalingGroupName},
|
||||
asgDetails, err := c.Autoscaling().DescribeAutoScalingGroups(ctx, &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: []string{aws.StringValue(asg.AutoScalingGroupName)},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("error describing autoScalingGroups: %v", err)
|
||||
|
@ -619,8 +610,8 @@ func deregisterInstance(ctx context.Context, c AWSCloud, i *cloudinstances.Cloud
|
|||
}
|
||||
|
||||
// there will always be only one ASG in the DescribeAutoScalingGroups response.
|
||||
loadBalancerNames := aws.StringValueSlice(asgDetails.AutoScalingGroups[0].LoadBalancerNames)
|
||||
targetGroupArns := aws.StringValueSlice(asgDetails.AutoScalingGroups[0].TargetGroupARNs)
|
||||
loadBalancerNames := asgDetails.AutoScalingGroups[0].LoadBalancerNames
|
||||
targetGroupArns := asgDetails.AutoScalingGroups[0].TargetGroupARNs
|
||||
|
||||
eg, _ := errgroup.WithContext(context.Background())
|
||||
|
||||
|
@ -771,7 +762,7 @@ func detachInstance(ctx context.Context, c AWSCloud, i *cloudinstances.CloudInst
|
|||
return fmt.Errorf("id was not set on CloudInstance: %v", i)
|
||||
}
|
||||
|
||||
asg := i.CloudInstanceGroup.Raw.(*autoscaling.Group)
|
||||
asg := i.CloudInstanceGroup.Raw.(*autoscalingtypes.AutoScalingGroup)
|
||||
if err := c.CreateTags(id, map[string]string{tagNameDetachedInstance: *asg.AutoScalingGroupName}); err != nil {
|
||||
return fmt.Errorf("error tagging instance %q: %v", id, err)
|
||||
}
|
||||
|
@ -780,11 +771,11 @@ func detachInstance(ctx context.Context, c AWSCloud, i *cloudinstances.CloudInst
|
|||
|
||||
input := &autoscaling.DetachInstancesInput{
|
||||
AutoScalingGroupName: aws.String(i.CloudInstanceGroup.HumanName),
|
||||
InstanceIds: []*string{aws.String(id)},
|
||||
InstanceIds: []string{id},
|
||||
ShouldDecrementDesiredCapacity: aws.Bool(false),
|
||||
}
|
||||
|
||||
if _, err := c.Autoscaling().DetachInstancesWithContext(ctx, input); err != nil {
|
||||
if _, err := c.Autoscaling().DetachInstances(ctx, input); err != nil {
|
||||
return fmt.Errorf("error detaching instance %q: %v", id, err)
|
||||
}
|
||||
|
||||
|
@ -977,40 +968,40 @@ func getCloudGroups(ctx context.Context, c AWSCloud, cluster *kops.Cluster, inst
|
|||
|
||||
// FindAutoscalingGroups finds autoscaling groups matching the specified tags
|
||||
// This isn't entirely trivial because autoscaling doesn't let us filter with as much precision as we would like
|
||||
func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscaling.Group, error) {
|
||||
func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscalingtypes.AutoScalingGroup, error) {
|
||||
ctx := context.TODO()
|
||||
|
||||
var asgs []*autoscaling.Group
|
||||
var asgs []*autoscalingtypes.AutoScalingGroup
|
||||
|
||||
klog.V(2).Infof("Listing all Autoscaling groups matching cluster tags")
|
||||
var asgNames []*string
|
||||
var asgNames []string
|
||||
{
|
||||
var asFilters []*autoscaling.Filter
|
||||
var asFilters []autoscalingtypes.Filter
|
||||
for _, v := range tags {
|
||||
// Not an exact match, but likely the best we can do
|
||||
asFilters = append(asFilters, &autoscaling.Filter{
|
||||
asFilters = append(asFilters, autoscalingtypes.Filter{
|
||||
Name: aws.String("value"),
|
||||
Values: []*string{aws.String(v)},
|
||||
Values: []string{v},
|
||||
})
|
||||
}
|
||||
request := &autoscaling.DescribeTagsInput{
|
||||
Filters: asFilters,
|
||||
}
|
||||
|
||||
err := c.Autoscaling().DescribeTagsPagesWithContext(ctx, request, func(p *autoscaling.DescribeTagsOutput, lastPage bool) bool {
|
||||
for _, t := range p.Tags {
|
||||
paginator := autoscaling.NewDescribeTagsPaginator(c.Autoscaling(), request)
|
||||
for paginator.HasMorePages() {
|
||||
page, err := paginator.NextPage(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing autoscaling cluster tags: %v", err)
|
||||
}
|
||||
for _, t := range page.Tags {
|
||||
switch *t.ResourceType {
|
||||
case "auto-scaling-group":
|
||||
asgNames = append(asgNames, t.ResourceId)
|
||||
asgNames = append(asgNames, aws.StringValue(t.ResourceId))
|
||||
default:
|
||||
klog.Warningf("Unknown resource type: %v", *t.ResourceType)
|
||||
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing autoscaling cluster tags: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1020,8 +1011,13 @@ func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscaling.G
|
|||
request := &autoscaling.DescribeAutoScalingGroupsInput{
|
||||
AutoScalingGroupNames: batch,
|
||||
}
|
||||
err := c.Autoscaling().DescribeAutoScalingGroupsPagesWithContext(ctx, request, func(p *autoscaling.DescribeAutoScalingGroupsOutput, lastPage bool) bool {
|
||||
for _, asg := range p.AutoScalingGroups {
|
||||
paginator := autoscaling.NewDescribeAutoScalingGroupsPaginator(c.Autoscaling(), request)
|
||||
for paginator.HasMorePages() {
|
||||
page, err := paginator.NextPage(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing autoscaling groups: %v", err)
|
||||
}
|
||||
for _, asg := range page.AutoScalingGroups {
|
||||
if !matchesAsgTags(tags, asg.Tags) {
|
||||
// We used an inexact filter above
|
||||
continue
|
||||
|
@ -1031,12 +1027,8 @@ func FindAutoscalingGroups(c AWSCloud, tags map[string]string) ([]*autoscaling.G
|
|||
klog.Warningf("Skipping ASG %v (which matches tags): %v", *asg.AutoScalingGroupARN, *asg.Status)
|
||||
continue
|
||||
}
|
||||
asgs = append(asgs, asg)
|
||||
asgs = append(asgs, &asg)
|
||||
}
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing autoscaling groups: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1053,7 +1045,7 @@ func minInt(a int, b int) int {
|
|||
}
|
||||
|
||||
// matchesAsgTags is used to filter an asg by tags
|
||||
func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription) bool {
|
||||
func matchesAsgTags(tags map[string]string, actual []autoscalingtypes.TagDescription) bool {
|
||||
for k, v := range tags {
|
||||
found := false
|
||||
for _, a := range actual {
|
||||
|
@ -1072,14 +1064,14 @@ func matchesAsgTags(tags map[string]string, actual []*autoscaling.TagDescription
|
|||
}
|
||||
|
||||
// findAutoscalingGroupLaunchConfiguration is responsible for finding the launch - which could be a launchconfiguration, a template or a mixed instance policy template
|
||||
func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (string, error) {
|
||||
func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscalingtypes.AutoScalingGroup) (string, error) {
|
||||
name := aws.StringValue(g.LaunchConfigurationName)
|
||||
if name != "" {
|
||||
return name, nil
|
||||
}
|
||||
|
||||
// @check the launch template then
|
||||
var launchTemplate *autoscaling.LaunchTemplateSpecification
|
||||
var launchTemplate *autoscalingtypes.LaunchTemplateSpecification
|
||||
if g.LaunchTemplate != nil {
|
||||
launchTemplate = g.LaunchTemplate
|
||||
} else if g.MixedInstancesPolicy != nil && g.MixedInstancesPolicy.LaunchTemplate != nil && g.MixedInstancesPolicy.LaunchTemplate.LaunchTemplateSpecification != nil {
|
||||
|
@ -1120,7 +1112,7 @@ func findAutoscalingGroupLaunchConfiguration(c AWSCloud, g *autoscaling.Group) (
|
|||
}
|
||||
|
||||
// findInstanceLaunchConfiguration is responsible for discoverying the launch configuration for an instance
|
||||
func findInstanceLaunchConfiguration(i *autoscaling.Instance) string {
|
||||
func findInstanceLaunchConfiguration(i autoscalingtypes.Instance) string {
|
||||
name := aws.StringValue(i.LaunchConfigurationName)
|
||||
if name != "" {
|
||||
return name
|
||||
|
@ -1139,7 +1131,7 @@ func findInstanceLaunchConfiguration(i *autoscaling.Instance) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func awsBuildCloudInstanceGroup(ctx context.Context, c AWSCloud, cluster *kops.Cluster, ig *kops.InstanceGroup, g *autoscaling.Group, nodeMap map[string]*v1.Node) (*cloudinstances.CloudInstanceGroup, error) {
|
||||
func awsBuildCloudInstanceGroup(ctx context.Context, c AWSCloud, cluster *kops.Cluster, ig *kops.InstanceGroup, g *autoscalingtypes.AutoScalingGroup, nodeMap map[string]*v1.Node) (*cloudinstances.CloudInstanceGroup, error) {
|
||||
newConfigName, err := findAutoscalingGroupLaunchConfiguration(c, g)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -1154,9 +1146,9 @@ func awsBuildCloudInstanceGroup(ctx context.Context, c AWSCloud, cluster *kops.C
|
|||
cg := &cloudinstances.CloudInstanceGroup{
|
||||
HumanName: aws.StringValue(g.AutoScalingGroupName),
|
||||
InstanceGroup: ig,
|
||||
MinSize: int(aws.Int64Value(g.MinSize)),
|
||||
TargetSize: int(aws.Int64Value(g.DesiredCapacity)),
|
||||
MaxSize: int(aws.Int64Value(g.MaxSize)),
|
||||
MinSize: int(aws.Int32Value(g.MinSize)),
|
||||
TargetSize: int(aws.Int32Value(g.DesiredCapacity)),
|
||||
MaxSize: int(aws.Int32Value(g.MaxSize)),
|
||||
Raw: g,
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1159,7 @@ func awsBuildCloudInstanceGroup(ctx context.Context, c AWSCloud, cluster *kops.C
|
|||
}
|
||||
}
|
||||
|
||||
result, err := c.Autoscaling().DescribeWarmPoolWithContext(ctx, &autoscaling.DescribeWarmPoolInput{
|
||||
result, err := c.Autoscaling().DescribeWarmPool(ctx, &autoscaling.DescribeWarmPoolInput{
|
||||
AutoScalingGroupName: g.AutoScalingGroupName,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -1204,7 +1196,7 @@ func awsBuildCloudInstanceGroup(ctx context.Context, c AWSCloud, cluster *kops.C
|
|||
return cg, nil
|
||||
}
|
||||
|
||||
func buildCloudInstance(i *autoscaling.Instance, instances map[string]*ec2.Instance, instanceSeen map[string]bool, nodeMap map[string]*v1.Node, cg *cloudinstances.CloudInstanceGroup, newConfigName string) error {
|
||||
func buildCloudInstance(i autoscalingtypes.Instance, instances map[string]*ec2.Instance, instanceSeen map[string]bool, nodeMap map[string]*v1.Node, cg *cloudinstances.CloudInstanceGroup, newConfigName string) error {
|
||||
id := aws.StringValue(i.InstanceId)
|
||||
if id == "" {
|
||||
klog.Warningf("ignoring instance with no instance id: %s in autoscaling group: %s", id, cg.HumanName)
|
||||
|
@ -1212,7 +1204,7 @@ func buildCloudInstance(i *autoscaling.Instance, instances map[string]*ec2.Insta
|
|||
}
|
||||
instanceSeen[id] = true
|
||||
// @step: check if the instance is terminating
|
||||
if aws.StringValue(i.LifecycleState) == autoscaling.LifecycleStateTerminating {
|
||||
if i.LifecycleState == autoscalingtypes.LifecycleStateTerminating {
|
||||
klog.Warningf("ignoring instance as it is terminating: %s in autoscaling group: %s", id, cg.HumanName)
|
||||
return nil
|
||||
}
|
||||
|
@ -1228,7 +1220,7 @@ func buildCloudInstance(i *autoscaling.Instance, instances map[string]*ec2.Insta
|
|||
if err != nil {
|
||||
return fmt.Errorf("error creating cloud instance group member: %v", err)
|
||||
}
|
||||
if strings.HasPrefix(*i.LifecycleState, "Warmed") {
|
||||
if strings.HasPrefix(string(i.LifecycleState), "Warmed") {
|
||||
cm.State = cloudinstances.WarmPool
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1270,7 @@ func findInstances(c AWSCloud, ig *kops.InstanceGroup) (map[string]*ec2.Instance
|
|||
return instances, nil
|
||||
}
|
||||
|
||||
func findDetachedInstances(c AWSCloud, g *autoscaling.Group) ([]*string, error) {
|
||||
func findDetachedInstances(c AWSCloud, g *autoscalingtypes.AutoScalingGroup) ([]*string, error) {
|
||||
clusterName := c.Tags()[TagClusterName]
|
||||
req := &ec2.DescribeInstancesInput{
|
||||
Filters: []*ec2.Filter{
|
||||
|
@ -2175,7 +2167,7 @@ func (c *awsCloudImplementation) ELBV2() awsinterfaces.ELBV2API {
|
|||
return c.elbv2
|
||||
}
|
||||
|
||||
func (c *awsCloudImplementation) Autoscaling() autoscalingiface.AutoScalingAPI {
|
||||
func (c *awsCloudImplementation) Autoscaling() awsinterfaces.AutoScalingAPI {
|
||||
return c.autoscaling
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ import (
|
|||
awsv2 "github.com/aws/aws-sdk-go-v2/aws"
|
||||
"github.com/aws/aws-sdk-go-v2/aws/arn"
|
||||
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
autoscalingtypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
|
||||
ec2v2 "github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||
elbtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
|
||||
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
|
||||
iamtypes "github.com/aws/aws-sdk-go-v2/service/iam/types"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/smithy-go"
|
||||
"k8s.io/klog/v2"
|
||||
|
@ -126,7 +126,7 @@ func FindEC2Tag(tags []*ec2.Tag, key string) (string, bool) {
|
|||
}
|
||||
|
||||
// FindASGTag find the value of the tag with the specified key
|
||||
func FindASGTag(tags []*autoscaling.TagDescription, key string) (string, bool) {
|
||||
func FindASGTag(tags []autoscalingtypes.TagDescription, key string) (string, bool) {
|
||||
for _, tag := range tags {
|
||||
if key == aws.ToString(tag.Key) {
|
||||
return aws.ToString(tag.Value), true
|
||||
|
|
|
@ -25,7 +25,6 @@ import (
|
|||
elbtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing/types"
|
||||
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"github.com/aws/aws-sdk-go/service/ec2/ec2iface"
|
||||
"github.com/aws/aws-sdk-go/service/route53/route53iface"
|
||||
|
@ -74,7 +73,7 @@ func BuildMockAWSCloud(region string, zoneLetters string) *MockAWSCloud {
|
|||
}
|
||||
|
||||
type MockCloud struct {
|
||||
MockAutoscaling autoscalingiface.AutoScalingAPI
|
||||
MockAutoscaling awsinterfaces.AutoScalingAPI
|
||||
MockEC2 ec2iface.EC2API
|
||||
MockIAM awsinterfaces.IAMAPI
|
||||
MockRoute53 route53iface.Route53API
|
||||
|
@ -262,7 +261,7 @@ func (c *MockAWSCloud) ELBV2() awsinterfaces.ELBV2API {
|
|||
return c.MockELBV2
|
||||
}
|
||||
|
||||
func (c *MockAWSCloud) Autoscaling() autoscalingiface.AutoScalingAPI {
|
||||
func (c *MockAWSCloud) Autoscaling() awsinterfaces.AutoScalingAPI {
|
||||
if c.MockAutoscaling == nil {
|
||||
klog.Fatalf("MockAWSCloud Autoscaling not set")
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ import (
|
|||
"github.com/aws/aws-sdk-go-v2/aws"
|
||||
awsconfig "github.com/aws/aws-sdk-go-v2/config"
|
||||
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
"github.com/aws/aws-sdk-go-v2/service/kms"
|
||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling"
|
||||
"go.uber.org/multierr"
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/kops/nodeup/pkg/model"
|
||||
|
@ -408,9 +408,9 @@ func completeWarmingLifecycleAction(ctx context.Context, cloud awsup.AWSCloud, m
|
|||
asgName := modelContext.BootConfig.InstanceGroupName + "." + modelContext.NodeupConfig.ClusterName
|
||||
hookName := "kops-warmpool"
|
||||
svc := cloud.Autoscaling()
|
||||
hooks, err := svc.DescribeLifecycleHooksWithContext(ctx, &autoscaling.DescribeLifecycleHooksInput{
|
||||
hooks, err := svc.DescribeLifecycleHooks(ctx, &autoscaling.DescribeLifecycleHooksInput{
|
||||
AutoScalingGroupName: &asgName,
|
||||
LifecycleHookNames: []*string{&hookName},
|
||||
LifecycleHookNames: []string{hookName},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to find lifecycle hook %q: %w", hookName, err)
|
||||
|
@ -418,7 +418,7 @@ func completeWarmingLifecycleAction(ctx context.Context, cloud awsup.AWSCloud, m
|
|||
|
||||
if len(hooks.LifecycleHooks) > 0 {
|
||||
klog.Info("Found ASG lifecycle hook")
|
||||
_, err := svc.CompleteLifecycleActionWithContext(ctx, &autoscaling.CompleteLifecycleActionInput{
|
||||
_, err := svc.CompleteLifecycleAction(ctx, &autoscaling.CompleteLifecycleActionInput{
|
||||
AutoScalingGroupName: &asgName,
|
||||
InstanceId: &modelContext.InstanceID,
|
||||
LifecycleHookName: &hookName,
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
Copyright 2024 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package awsinterfaces
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
|
||||
)
|
||||
|
||||
type AutoScalingAPI interface {
|
||||
AttachInstances(ctx context.Context, params *autoscaling.AttachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.AttachInstancesOutput, error)
|
||||
AttachLoadBalancers(ctx context.Context, params *autoscaling.AttachLoadBalancersInput, optFns ...func(*autoscaling.Options)) (*autoscaling.AttachLoadBalancersOutput, error)
|
||||
AttachLoadBalancerTargetGroups(ctx context.Context, params *autoscaling.AttachLoadBalancerTargetGroupsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.AttachLoadBalancerTargetGroupsOutput, error)
|
||||
CompleteLifecycleAction(ctx context.Context, params *autoscaling.CompleteLifecycleActionInput, optFns ...func(*autoscaling.Options)) (*autoscaling.CompleteLifecycleActionOutput, error)
|
||||
CreateAutoScalingGroup(ctx context.Context, params *autoscaling.CreateAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.CreateAutoScalingGroupOutput, error)
|
||||
CreateOrUpdateTags(ctx context.Context, params *autoscaling.CreateOrUpdateTagsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.CreateOrUpdateTagsOutput, error)
|
||||
DeleteAutoScalingGroup(ctx context.Context, params *autoscaling.DeleteAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteAutoScalingGroupOutput, error)
|
||||
DeleteLaunchConfiguration(ctx context.Context, params *autoscaling.DeleteLaunchConfigurationInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteLaunchConfigurationOutput, error)
|
||||
DeleteLifecycleHook(ctx context.Context, params *autoscaling.DeleteLifecycleHookInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteLifecycleHookOutput, error)
|
||||
DeleteTags(ctx context.Context, params *autoscaling.DeleteTagsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteTagsOutput, error)
|
||||
DeleteWarmPool(ctx context.Context, params *autoscaling.DeleteWarmPoolInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DeleteWarmPoolOutput, error)
|
||||
DescribeAutoScalingGroups(ctx context.Context, params *autoscaling.DescribeAutoScalingGroupsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeAutoScalingGroupsOutput, error)
|
||||
DescribeLifecycleHooks(ctx context.Context, params *autoscaling.DescribeLifecycleHooksInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeLifecycleHooksOutput, error)
|
||||
DescribeTags(ctx context.Context, params *autoscaling.DescribeTagsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeTagsOutput, error)
|
||||
DescribeWarmPool(ctx context.Context, params *autoscaling.DescribeWarmPoolInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DescribeWarmPoolOutput, error)
|
||||
DetachInstances(ctx context.Context, params *autoscaling.DetachInstancesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachInstancesOutput, error)
|
||||
DetachLoadBalancers(ctx context.Context, params *autoscaling.DetachLoadBalancersInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachLoadBalancersOutput, error)
|
||||
DetachLoadBalancerTargetGroups(ctx context.Context, params *autoscaling.DetachLoadBalancerTargetGroupsInput, optFns ...func(*autoscaling.Options)) (*autoscaling.DetachLoadBalancerTargetGroupsOutput, error)
|
||||
EnableMetricsCollection(ctx context.Context, params *autoscaling.EnableMetricsCollectionInput, optFns ...func(*autoscaling.Options)) (*autoscaling.EnableMetricsCollectionOutput, error)
|
||||
PutLifecycleHook(ctx context.Context, params *autoscaling.PutLifecycleHookInput, optFns ...func(*autoscaling.Options)) (*autoscaling.PutLifecycleHookOutput, error)
|
||||
PutWarmPool(ctx context.Context, params *autoscaling.PutWarmPoolInput, optFns ...func(*autoscaling.Options)) (*autoscaling.PutWarmPoolOutput, error)
|
||||
ResumeProcesses(ctx context.Context, params *autoscaling.ResumeProcessesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.ResumeProcessesOutput, error)
|
||||
SuspendProcesses(ctx context.Context, params *autoscaling.SuspendProcessesInput, optFns ...func(*autoscaling.Options)) (*autoscaling.SuspendProcessesOutput, error)
|
||||
TerminateInstanceInAutoScalingGroup(ctx context.Context, params *autoscaling.TerminateInstanceInAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.TerminateInstanceInAutoScalingGroupOutput, error)
|
||||
UpdateAutoScalingGroup(ctx context.Context, params *autoscaling.UpdateAutoScalingGroupInput, optFns ...func(*autoscaling.Options)) (*autoscaling.UpdateAutoScalingGroupOutput, error)
|
||||
}
|
Loading…
Reference in New Issue