mirror of https://github.com/kubernetes/kops.git
aws: Fix SIGSEGV when using instance selector
This commit is contained in:
parent
c592a02bb4
commit
211c82d8ad
|
@ -271,9 +271,11 @@ func RunToolboxInstanceSelector(ctx context.Context, f commandutils.Factory, out
|
|||
return fmt.Errorf("error initializing AWS client: %v", err)
|
||||
}
|
||||
|
||||
instanceSelector := selector.Selector{
|
||||
EC2: cloud.EC2(),
|
||||
sess, err := cloud.Session()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
instanceSelector := selector.New(sess)
|
||||
|
||||
igCount := options.InstanceGroupCount
|
||||
filters := getFilters(commandline, region, zones)
|
||||
|
|
|
@ -124,6 +124,7 @@ const AWSErrCodeInvalidAction = "InvalidAction"
|
|||
type AWSCloud interface {
|
||||
fi.Cloud
|
||||
CloudFormation() *cloudformation.CloudFormation
|
||||
Session() (*session.Session, error)
|
||||
EC2() ec2iface.EC2API
|
||||
IAM() iamiface.IAMAPI
|
||||
ELB() elbiface.ELBAPI
|
||||
|
@ -404,6 +405,22 @@ func NewAWSCloud(region string, tags map[string]string) (AWSCloud, error) {
|
|||
return i, nil
|
||||
}
|
||||
|
||||
func (c *awsCloudImplementation) Session() (*session.Session, error) {
|
||||
config := aws.NewConfig().WithRegion(c.region)
|
||||
config = config.WithCredentialsChainVerboseErrors(true)
|
||||
config = request.WithRetryer(config, newLoggingRetryer(ClientMaxRetries))
|
||||
|
||||
sess, err := session.NewSessionWithOptions(session.Options{
|
||||
Config: *config,
|
||||
SharedConfigState: session.SharedConfigEnable,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create session: %w", err)
|
||||
}
|
||||
|
||||
return sess, err
|
||||
}
|
||||
|
||||
func (c *awsCloudImplementation) addHandlers(regionName string, h *request.Handlers) {
|
||||
delayer := c.getCrossRequestRetryDelay(regionName)
|
||||
if delayer != nil {
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"github.com/aws/aws-sdk-go/service/autoscaling/autoscalingiface"
|
||||
"github.com/aws/aws-sdk-go/service/cloudformation"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
|
@ -400,3 +401,7 @@ func (c *MockAWSCloud) DescribeInstanceType(instanceType string) (*ec2.InstanceT
|
|||
func (c *MockAWSCloud) AccountInfo() (string, string, error) {
|
||||
return "123456789012", "aws-test", nil
|
||||
}
|
||||
|
||||
func (c *MockAWSCloud) Session() (*session.Session, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue