Skip to content

Commit 4b5d1a7

Browse files
committed
remove the aws-vpc-cache-ttl flag
fix unit tests
1 parent 8f9a502 commit 4b5d1a7

File tree

9 files changed

+16
-27
lines changed

9 files changed

+16
-27
lines changed

docs/deploy/configurations.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ Currently, you can set only 1 namespace to watch in this flag. See [this Kuberne
6767

6868
|Flag | Type | Default | Description |
6969
|---------------------------------------|---------------------------------|-----------------|-------------|
70-
|aws-api-endpoints | AWS API Endpoints Config | | AWS API endpoints mapping, format: serviceID1=URL1,serviceID2=URL2 |
7170
|aws-api-throttle | AWS Throttle Config | [default value](#default-throttle-config ) | throttle settings for AWS APIs, format: serviceID1:operationRegex1=rate:burst,serviceID2:operationRegex2=rate:burst |
7271
|aws-max-retries | int | 10 | Maximum retries for AWS APIs |
7372
|aws-region | string | [instance metadata](#instance-metadata) | AWS Region for the kubernetes cluster |
74-
|aws-vpc-cache-ttl | string | 10m | Length of time in minutes to cache VPC info |
75-
|aws-vpc-id | string | [instance metadata](#instance-metadata) | ID of the AWS VPC where Load Balancer resources will be created |
73+
|aws-vpc-id | string | [instance metadata](#instance-metadata) | AWS VPC ID for the Kubernetes cluster |
74+
|aws-api-endpoints | AWS API Endpoints Config | | AWS API endpoints mapping, format: serviceID1=URL1,serviceID2=URL2 |
7675
|cluster-name | string | | Kubernetes cluster name|
7776
|default-tags | stringMap | | AWS Tags that will be applied to all AWS resources managed by this controller. Specified Tags takes highest priority |
7877
|default-ssl-policy | string | ELBSecurityPolicy-2016-08 | Default SSL Policy that will be applied to all Ingresses or Services that do not have the SSL Policy annotation |

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,6 @@ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh
643643
github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4=
644644
github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM=
645645
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
646-
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
647646
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
648647
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
649648
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ func main() {
103103
sgManager := networking.NewDefaultSecurityGroupManager(cloud.EC2(), ctrl.Log)
104104
sgReconciler := networking.NewDefaultSecurityGroupReconciler(sgManager, ctrl.Log)
105105
azInfoProvider := networking.NewDefaultAZInfoProvider(cloud.EC2(), ctrl.Log.WithName("az-info-provider"))
106-
vpcInfoProvider := networking.NewDefaultVPCInfoProvider(cloud.EC2(), ctrl.Log.WithName("vpc-info-provider"), cloud.VpcCacheTTL())
106+
vpcInfoProvider := networking.NewDefaultVPCInfoProvider(cloud.EC2(), ctrl.Log.WithName("vpc-info-provider"))
107107
subnetResolver := networking.NewDefaultSubnetsResolver(azInfoProvider, cloud.EC2(), cloud.VpcID(), controllerCFG.ClusterName, ctrl.Log.WithName("subnets-resolver"))
108108
vpcResolver := networking.NewDefaultVPCResolver(cloud.EC2(), cloud.VpcID(), ctrl.Log.WithName("vpc-resolver"))
109109
tgbResManager := targetgroupbinding.NewDefaultResourceManager(mgr.GetClient(), cloud.ELBV2(), cloud.EC2(),

pkg/aws/cloud.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package aws
22

33
import (
4-
"time"
5-
64
"github.com/aws/aws-sdk-go/aws"
75
"github.com/aws/aws-sdk-go/aws/endpoints"
86
"github.com/aws/aws-sdk-go/aws/session"
@@ -40,11 +38,8 @@ type Cloud interface {
4038
// Region for the kubernetes cluster
4139
Region() string
4240

43-
// ID of VPC to create load balancers in
41+
// VpcID for the LoadBalancer resources.
4442
VpcID() string
45-
46-
// VPC cache TTL in minutes
47-
VpcCacheTTL() time.Duration
4843
}
4944

5045
// NewCloud constructs new Cloud implementation.
@@ -154,7 +149,3 @@ func (c *defaultCloud) Region() string {
154149
func (c *defaultCloud) VpcID() string {
155150
return c.cfg.VpcID
156151
}
157-
158-
func (c *defaultCloud) VpcCacheTTL() time.Duration {
159-
return c.cfg.VpcCacheTTL
160-
}

pkg/aws/cloud_config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const (
1717
defaultVpcID = ""
1818
defaultRegion = ""
1919
defaultAPIMaxRetries = 10
20-
defaultVpcCacheTTL = time.Minute * 10
2120
)
2221

2322
type CloudConfig struct {
@@ -27,7 +26,7 @@ type CloudConfig struct {
2726
// Throttle settings for AWS APIs
2827
ThrottleConfig *throttle.ServiceOperationsThrottleConfig
2928

30-
// ID of VPC to create load balancers in
29+
// VpcID for the LoadBalancer resources.
3130
VpcID string
3231

3332
// VPC cache TTL in minutes
@@ -43,8 +42,7 @@ type CloudConfig struct {
4342
func (cfg *CloudConfig) BindFlags(fs *pflag.FlagSet) {
4443
fs.StringVar(&cfg.Region, flagAWSRegion, defaultRegion, "AWS Region for the kubernetes cluster")
4544
fs.Var(cfg.ThrottleConfig, flagAWSAPIThrottle, "throttle settings for AWS APIs, format: serviceID1:operationRegex1=rate:burst,serviceID2:operationRegex2=rate:burst")
46-
fs.StringVar(&cfg.VpcID, flagAWSVpcID, defaultVpcID, "AWS ID of VPC to create load balancers in")
47-
fs.DurationVar(&cfg.VpcCacheTTL, flagAWSVpcCacheTTL, defaultVpcCacheTTL, "VPC cache TTL in minutes")
45+
fs.StringVar(&cfg.VpcID, flagAWSVpcID, defaultVpcID, "AWS VpcID for the LoadBalancer resources")
4846
fs.IntVar(&cfg.MaxRetries, flagAWSMaxRetries, defaultAPIMaxRetries, "Maximum retries for AWS APIs")
4947
fs.StringToStringVar(&cfg.AWSEndpoints, flagAWSAPIEndpoints, nil, "Custom AWS endpoint configuration, format: serviceID1=URL1,serviceID2=URL2")
5048
}

pkg/networking/vpc_info_provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,20 @@ import (
1212
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/services"
1313
)
1414

15+
const defaultVPCInfoCacheTTL = 10 * time.Minute
16+
1517
// VPCInfoProvider is responsible for providing VPC info.
1618
type VPCInfoProvider interface {
1719
FetchVPCInfo(ctx context.Context, vpcID string) (*ec2sdk.Vpc, error)
1820
}
1921

2022
// NewDefaultVPCInfoProvider constructs new defaultVPCInfoProvider.
21-
func NewDefaultVPCInfoProvider(ec2Client services.EC2, logger logr.Logger, vpcInfoCacheTTL time.Duration) *defaultVPCInfoProvider {
23+
func NewDefaultVPCInfoProvider(ec2Client services.EC2, logger logr.Logger) *defaultVPCInfoProvider {
2224
return &defaultVPCInfoProvider{
2325
ec2Client: ec2Client,
2426
vpcInfoCache: cache.NewExpiring(),
2527
vpcInfoCacheMutex: sync.RWMutex{},
26-
vpcInfoCacheTTL: vpcInfoCacheTTL,
28+
vpcInfoCacheTTL: defaultVPCInfoCacheTTL,
2729
logger: logger,
2830
}
2931
}

pkg/networking/vpc_info_provider_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package networking
22

33
import (
44
"context"
5-
"reflect"
6-
"testing"
7-
"time"
8-
95
awssdk "github.com/aws/aws-sdk-go/aws"
106
ec2sdk "github.com/aws/aws-sdk-go/service/ec2"
117
gomock "github.com/golang/mock/gomock"
8+
"reflect"
129
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/services"
1310
"sigs.k8s.io/controller-runtime/pkg/log"
11+
"testing"
1412
)
1513

1614
func Test_defaultVPCInfoProvider_FetchVPCInfo(t *testing.T) {
@@ -63,7 +61,7 @@ func Test_defaultVPCInfoProvider_FetchVPCInfo(t *testing.T) {
6361
defer ctrl.Finish()
6462

6563
ec2Client := services.NewMockEC2(ctrl)
66-
p := NewDefaultVPCInfoProvider(ec2Client, &log.NullLogger{}, 10*time.Minute)
64+
p := NewDefaultVPCInfoProvider(ec2Client, &log.NullLogger{})
6765

6866
for _, tt := range tests {
6967
t.Run(tt.name, func(t *testing.T) {

pkg/targetgroupbinding/resource_manager.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"k8s.io/apimachinery/pkg/types"
2222
"k8s.io/apimachinery/pkg/util/sets"
2323
"k8s.io/apimachinery/pkg/util/strategicpatch"
24-
"k8s.io/client-go/tools/record"
2524
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
2625
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/services"
2726
"sigs.k8s.io/aws-load-balancer-controller/pkg/backend"

pkg/targetgroupbinding/resource_manager_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,9 @@ func Test_isELBV2TargetInELBVPC(t *testing.T) {
507507
v := &ec2sdk.Vpc{
508508
CidrBlock: awssdk.String("192.168.1.0/24"),
509509
CidrBlockAssociationSet: []*ec2sdk.VpcCidrBlockAssociation{
510+
{
511+
CidrBlock: awssdk.String("192.168.1.0/24"),
512+
},
510513
{
511514
CidrBlock: awssdk.String("10.10.10.0/24"),
512515
},

0 commit comments

Comments
 (0)