Skip to content

ingress-controller: update ingresses only if the load balancer is active #748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

madumalt
Copy link
Collaborator

@madumalt madumalt commented Jun 16, 2025

As per the existing behavior, once the stack update completes, the ingress controller immediately updates the status of all ingresses and routegroups to reference the new load balancer. This update may sometimes happens before the new load balancer has marked its targets (skipper-ingress) as healthy, leading clients being routed to a load balancer that is not ready to serve traffic yet.

To improve this behavior we retrieve the ELBs via AWS API and build the models including the ELB states of the corresponding ELBs. Then before updating the ingresses/routegroups (updateIngress func) we check whether the ELB is in active state, if not we skip updating the ingresses/routegroups status with the ELB hostname.

@madumalt
Copy link
Collaborator Author

👍

aws/cf.go Outdated
var nextToken *string

for {
resp, err := svc.ListStackResources(ctx, &cloudformation.ListStackResourcesInput{
Copy link
Member

@AlexanderYastrebov AlexanderYastrebov Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we do another API call (or maybe even several) to get loadbalancer ARN. I think we could store it in the stack output like we do for LoadBalancerDNSName and target group ARNs so that we have it right after FindManagedStacks without extra API calls.

Copy link
Member

@AlexanderYastrebov AlexanderYastrebov Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We we still want to use API call then we should use describe-stack-resource instead of listing all resources and filtering on client side

$ aws cloudformation describe-stack-resource --stack-name=$STACK_ANME --logical-resource-id LB

Copy link
Collaborator Author

@madumalt madumalt Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the LoadBalancerARN in the output section of the Cloudformation Stack Template.

As per this reddit post, without updating a resource an update to an output is not effective.

I wonder how can we overcome this issue. maybe by doing some dummy update to the stack?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trick: add an AWS Tag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trick: add an AWS Tag.

Tested the changes in teapot, we do not need to trigger stack update. The template get updated and when we query the AWS API then we get the output with the new the field. All good!

@madumalt madumalt force-pushed the update-ingress-only-if-elb-is-ready-to-serve branch from 1fee90b to b761926 Compare June 18, 2025 05:53
paginator := elbv2.NewDescribeLoadBalancersPaginator(
a.elbv2,
&elbv2.DescribeLoadBalancersInput{
LoadBalancerArns: lbARNs,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if we have more than 20 ARNs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paginator takes care of it if I'm not mistaken. This is the way it was done with the stacks retrieval, I guess the same limitation applies there as well right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check this anyways

As per the existing behavior, once the stack update completes, the
ingress controller immediately updates the status of all ingresses and
routegroups to reference the new load balancer. This update may
sometimes happens before the new load balancer has marked its targets
(skipper-ingress) as healthy, leading clients being routed to a load
balancer that is not ready to serve traffic yet.

To improve this behavior we retrieve the ELBs via aws api and build
the models including the ELB state of the corresponding ELB. Then
before updating the ingresses/routegroups (updateIngress func) we
check whether the ELB is in active state, if not we skip updating
the ingresses/routegroups status with the ELB hostname.

Signed-off-by: Thilina Madumal <[email protected]>
@madumalt madumalt force-pushed the update-ingress-only-if-elb-is-ready-to-serve branch from b761926 to 2c63caf Compare June 18, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants