Skip to content

Commit

Permalink
feat(AwsVpcPeering): delete only created routes
Browse files Browse the repository at this point in the history
  • Loading branch information
vandjelk committed Feb 10, 2025
1 parent e116145 commit 0e4cfc5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/kcp/provider/aws/vpcpeering/remoteRoutesDelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"github.com/kyma-project/cloud-manager/pkg/composed"
awsmeta "github.com/kyma-project/cloud-manager/pkg/kcp/provider/aws/meta"
awsutil "github.com/kyma-project/cloud-manager/pkg/kcp/provider/aws/util"
"github.com/kyma-project/cloud-manager/pkg/util"
"k8s.io/utils/ptr"
)
Expand All @@ -24,13 +25,21 @@ func remoteRoutesDelete(ctx context.Context, st composed.State) (error, context.

for _, t := range state.remoteRouteTables {

shouldUpdateRouteTable := awsutil.ShouldUpdateRouteTable(t.Tags,
state.ObjAsVpcPeering().Spec.Details.RemoteRouteTableUpdateStrategy,
state.Scope().Spec.ShootName)

if !shouldUpdateRouteTable {
continue
}

for _, r := range t.Routes {

if ptr.Equal(r.VpcPeeringConnectionId, state.remoteVpcPeering.VpcPeeringConnectionId) {
err := state.remoteClient.DeleteRoute(ctx, t.RouteTableId, r.DestinationCidrBlock)

lll := logger.WithValues(
"routeTableId", ptr.Deref(t.RouteTableId, "xxx"),
"remoteRouteTableId", ptr.Deref(t.RouteTableId, "xxx"),
"destinationCidrBlock", ptr.Deref(r.DestinationCidrBlock, "xxx"),
)

Expand Down

0 comments on commit 0e4cfc5

Please sign in to comment.