Skip to content

Commit

Permalink
disassociate secondary CIDR after subnets are deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankitasw committed Mar 30, 2022
1 parent 760e4e7 commit f6a4928
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,8 @@ func (t Template) ControllersPolicyEKS() *iamv1.PolicyDocument {
Effect: iamv1.EffectAllow,
}, {
Action: iamv1.Actions{
"ec2:AssociateVpcCidrBlock",
"ec2:DisassociateVpcCidrBlock",
"eks:ListAddons",
"eks:CreateAddon",
"eks:DescribeAddonVersions",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ Resources:
- arn:*:eks:*:*:cluster/*
- arn:*:eks:*:*:nodegroup/*/*/*
- Action:
- ec2:AssociateVpcCidrBlock
- ec2:DisassociateVpcCidrBlock
- eks:ListAddons
- eks:CreateAddon
- eks:DescribeAddonVersions
Expand Down
14 changes: 7 additions & 7 deletions pkg/cloud/services/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,6 @@ func (s *Service) DeleteNetwork() (err error) {

vpc.DeepCopyInto(s.scope.VPC())

// Secondary CIDR
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.SecondaryCidrsReadyCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
if err := s.disassociateSecondaryCidr(); err != nil {
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.SecondaryCidrsReadyCondition, "DisassociateFailed", clusterv1.ConditionSeverityWarning, err.Error())
return err
}

// Routing tables.
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.RouteTablesReadyCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
if err := s.scope.PatchObject(); err != nil {
Expand Down Expand Up @@ -151,6 +144,13 @@ func (s *Service) DeleteNetwork() (err error) {
}
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.SubnetsReadyCondition, clusterv1.DeletedReason, clusterv1.ConditionSeverityInfo, "")

// Secondary CIDR.
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.SecondaryCidrsReadyCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
if err := s.disassociateSecondaryCidr(); err != nil {
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.SecondaryCidrsReadyCondition, "DisassociateFailed", clusterv1.ConditionSeverityWarning, err.Error())
return err
}

// VPC.
conditions.MarkFalse(s.scope.InfraCluster(), infrav1.VpcReadyCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
if err := s.scope.PatchObject(); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ spec:
identityRef:
kind: AWSClusterStaticIdentity
name: e2e-account
secondaryCidrBlock: 100.64.0.0/16

0 comments on commit f6a4928

Please sign in to comment.