Skip to content

Commit

Permalink
Give all EC2 managed resoruces a 3 minute creation grace period
Browse files Browse the repository at this point in the history
This means we'll wait three minutes from the time a resource was most recently
created before we trust the EC2 API if/when it indicates the resource doesn't
exist.

Signed-off-by: Nic Cope <[email protected]>
  • Loading branch information
negz committed Sep 8, 2021
1 parent 8514cc4 commit 4b46060
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/ec2/address/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package address
import (
"context"
"sort"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -66,6 +67,7 @@ func SetupAddress(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter)
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.AddressGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient()}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithConnectionPublishers(),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient()), &tagger{kube: mgr.GetClient()}),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/internetgateway/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package internetgateway

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -67,6 +68,7 @@ func SetupInternetGateway(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateL
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.InternetGatewayGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewInternetGatewayClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())),
managed.WithConnectionPublishers(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/natgateway/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package natgateway

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -47,6 +48,7 @@ func SetupNatGateway(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimite
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.NATGatewayGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewNatGatewayClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())),
managed.WithConnectionPublishers(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/routetable/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package routetable

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -71,6 +72,7 @@ func SetupRouteTable(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimite
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.RouteTableGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewRouteTableClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())),
managed.WithConnectionPublishers(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/securitygroup/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package securitygroup

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -73,6 +74,7 @@ func SetupSecurityGroup(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLim
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.SecurityGroupGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewSecurityGroupClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())),
managed.WithConnectionPublishers(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/subnet/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package subnet

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -64,6 +65,7 @@ func SetupSubnet(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter) e
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.SubnetGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewSubnetClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())),
managed.WithConnectionPublishers(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/vpc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package vpc
import (
"context"
"sort"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -67,6 +68,7 @@ func SetupVPC(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter) erro
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.VPCGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewVPCClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithConnectionPublishers(),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient()), &tagger{kube: mgr.GetClient()}),
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/ec2/vpccidrblock/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package vpccidrblock

import (
"context"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -60,6 +61,7 @@ func SetupVPCCIDRBlock(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimi
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1alpha1.VPCCIDRBlockGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), newClientFn: ec2.NewVPCCIDRBlockClient}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithConnectionPublishers(),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient())),
Expand Down

0 comments on commit 4b46060

Please sign in to comment.