From 77391c6e58599b2106f4293bdc595de24f1b8e0d Mon Sep 17 00:00:00 2001 From: Samuel Esposito <40698384+samuel-esp@users.noreply.github.com> Date: Mon, 30 Jun 2025 20:27:44 +0200 Subject: [PATCH] fix: correctly assign health check protocol when annotation value is lowercase --- pkg/providers/v1/aws_loadbalancer.go | 4 ++-- pkg/providers/v1/aws_test.go | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/providers/v1/aws_loadbalancer.go b/pkg/providers/v1/aws_loadbalancer.go index 9b0fd9985e..9080395f1b 100644 --- a/pkg/providers/v1/aws_loadbalancer.go +++ b/pkg/providers/v1/aws_loadbalancer.go @@ -1385,7 +1385,7 @@ func (c *Cloud) ensureLoadBalancerHealthCheck(ctx context.Context, loadBalancer actual := loadBalancer.HealthCheck // Override healthcheck protocol, port and path based on annotations if s, ok := annotations[ServiceAnnotationLoadBalancerHealthCheckProtocol]; ok { - protocol = s + protocol = strings.ToUpper(s) } if s, ok := annotations[ServiceAnnotationLoadBalancerHealthCheckPort]; ok && s != defaultHealthCheckPort { p, err := strconv.ParseInt(s, 10, 0) @@ -1394,7 +1394,7 @@ func (c *Cloud) ensureLoadBalancerHealthCheck(ctx context.Context, loadBalancer } port = int32(p) } - switch strings.ToUpper(protocol) { + switch protocol { case "HTTP", "HTTPS": if path == "" { path = defaultHealthCheckPath diff --git a/pkg/providers/v1/aws_test.go b/pkg/providers/v1/aws_test.go index 1feb780fc9..69a823f869 100644 --- a/pkg/providers/v1/aws_test.go +++ b/pkg/providers/v1/aws_test.go @@ -2192,6 +2192,19 @@ func TestEnsureLoadBalancerHealthCheck(t *testing.T) { Target: aws.String("TCP:8080"), }, }, + { + name: "healthcheck protocol written lowercase should be converted to uppercase", + annotations: map[string]string{ + ServiceAnnotationLoadBalancerHealthCheckProtocol: "tcp", + }, + want: elbtypes.HealthCheck{ + HealthyThreshold: aws.Int32(2), + UnhealthyThreshold: aws.Int32(6), + Timeout: aws.Int32(5), + Interval: aws.Int32(10), + Target: aws.String("TCP:8080"), + }, + }, } lbName := "myLB" // this HC will always differ from the expected HC and thus it is expected an