Skip to content

Commit 36eb574

Browse files
shoekstraM00nF1sh
authored andcommitted
Change VPC cache duration to 10m
Also switched cache value to be time.Duration from int. Signed-off-by: Stephen Hoekstra <[email protected]>
1 parent 556acb7 commit 36eb574

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

docs/deploy/configurations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Currently, you can set only 1 namespace to watch in this flag. See [this Kuberne
7171
|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 |
7272
|aws-max-retries | int | 10 | Maximum retries for AWS APIs |
7373
|aws-region | string | [instance metadata](#instance-metadata) | AWS Region for the kubernetes cluster |
74-
|aws-vpc-cache-duration | string | 5 | Length of time in minutes to cache VPC info |
74+
|aws-vpc-cache-duration | string | 10m | Length of time in minutes to cache VPC info |
7575
|aws-vpc-id | string | [instance metadata](#instance-metadata) | ID of the AWS VPC where Load Balancer resources will be created |
7676
|cluster-name | string | | Kubernetes cluster name|
7777
|default-tags | stringMap | | AWS Tags that will be applied to all AWS resources managed by this controller. Specified Tags takes highest priority |

pkg/aws/cloud.go

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

33
import (
4+
"time"
5+
46
"github.com/aws/aws-sdk-go/aws"
57
"github.com/aws/aws-sdk-go/aws/endpoints"
68
"github.com/aws/aws-sdk-go/aws/session"
@@ -42,7 +44,7 @@ type Cloud interface {
4244
VpcID() string
4345

4446
// VPC cache duration in minutes
45-
VpcCacheDuration() int
47+
VpcCacheDuration() time.Duration
4648
}
4749

4850
// NewCloud constructs new Cloud implementation.
@@ -153,6 +155,6 @@ func (c *defaultCloud) VpcID() string {
153155
return c.cfg.VpcID
154156
}
155157

156-
func (c *defaultCloud) VpcCacheDuration() int {
158+
func (c *defaultCloud) VpcCacheDuration() time.Duration {
157159
return c.cfg.VpcCacheDuration
158160
}

pkg/aws/cloud_config.go

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

33
import (
4+
"time"
5+
46
"github.com/spf13/pflag"
57
"sigs.k8s.io/aws-load-balancer-controller/pkg/aws/throttle"
68
)
@@ -15,7 +17,7 @@ const (
1517
defaultVpcID = ""
1618
defaultRegion = ""
1719
defaultAPIMaxRetries = 10
18-
defaultVpcCacheDuration = 5
20+
defaultVpcCacheDuration = time.Minute * 10
1921
)
2022

2123
type CloudConfig struct {
@@ -29,7 +31,7 @@ type CloudConfig struct {
2931
VpcID string
3032

3133
// VPC cache duration in minutes
32-
VpcCacheDuration int
34+
VpcCacheDuration time.Duration
3335

3436
// Max retries configuration for AWS APIs
3537
MaxRetries int
@@ -42,7 +44,7 @@ func (cfg *CloudConfig) BindFlags(fs *pflag.FlagSet) {
4244
fs.StringVar(&cfg.Region, flagAWSRegion, defaultRegion, "AWS Region for the kubernetes cluster")
4345
fs.Var(cfg.ThrottleConfig, flagAWSAPIThrottle, "throttle settings for AWS APIs, format: serviceID1:operationRegex1=rate:burst,serviceID2:operationRegex2=rate:burst")
4446
fs.StringVar(&cfg.VpcID, flagAWSVpcID, defaultVpcID, "AWS ID of VPC to create load balancers in")
45-
fs.IntVar(&cfg.VpcCacheDuration, flagAWSVpcCacheDuration, defaultVpcCacheDuration, "VPC cache duration in minutes")
47+
fs.DurationVar(&cfg.VpcCacheDuration, flagAWSVpcCacheDuration, defaultVpcCacheDuration, "VPC cache duration in minutes")
4648
fs.IntVar(&cfg.MaxRetries, flagAWSMaxRetries, defaultAPIMaxRetries, "Maximum retries for AWS APIs")
4749
fs.StringToStringVar(&cfg.AWSEndpoints, flagAWSAPIEndpoints, nil, "Custom AWS endpoint configuration, format: serviceID1=URL1,serviceID2=URL2")
4850
}

pkg/networking/vpc_info_provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type VPCInfoProvider interface {
1818
}
1919

2020
// NewDefaultVPCInfoProvider constructs new defaultVPCInfoProvider.
21-
func NewDefaultVPCInfoProvider(cacheDuration int, ec2Client services.EC2, logger logr.Logger) *defaultVPCInfoProvider {
21+
func NewDefaultVPCInfoProvider(cacheDuration time.Duration, ec2Client services.EC2, logger logr.Logger) *defaultVPCInfoProvider {
2222
return &defaultVPCInfoProvider{
2323
ec2Client: ec2Client,
2424
vpcInfoCache: cache.New(time.Duration(cacheDuration)*time.Minute, 10*time.Minute),

pkg/networking/vpc_info_provider_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"reflect"
66
"testing"
7+
"time"
78

89
awssdk "github.com/aws/aws-sdk-go/aws"
910
ec2sdk "github.com/aws/aws-sdk-go/service/ec2"
@@ -62,7 +63,7 @@ func Test_defaultVPCInfoProvider_FetchVPCInfo(t *testing.T) {
6263
defer ctrl.Finish()
6364

6465
ec2Client := services.NewMockEC2(ctrl)
65-
p := NewDefaultVPCInfoProvider(5, ec2Client, &log.NullLogger{})
66+
p := NewDefaultVPCInfoProvider(10*time.Minute, ec2Client, &log.NullLogger{})
6667

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

0 commit comments

Comments
 (0)