refactor(elbv2): compare DescribeTargetHealth's targets through sameTarget (#8246)

DescribeTargetHealth checked a Targets filter against the registered
targets by comparing the Id and effective port itself. It now uses
ElbV2HealthChecker.sameTarget, as RegisterTargets and DeregisterTargets
do since #8199, so all three tell registrations apart the same way.
No behaviour change.
This commit is contained in:
Suja Shaj authored and GitHub committed 2026-11-13 22:29:53 -04:00
1 parent 3e02ff995f
commit 55a7d95146
2 files changed
+18 -4

No files matched your search

@@ -1157,7 +1157,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
}
int port = ElbV2HealthChecker.effectivePort(t, tg);
th.setHealthCheckPort(String.valueOf(port));
if (hasFilterTargets && !isRegisteredTarget(tg, t, port)) {
if (hasFilterTargets && !isRegisteredTarget(tg, t)) {
th.setState("unused");
th.setReason("Target.NotRegistered");
th.setDescription("Target is not registered to the target group");
@@ -1171,10 +1171,9 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
}).collect(Collectors.toList());
}
private static boolean isRegisteredTarget(TargetGroup targetGroup, TargetDescription candidate, int candidatePort) {
private static boolean isRegisteredTarget(TargetGroup targetGroup, TargetDescription candidate) {
return targetGroup.getTargets().stream()
.anyMatch(registered -> Objects.equals(registered.getId(), candidate.getId())
&& ElbV2HealthChecker.effectivePort(registered, targetGroup) == candidatePort);
.anyMatch(registered -> ElbV2HealthChecker.sameTarget(registered, candidate, targetGroup));
}
// ── Tags ──────────────────────────────────────────────────────────────────