Skip to content

Commit

Permalink
Removes unused autoscaling code
Browse files Browse the repository at this point in the history
  • Loading branch information
mmerkes committed Nov 12, 2024
1 parent e101f87 commit 462a4c3
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 43 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ e2e.test:
.PHONY: check
check: verify-fmt verify-lint vet

.PHONY: develop
develop: aws-cloud-controller-manager test update-fmt check

.PHONY: test
test:
go test -count=1 -race -v $(shell go list ./...)
Expand Down
16 changes: 0 additions & 16 deletions pkg/providers/v1/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/aws/aws-sdk-go/aws/endpoints"
"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/ec2"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/elbv2"
Expand Down Expand Up @@ -290,7 +289,6 @@ type Services interface {
Compute(region string) (iface.EC2, error)
LoadBalancing(region string) (ELB, error)
LoadBalancingV2(region string) (ELBV2, error)
Autoscaling(region string) (ASG, error)
Metadata() (config.EC2Metadata, error)
KeyManagement(region string) (KMS, error)
}
Expand Down Expand Up @@ -354,13 +352,6 @@ type ELBV2 interface {
WaitUntilLoadBalancersDeleted(*elbv2.DescribeLoadBalancersInput) error
}

// ASG is a simple pass-through of the Autoscaling client interface, which
// allows for testing.
type ASG interface {
UpdateAutoScalingGroup(*autoscaling.UpdateAutoScalingGroupInput) (*autoscaling.UpdateAutoScalingGroupOutput, error)
DescribeAutoScalingGroups(*autoscaling.DescribeAutoScalingGroupsInput) (*autoscaling.DescribeAutoScalingGroupsOutput, error)
}

// KMS is a simple pass-through of the Key Management Service client interface,
// which allows for testing.
type KMS interface {
Expand All @@ -378,7 +369,6 @@ type Cloud struct {
ec2 iface.EC2
elb ELB
elbv2 ELBV2
asg ASG
kms KMS
metadata config.EC2Metadata
cfg *config.CloudConfig
Expand Down Expand Up @@ -604,11 +594,6 @@ func newAWSCloud2(cfg config.CloudConfig, awsServices Services, provider config.
return nil, fmt.Errorf("error creating AWS ELBV2 client: %v", err)
}

asg, err := awsServices.Autoscaling(regionName)
if err != nil {
return nil, fmt.Errorf("error creating AWS autoscaling client: %v", err)
}

kms, err := awsServices.KeyManagement(regionName)
if err != nil {
return nil, fmt.Errorf("error creating AWS key management client: %v", err)
Expand All @@ -618,7 +603,6 @@ func newAWSCloud2(cfg config.CloudConfig, awsServices Services, provider config.
ec2: ec2,
elb: elb,
elbv2: elbv2,
asg: asg,
metadata: metadata,
kms: kms,
cfg: &cfg,
Expand Down
5 changes: 0 additions & 5 deletions pkg/providers/v1/aws_fakes.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ func (s *FakeAWSServices) LoadBalancingV2(region string) (ELBV2, error) {
return s.elbv2, nil
}

// Autoscaling returns a fake ASG client
func (s *FakeAWSServices) Autoscaling(region string) (ASG, error) {
return s.asg, nil
}

// Metadata returns a fake EC2Metadata client
func (s *FakeAWSServices) Metadata() (config.EC2Metadata, error) {
return s.metadata, nil
Expand Down
22 changes: 0 additions & 22 deletions pkg/providers/v1/aws_sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/aws/aws-sdk-go/aws/ec2metadata"
"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/ec2"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/elbv2"
Expand Down Expand Up @@ -179,27 +178,6 @@ func (p *awsSDKProvider) LoadBalancingV2(regionName string) (ELBV2, error) {
return elbClient, nil
}

func (p *awsSDKProvider) Autoscaling(regionName string) (ASG, error) {
awsConfig := &aws.Config{
Region: &regionName,
Credentials: p.creds,
}
awsConfig = awsConfig.WithCredentialsChainVerboseErrors(true).
WithEndpointResolver(p.cfg.GetResolver())
sess, err := session.NewSessionWithOptions(session.Options{
Config: *awsConfig,
SharedConfigState: session.SharedConfigEnable,
})
if err != nil {
return nil, fmt.Errorf("unable to initialize AWS session: %v", err)
}
client := autoscaling.New(sess)

p.AddHandlers(regionName, &client.Handlers)

return client, nil
}

func (p *awsSDKProvider) Metadata() (config.EC2Metadata, error) {
sess, err := session.NewSession(&aws.Config{
EndpointResolver: p.cfg.GetResolver(),
Expand Down

0 comments on commit 462a4c3

Please sign in to comment.