[AWS EKS - Scale-to-0] Add EKS service and DescribeNodegroup API call

This change adds the AWS EKS service to the vendor service directory and adds the DescribeNodegroup API call to the AWSWrapper. This will be used for the AWS scale-to-0 project to get more information about empty managed nodegroups

Related proposal: https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/proposals/circumvent-tag-limit-aws.md
This commit is contained in:
MyannaHarris 2021-11-04 11:47:38 -07:00
parent f0eb6e8f78
commit 06b4297581
13 changed files with 11543 additions and 11 deletions

View File

@ -38,8 +38,8 @@ var testAwsManager = &AwsManager{
awsService: testAwsService,
}
func newTestAwsManagerWithMockServices(mockAutoScaling autoScalingI, mockEC2 ec2I, autoDiscoverySpecs []asgAutoDiscoveryConfig) *AwsManager {
awsService := awsWrapper{mockAutoScaling, mockEC2}
func newTestAwsManagerWithMockServices(mockAutoScaling autoScalingI, mockEC2 ec2I, mockEKS eksI, autoDiscoverySpecs []asgAutoDiscoveryConfig) *AwsManager {
awsService := awsWrapper{mockAutoScaling, mockEC2, mockEKS}
return &AwsManager{
awsService: awsService,
asgCache: &asgCache{
@ -56,13 +56,13 @@ func newTestAwsManagerWithMockServices(mockAutoScaling autoScalingI, mockEC2 ec2
}
func newTestAwsManagerWithAsgs(t *testing.T, mockAutoScaling autoScalingI, mockEC2 ec2I, specs []string) *AwsManager {
m := newTestAwsManagerWithMockServices(mockAutoScaling, mockEC2, nil)
m := newTestAwsManagerWithMockServices(mockAutoScaling, mockEC2, nil, nil)
m.asgCache.parseExplicitAsgs(specs)
return m
}
func newTestAwsManagerWithAutoAsgs(t *testing.T, mockAutoScaling autoScalingI, mockEC2 ec2I, specs []string, autoDiscoverySpecs []asgAutoDiscoveryConfig) *AwsManager {
m := newTestAwsManagerWithMockServices(mockAutoScaling, mockEC2, autoDiscoverySpecs)
m := newTestAwsManagerWithMockServices(mockAutoScaling, mockEC2, nil, autoDiscoverySpecs)
m.asgCache.parseExplicitAsgs(specs)
return m
}
@ -524,7 +524,7 @@ func TestDeleteNodesAfterMultipleRefreshes(t *testing.T) {
func TestGetResourceLimiter(t *testing.T) {
mockAutoScaling := &autoScalingMock{}
mockEC2 := &ec2Mock{}
m := newTestAwsManagerWithMockServices(mockAutoScaling, mockEC2, nil)
m := newTestAwsManagerWithMockServices(mockAutoScaling, mockEC2, nil, nil)
provider := testProvider(t, m)
_, err := provider.GetResourceLimiter()

View File

@ -34,6 +34,7 @@ import (
"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/eks"
"gopkg.in/gcfg.v1"
apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
@ -194,7 +195,7 @@ func createAWSManagerInternal(
return nil, err
}
awsService = &awsWrapper{autoscaling.New(sess), ec2.New(sess)}
awsService = &awsWrapper{autoscaling.New(sess), ec2.New(sess), eks.New(sess)}
}
specs, err := parseASGAutoDiscoverySpecs(discoveryOpts)

View File

@ -330,7 +330,7 @@ func TestFetchExplicitAsgs(t *testing.T) {
defer resetAWSRegion(os.LookupEnv("AWS_REGION"))
os.Setenv("AWS_REGION", "fanghorn")
instanceTypes, _ := GetStaticEC2InstanceTypes()
m, err := createAWSManagerInternal(nil, do, &awsWrapper{a, nil}, instanceTypes)
m, err := createAWSManagerInternal(nil, do, &awsWrapper{a, nil, nil}, instanceTypes)
assert.NoError(t, err)
asgs := m.asgCache.Get()
@ -395,7 +395,7 @@ func TestGetASGTemplate(t *testing.T) {
instanceTypes, _ := GetStaticEC2InstanceTypes()
do := cloudprovider.NodeGroupDiscoveryOptions{}
m, err := createAWSManagerInternal(nil, do, &awsWrapper{nil, e}, instanceTypes)
m, err := createAWSManagerInternal(nil, do, &awsWrapper{nil, e, nil}, instanceTypes)
origGetInstanceTypeFunc := getInstanceTypeForAsg
defer func() { getInstanceTypeForAsg = origGetInstanceTypeFunc }()
getInstanceTypeForAsg = func(m *asgCache, asg *asg) (string, error) {
@ -483,7 +483,7 @@ func TestFetchAutoAsgs(t *testing.T) {
os.Setenv("AWS_REGION", "fanghorn")
// fetchAutoASGs is called at manager creation time, via forceRefresh
instanceTypes, _ := GetStaticEC2InstanceTypes()
m, err := createAWSManagerInternal(nil, do, &awsWrapper{a, nil}, instanceTypes)
m, err := createAWSManagerInternal(nil, do, &awsWrapper{a, nil, nil}, instanceTypes)
assert.NoError(t, err)
asgs := m.asgCache.Get()

View File

@ -18,11 +18,14 @@ package aws
import (
"fmt"
"strconv"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/eks"
apiv1 "k8s.io/api/core/v1"
klog "k8s.io/klog/v2"
)
@ -40,10 +43,73 @@ type ec2I interface {
DescribeLaunchTemplateVersions(input *ec2.DescribeLaunchTemplateVersionsInput) (*ec2.DescribeLaunchTemplateVersionsOutput, error)
}
// eksI is the interface that represents a specific aspect of EKS (Elastic Kubernetes Service) which is provided by AWS SDK for use in CA
type eksI interface {
DescribeNodegroup(input *eks.DescribeNodegroupInput) (*eks.DescribeNodegroupOutput, error)
}
// awsWrapper provides several utility methods over the services provided by the AWS SDK
type awsWrapper struct {
autoScalingI
ec2I
eksI
}
func (m *awsWrapper) getManagedNodegroupInfo(nodegroupName string, clusterName string) ([]apiv1.Taint, map[string]string, error) {
params := &eks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &nodegroupName,
}
start := time.Now()
r, err := m.DescribeNodegroup(params)
observeAWSRequest("DescribeNodegroup", err, start)
if err != nil {
return nil, nil, err
}
taints := make([]apiv1.Taint, 0)
labels := make(map[string]string)
// Labels will include diskSize, amiType, capacityType, version
if r.Nodegroup.DiskSize != nil {
labels["diskSize"] = strconv.FormatInt(*r.Nodegroup.DiskSize, 10)
}
if r.Nodegroup.AmiType != nil && len(*r.Nodegroup.AmiType) > 0 {
labels["amiType"] = *r.Nodegroup.AmiType
}
if r.Nodegroup.CapacityType != nil && len(*r.Nodegroup.CapacityType) > 0 {
labels["capacityType"] = *r.Nodegroup.CapacityType
}
if r.Nodegroup.Version != nil && len(*r.Nodegroup.Version) > 0 {
labels["k8sVersion"] = *r.Nodegroup.Version
}
if r.Nodegroup.Labels != nil && len(r.Nodegroup.Labels) > 0 {
labelsMap := r.Nodegroup.Labels
for k, v := range labelsMap {
if v != nil {
labels[k] = *v
}
}
}
if r.Nodegroup.Taints != nil && len(r.Nodegroup.Taints) > 0 {
taintList := r.Nodegroup.Taints
for _, taint := range taintList {
if taint != nil && taint.Effect != nil && taint.Key != nil && taint.Value != nil {
taints = append(taints, apiv1.Taint{
Key: *taint.Key,
Value: *taint.Value,
Effect: apiv1.TaintEffect(*taint.Effect),
})
}
}
}
return taints, labels, nil
}
func (m *awsWrapper) getInstanceTypeByLaunchConfigNames(launchConfigToQuery []*string) (map[string]string, error) {

View File

@ -19,13 +19,16 @@ package aws
import (
"fmt"
"os"
"strconv"
"testing"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/aws/aws-sdk-go/service/eks"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
apiv1 "k8s.io/api/core/v1"
)
type autoScalingMock struct {
@ -66,13 +69,178 @@ func (e *ec2Mock) DescribeLaunchTemplateVersions(i *ec2.DescribeLaunchTemplateVe
return args.Get(0).(*ec2.DescribeLaunchTemplateVersionsOutput), nil
}
var testAwsService = awsWrapper{&autoScalingMock{}, &ec2Mock{}}
type eksMock struct {
mock.Mock
}
func (k *eksMock) DescribeNodegroup(i *eks.DescribeNodegroupInput) (*eks.DescribeNodegroupOutput, error) {
args := k.Called(i)
return args.Get(0).(*eks.DescribeNodegroupOutput), nil
}
var testAwsService = awsWrapper{&autoScalingMock{}, &ec2Mock{}, &eksMock{}}
func TestGetManagedNodegroup(t *testing.T) {
k := &eksMock{}
awsWrapper := &awsWrapper{
autoScalingI: nil,
ec2I: nil,
eksI: k,
}
labelKey1 := "labelKey 1"
labelKey2 := "labelKey 2"
labelValue1 := "testValue 1"
labelValue2 := "testValue 2"
nodegroupName := "testNodegroup"
clusterName := "testCluster"
taintEffect1 := "effect 1"
taintKey1 := "key 1"
taintValue1 := "value 1"
taint1 := eks.Taint{
Effect: &taintEffect1,
Key: &taintKey1,
Value: &taintValue1,
}
taintEffect2 := "effect 2"
taintKey2 := "key 2"
taintValue2 := "value 2"
taint2 := eks.Taint{
Effect: &taintEffect2,
Key: &taintKey2,
Value: &taintValue2,
}
amiType := "testAmiType"
diskSize := int64(100)
capacityType := "testCapacityType"
k8sVersion := "1.19"
// Create test nodegroup
testNodegroup := eks.Nodegroup{
AmiType: &amiType,
ClusterName: &clusterName,
DiskSize: &diskSize,
Labels: map[string]*string{labelKey1: &labelValue1, labelKey2: &labelValue2},
NodegroupName: &nodegroupName,
CapacityType: &capacityType,
Version: &k8sVersion,
Taints: []*eks.Taint{&taint1, &taint2},
}
k.On("DescribeNodegroup", &eks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &nodegroupName,
}).Return(&eks.DescribeNodegroupOutput{Nodegroup: &testNodegroup})
taintList, labelMap, err := awsWrapper.getManagedNodegroupInfo(nodegroupName, clusterName)
assert.Nil(t, err)
assert.Equal(t, len(taintList), 2)
assert.Equal(t, taintList[0].Effect, apiv1.TaintEffect(taintEffect1))
assert.Equal(t, taintList[0].Key, taintKey1)
assert.Equal(t, taintList[0].Value, taintValue1)
assert.Equal(t, taintList[1].Effect, apiv1.TaintEffect(taintEffect2))
assert.Equal(t, taintList[1].Key, taintKey2)
assert.Equal(t, taintList[1].Value, taintValue2)
assert.Equal(t, len(labelMap), 6)
assert.Equal(t, labelMap[labelKey1], labelValue1)
assert.Equal(t, labelMap[labelKey2], labelValue2)
assert.Equal(t, labelMap["diskSize"], strconv.FormatInt(diskSize, 10))
assert.Equal(t, labelMap["amiType"], amiType)
assert.Equal(t, labelMap["capacityType"], capacityType)
assert.Equal(t, labelMap["k8sVersion"], k8sVersion)
}
func TestGetManagedNodegroupWithNilValues(t *testing.T) {
k := &eksMock{}
awsWrapper := &awsWrapper{
autoScalingI: nil,
ec2I: nil,
eksI: k,
}
nodegroupName := "testNodegroup"
clusterName := "testCluster"
amiType := "testAmiType"
capacityType := "testCapacityType"
k8sVersion := "1.19"
// Create test nodegroup
testNodegroup := eks.Nodegroup{
AmiType: &amiType,
ClusterName: &clusterName,
DiskSize: nil,
Labels: nil,
NodegroupName: &nodegroupName,
CapacityType: &capacityType,
Version: &k8sVersion,
Taints: nil,
}
k.On("DescribeNodegroup", &eks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &nodegroupName,
}).Return(&eks.DescribeNodegroupOutput{Nodegroup: &testNodegroup})
taintList, labelMap, err := awsWrapper.getManagedNodegroupInfo(nodegroupName, clusterName)
assert.Nil(t, err)
assert.Equal(t, len(taintList), 0)
assert.Equal(t, len(labelMap), 3)
assert.Equal(t, labelMap["amiType"], amiType)
assert.Equal(t, labelMap["capacityType"], capacityType)
assert.Equal(t, labelMap["k8sVersion"], k8sVersion)
}
func TestGetManagedNodegroupWithEmptyValues(t *testing.T) {
k := &eksMock{}
awsWrapper := &awsWrapper{
autoScalingI: nil,
ec2I: nil,
eksI: k,
}
nodegroupName := "testNodegroup"
clusterName := "testCluster"
amiType := "testAmiType"
capacityType := "testCapacityType"
k8sVersion := "1.19"
// Create test nodegroup
testNodegroup := eks.Nodegroup{
AmiType: &amiType,
ClusterName: &clusterName,
DiskSize: nil,
Labels: make(map[string]*string),
NodegroupName: &nodegroupName,
CapacityType: &capacityType,
Version: &k8sVersion,
Taints: make([]*eks.Taint, 0),
}
k.On("DescribeNodegroup", &eks.DescribeNodegroupInput{
ClusterName: &clusterName,
NodegroupName: &nodegroupName,
}).Return(&eks.DescribeNodegroupOutput{Nodegroup: &testNodegroup})
taintList, labelMap, err := awsWrapper.getManagedNodegroupInfo(nodegroupName, clusterName)
assert.Nil(t, err)
assert.Equal(t, len(taintList), 0)
assert.Equal(t, len(labelMap), 3)
assert.Equal(t, labelMap["amiType"], amiType)
assert.Equal(t, labelMap["capacityType"], capacityType)
assert.Equal(t, labelMap["k8sVersion"], k8sVersion)
}
func TestMoreThen100Groups(t *testing.T) {
a := &autoScalingMock{}
awsWrapper := &awsWrapper{
autoScalingI: a,
ec2I: nil,
eksI: nil,
}
// Generate 101 ASG names
@ -152,6 +320,7 @@ func TestGetInstanceTypesForAsgs(t *testing.T) {
awsWrapper := &awsWrapper{
autoScalingI: a,
ec2I: e,
eksI: nil,
}
cases := []struct {

View File

@ -76,7 +76,7 @@ func TestLTVersionChange(t *testing.T) {
},
fakeClock,
)
m := newAsgInstanceTypeCacheWithClock(&awsWrapper{a, e}, fakeClock, fakeStore)
m := newAsgInstanceTypeCacheWithClock(&awsWrapper{a, e, nil}, fakeClock, fakeStore)
for i := 0; i < 2; i++ {
err := m.populate([]*asg{

View File

@ -41,6 +41,8 @@ require (
k8s.io/utils v0.0.0-20210802155522-efc7438f0176
)
replace github.com/aws/aws-sdk-go/service/eks => github.com/aws/aws-sdk-go/service/eks v1.38.49
replace github.com/digitalocean/godo => github.com/digitalocean/godo v1.27.0
replace github.com/rancher/go-rancher => github.com/rancher/go-rancher v0.1.0

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,40 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
// Package eks provides the client and types for making API
// requests to Amazon Elastic Kubernetes Service.
//
// Amazon Elastic Kubernetes Service (Amazon EKS) is a managed service that
// makes it easy for you to run Kubernetes on AWS without needing to stand up
// or maintain your own Kubernetes control plane. Kubernetes is an open-source
// system for automating the deployment, scaling, and management of containerized
// applications.
//
// Amazon EKS runs up-to-date versions of the open-source Kubernetes software,
// so you can use all the existing plugins and tooling from the Kubernetes community.
// Applications running on Amazon EKS are fully compatible with applications
// running on any standard Kubernetes environment, whether running in on-premises
// data centers or public clouds. This means that you can easily migrate any
// standard Kubernetes application to Amazon EKS without any code modification
// required.
//
// See https://docs.aws.amazon.com/goto/WebAPI/eks-2017-11-01 for more information on this service.
//
// See eks package documentation for more information.
// https://docs.aws.amazon.com/sdk-for-go/api/service/eks/
//
// Using the Client
//
// To contact Amazon Elastic Kubernetes Service with the SDK use the New function to create
// a new service client. With that client you can make API requests to the service.
// These clients are safe to use concurrently.
//
// See the SDK's documentation for more information on how to use the SDK.
// https://docs.aws.amazon.com/sdk-for-go/api/
//
// See aws.Config documentation for more information on configuring SDK clients.
// https://docs.aws.amazon.com/sdk-for-go/api/aws/#Config
//
// See the Amazon Elastic Kubernetes Service client EKS for more
// information on creating client for this service.
// https://docs.aws.amazon.com/sdk-for-go/api/service/eks/#New
package eks

View File

@ -0,0 +1,101 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package eks
import (
"github.com/aws/aws-sdk-go/private/protocol"
)
const (
// ErrCodeBadRequestException for service response error code
// "BadRequestException".
//
// This exception is thrown if the request contains a semantic error. The precise
// meaning will depend on the API, and will be documented in the error message.
ErrCodeBadRequestException = "BadRequestException"
// ErrCodeClientException for service response error code
// "ClientException".
//
// These errors are usually caused by a client action. Actions can include using
// an action or resource on behalf of a user that doesn't have permissions to
// use the action or resource or specifying an identifier that is not valid.
ErrCodeClientException = "ClientException"
// ErrCodeInvalidParameterException for service response error code
// "InvalidParameterException".
//
// The specified parameter is invalid. Review the available parameters for the
// API request.
ErrCodeInvalidParameterException = "InvalidParameterException"
// ErrCodeInvalidRequestException for service response error code
// "InvalidRequestException".
//
// The request is invalid given the state of the cluster. Check the state of
// the cluster and the associated operations.
ErrCodeInvalidRequestException = "InvalidRequestException"
// ErrCodeNotFoundException for service response error code
// "NotFoundException".
//
// A service resource associated with the request could not be found. Clients
// should not retry such requests.
ErrCodeNotFoundException = "NotFoundException"
// ErrCodeResourceInUseException for service response error code
// "ResourceInUseException".
//
// The specified resource is in use.
ErrCodeResourceInUseException = "ResourceInUseException"
// ErrCodeResourceLimitExceededException for service response error code
// "ResourceLimitExceededException".
//
// You have encountered a service limit on the specified resource.
ErrCodeResourceLimitExceededException = "ResourceLimitExceededException"
// ErrCodeResourceNotFoundException for service response error code
// "ResourceNotFoundException".
//
// The specified resource could not be found. You can view your available clusters
// with ListClusters. You can view your available managed node groups with ListNodegroups.
// Amazon EKS clusters and node groups are Region-specific.
ErrCodeResourceNotFoundException = "ResourceNotFoundException"
// ErrCodeServerException for service response error code
// "ServerException".
//
// These errors are usually caused by a server-side issue.
ErrCodeServerException = "ServerException"
// ErrCodeServiceUnavailableException for service response error code
// "ServiceUnavailableException".
//
// The service is unavailable. Back off and retry the operation.
ErrCodeServiceUnavailableException = "ServiceUnavailableException"
// ErrCodeUnsupportedAvailabilityZoneException for service response error code
// "UnsupportedAvailabilityZoneException".
//
// At least one of your specified cluster subnets is in an Availability Zone
// that does not support Amazon EKS. The exception output specifies the supported
// Availability Zones for your account, from which you can choose subnets for
// your cluster.
ErrCodeUnsupportedAvailabilityZoneException = "UnsupportedAvailabilityZoneException"
)
var exceptionFromCode = map[string]func(protocol.ResponseMetadata) error{
"BadRequestException": newErrorBadRequestException,
"ClientException": newErrorClientException,
"InvalidParameterException": newErrorInvalidParameterException,
"InvalidRequestException": newErrorInvalidRequestException,
"NotFoundException": newErrorNotFoundException,
"ResourceInUseException": newErrorResourceInUseException,
"ResourceLimitExceededException": newErrorResourceLimitExceededException,
"ResourceNotFoundException": newErrorResourceNotFoundException,
"ServerException": newErrorServerException,
"ServiceUnavailableException": newErrorServiceUnavailableException,
"UnsupportedAvailabilityZoneException": newErrorUnsupportedAvailabilityZoneException,
}

View File

@ -0,0 +1,104 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package eks
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/client"
"github.com/aws/aws-sdk-go/aws/client/metadata"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/signer/v4"
"github.com/aws/aws-sdk-go/private/protocol"
"github.com/aws/aws-sdk-go/private/protocol/restjson"
)
// EKS provides the API operation methods for making requests to
// Amazon Elastic Kubernetes Service. See this package's package overview docs
// for details on the service.
//
// EKS methods are safe to use concurrently. It is not safe to
// modify mutate any of the struct's properties though.
type EKS struct {
*client.Client
}
// Used for custom client initialization logic
var initClient func(*client.Client)
// Used for custom request initialization logic
var initRequest func(*request.Request)
// Service information constants
const (
ServiceName = "eks" // Name of service.
EndpointsID = ServiceName // ID to lookup a service endpoint with.
ServiceID = "EKS" // ServiceID is a unique identifier of a specific service.
)
// New creates a new instance of the EKS client with a session.
// If additional configuration is needed for the client instance use the optional
// aws.Config parameter to add your extra config.
//
// Example:
// mySession := session.Must(session.NewSession())
//
// // Create a EKS client from just a session.
// svc := eks.New(mySession)
//
// // Create a EKS client with additional configuration
// svc := eks.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
func New(p client.ConfigProvider, cfgs ...*aws.Config) *EKS {
c := p.ClientConfig(EndpointsID, cfgs...)
if c.SigningNameDerived || len(c.SigningName) == 0 {
c.SigningName = "eks"
}
return newClient(*c.Config, c.Handlers, c.PartitionID, c.Endpoint, c.SigningRegion, c.SigningName)
}
// newClient creates, initializes and returns a new service client instance.
func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint, signingRegion, signingName string) *EKS {
svc := &EKS{
Client: client.New(
cfg,
metadata.ClientInfo{
ServiceName: ServiceName,
ServiceID: ServiceID,
SigningName: signingName,
SigningRegion: signingRegion,
PartitionID: partitionID,
Endpoint: endpoint,
APIVersion: "2017-11-01",
},
handlers,
),
}
// Handlers
svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
svc.Handlers.Build.PushBackNamed(restjson.BuildHandler)
svc.Handlers.Unmarshal.PushBackNamed(restjson.UnmarshalHandler)
svc.Handlers.UnmarshalMeta.PushBackNamed(restjson.UnmarshalMetaHandler)
svc.Handlers.UnmarshalError.PushBackNamed(
protocol.NewUnmarshalErrorHandler(restjson.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(),
)
// Run custom client initialization if present
if initClient != nil {
initClient(svc.Client)
}
return svc
}
// newRequest creates a new request for a EKS operation and runs any
// custom request initialization.
func (c *EKS) newRequest(op *request.Operation, params, data interface{}) *request.Request {
req := c.NewRequest(op, params, data)
// Run custom request initialization if present
if initRequest != nil {
initRequest(req)
}
return req
}

View File

@ -0,0 +1,331 @@
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package eks
import (
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
)
// WaitUntilAddonActive uses the Amazon EKS API operation
// DescribeAddon to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *EKS) WaitUntilAddonActive(input *DescribeAddonInput) error {
return c.WaitUntilAddonActiveWithContext(aws.BackgroundContext(), input)
}
// WaitUntilAddonActiveWithContext is an extended version of WaitUntilAddonActive.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *EKS) WaitUntilAddonActiveWithContext(ctx aws.Context, input *DescribeAddonInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilAddonActive",
MaxAttempts: 60,
Delay: request.ConstantWaiterDelay(10 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "addon.status",
Expected: "CREATE_FAILED",
},
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "addon.status",
Expected: "DEGRADED",
},
{
State: request.SuccessWaiterState,
Matcher: request.PathWaiterMatch, Argument: "addon.status",
Expected: "ACTIVE",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeAddonInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeAddonRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilAddonDeleted uses the Amazon EKS API operation
// DescribeAddon to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *EKS) WaitUntilAddonDeleted(input *DescribeAddonInput) error {
return c.WaitUntilAddonDeletedWithContext(aws.BackgroundContext(), input)
}
// WaitUntilAddonDeletedWithContext is an extended version of WaitUntilAddonDeleted.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *EKS) WaitUntilAddonDeletedWithContext(ctx aws.Context, input *DescribeAddonInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilAddonDeleted",
MaxAttempts: 60,
Delay: request.ConstantWaiterDelay(10 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "addon.status",
Expected: "DELETE_FAILED",
},
{
State: request.SuccessWaiterState,
Matcher: request.ErrorWaiterMatch,
Expected: "ResourceNotFoundException",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeAddonInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeAddonRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilClusterActive uses the Amazon EKS API operation
// DescribeCluster to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *EKS) WaitUntilClusterActive(input *DescribeClusterInput) error {
return c.WaitUntilClusterActiveWithContext(aws.BackgroundContext(), input)
}
// WaitUntilClusterActiveWithContext is an extended version of WaitUntilClusterActive.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *EKS) WaitUntilClusterActiveWithContext(ctx aws.Context, input *DescribeClusterInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilClusterActive",
MaxAttempts: 40,
Delay: request.ConstantWaiterDelay(30 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "cluster.status",
Expected: "DELETING",
},
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "cluster.status",
Expected: "FAILED",
},
{
State: request.SuccessWaiterState,
Matcher: request.PathWaiterMatch, Argument: "cluster.status",
Expected: "ACTIVE",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeClusterInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeClusterRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilClusterDeleted uses the Amazon EKS API operation
// DescribeCluster to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *EKS) WaitUntilClusterDeleted(input *DescribeClusterInput) error {
return c.WaitUntilClusterDeletedWithContext(aws.BackgroundContext(), input)
}
// WaitUntilClusterDeletedWithContext is an extended version of WaitUntilClusterDeleted.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *EKS) WaitUntilClusterDeletedWithContext(ctx aws.Context, input *DescribeClusterInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilClusterDeleted",
MaxAttempts: 40,
Delay: request.ConstantWaiterDelay(30 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "cluster.status",
Expected: "ACTIVE",
},
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "cluster.status",
Expected: "CREATING",
},
{
State: request.SuccessWaiterState,
Matcher: request.ErrorWaiterMatch,
Expected: "ResourceNotFoundException",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeClusterInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeClusterRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilNodegroupActive uses the Amazon EKS API operation
// DescribeNodegroup to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *EKS) WaitUntilNodegroupActive(input *DescribeNodegroupInput) error {
return c.WaitUntilNodegroupActiveWithContext(aws.BackgroundContext(), input)
}
// WaitUntilNodegroupActiveWithContext is an extended version of WaitUntilNodegroupActive.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *EKS) WaitUntilNodegroupActiveWithContext(ctx aws.Context, input *DescribeNodegroupInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilNodegroupActive",
MaxAttempts: 80,
Delay: request.ConstantWaiterDelay(30 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "nodegroup.status",
Expected: "CREATE_FAILED",
},
{
State: request.SuccessWaiterState,
Matcher: request.PathWaiterMatch, Argument: "nodegroup.status",
Expected: "ACTIVE",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeNodegroupInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeNodegroupRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}
// WaitUntilNodegroupDeleted uses the Amazon EKS API operation
// DescribeNodegroup to wait for a condition to be met before returning.
// If the condition is not met within the max attempt window, an error will
// be returned.
func (c *EKS) WaitUntilNodegroupDeleted(input *DescribeNodegroupInput) error {
return c.WaitUntilNodegroupDeletedWithContext(aws.BackgroundContext(), input)
}
// WaitUntilNodegroupDeletedWithContext is an extended version of WaitUntilNodegroupDeleted.
// With the support for passing in a context and options to configure the
// Waiter and the underlying request options.
//
// The context must be non-nil and will be used for request cancellation. If
// the context is nil a panic will occur. In the future the SDK may create
// sub-contexts for http.Requests. See https://golang.org/pkg/context/
// for more information on using Contexts.
func (c *EKS) WaitUntilNodegroupDeletedWithContext(ctx aws.Context, input *DescribeNodegroupInput, opts ...request.WaiterOption) error {
w := request.Waiter{
Name: "WaitUntilNodegroupDeleted",
MaxAttempts: 40,
Delay: request.ConstantWaiterDelay(30 * time.Second),
Acceptors: []request.WaiterAcceptor{
{
State: request.FailureWaiterState,
Matcher: request.PathWaiterMatch, Argument: "nodegroup.status",
Expected: "DELETE_FAILED",
},
{
State: request.SuccessWaiterState,
Matcher: request.ErrorWaiterMatch,
Expected: "ResourceNotFoundException",
},
},
Logger: c.Config.Logger,
NewRequest: func(opts []request.Option) (*request.Request, error) {
var inCpy *DescribeNodegroupInput
if input != nil {
tmp := *input
inCpy = &tmp
}
req, _ := c.DescribeNodegroupRequest(inCpy)
req.SetContext(ctx)
req.ApplyOptions(opts...)
return req, nil
},
}
w.ApplyOptions(opts...)
return w.WaitWithContext(ctx)
}

View File

@ -128,6 +128,7 @@ github.com/aws/aws-sdk-go/private/protocol/xml/xmlutil
github.com/aws/aws-sdk-go/service/autoscaling
github.com/aws/aws-sdk-go/service/ec2
github.com/aws/aws-sdk-go/service/ecr
github.com/aws/aws-sdk-go/service/eks
github.com/aws/aws-sdk-go/service/elb
github.com/aws/aws-sdk-go/service/elbv2
github.com/aws/aws-sdk-go/service/kms
@ -1849,6 +1850,7 @@ sigs.k8s.io/structured-merge-diff/v4/typed
sigs.k8s.io/structured-merge-diff/v4/value
# sigs.k8s.io/yaml v1.2.0
sigs.k8s.io/yaml
# github.com/aws/aws-sdk-go/service/eks => github.com/aws/aws-sdk-go/service/eks v1.38.49
# github.com/digitalocean/godo => github.com/digitalocean/godo v1.27.0
# github.com/rancher/go-rancher => github.com/rancher/go-rancher v0.1.0
# k8s.io/api => k8s.io/api v0.23.0-alpha.1