Skip to content

Commit

Permalink
removed CheckEC2Connectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
edibble21 committed Sep 27, 2024
1 parent 2e5d09a commit e125ee5
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ import (
//v2
configV2 "github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
ec2V2 "github.com/aws/aws-sdk-go-v2/service/ec2"
iamV2 "github.com/aws/aws-sdk-go-v2/service/iam"
"github.com/aws/smithy-go"
prometheusv2 "github.com/jonathan-innis/aws-sdk-go-prometheus/v2"

//v1
Expand Down Expand Up @@ -172,6 +170,14 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont
unavailableOfferingsCache,
pricingProvider,
)
instanceProvider := instance.NewDefaultProvider(
ctx,
aws.StringValue(sess.Config.Region),
ec2api,
unavailableOfferingsCache,
subnetProvider,
launchTemplateProvider,
)

//v2
cfg, err := configV2.LoadDefaultConfig(ctx,
Expand All @@ -193,14 +199,6 @@ func NewOperator(ctx context.Context, operator *operator.Operator) (context.Cont
}

instanceProfileProvider := instanceprofile.NewDefaultProvider(cfg.Region, iamV2.NewFromConfig(cfg), cache.New(awscache.InstanceProfileTTL, awscache.DefaultCleanupInterval))
instanceProvider := instance.NewDefaultProvider(
ctx,
aws.StringValue(sess.Config.Region),
ec2api,
unavailableOfferingsCache,
subnetProvider,
launchTemplateProvider,
)

return ctx, &Operator{
Operator: operator,
Expand Down Expand Up @@ -238,19 +236,6 @@ func CheckEC2Connectivity(ctx context.Context, api ec2iface.EC2API) error {
return err
}

// CheckEC2Connectivity makes a dry-run call to DescribeInstanceTypes. If it fails, we provide an early indicator that we
// are having issues connecting to the EC2 API.
func CheckEC2ConnectivityV2(ctx context.Context, api *ec2V2.Client) error {
_, err := api.DescribeInstanceTypes(ctx, &ec2V2.DescribeInstanceTypesInput{
DryRun: aws.Bool(true),
})
var apiErr smithy.APIError
if errors.As(err, &apiErr) && apiErr.ErrorCode() == "DryRunOperation" {
return nil
}
return err
}

func ResolveClusterEndpoint(ctx context.Context, eksAPI eksiface.EKSAPI) (string, error) {
clusterEndpointFromOptions := options.FromContext(ctx).ClusterEndpoint
if clusterEndpointFromOptions != "" {
Expand Down

0 comments on commit e125ee5

Please sign in to comment.