Skip to content

Commit

Permalink
aws cleaner: remove cluster at start
Browse files Browse the repository at this point in the history
Initial implementation assumption was that cluster should be removed
at the end of the cleanup proccess. This allows to restart cleanup
proccess from scratch in case of dependency cleanup issues.

But for some EKS setups we might have ENIs attached directly to a cluster.
That blocks VPC deletion while ENIs exist. The ENIs are deleted
automatically after cluster deletion.
So, I moved cluster drop to the beginning of the proccess.
  • Loading branch information
viktor-kurchenko committed Nov 7, 2024
1 parent e5b88b0 commit 3fdc4b0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/aws/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ func DeleteResources(ctx context.Context, accounts []dto.Account, tries int, ret
break
}
}
if err == nil {
logger.Info("deleting cluster")
err = deleteEKS(ctx, cls.EKS, clusterName)
}
return err
})
}
Expand All @@ -55,6 +51,12 @@ func DeleteResources(ctx context.Context, accounts []dto.Account, tries int, ret
func deleteVpcAndEks(ctx context.Context, clients *clients, vpcID, clusterName string) error {
logger := log.FromContext(ctx)
var errs error

logger.Info("deleting cluster")
if err := deleteEKS(ctx, clients.EKS, clusterName); err != nil {
errs = multierr.Append(errs, err)
}

logger.Info("listing vpc peering connections")
connections, err := listVpcPeeringConnections(ctx, clients.EC2, vpcID)
if err != nil {
Expand Down

0 comments on commit 3fdc4b0

Please sign in to comment.