mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(elbv2): honor disabled Lambda target health checks (#9407)
This commit is contained in:
1 parent
01a42399b0
commit
ba6a81a0d5
13 files changed
+240
-22
No files matched your search
@@ -590,6 +590,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
: defaultHealthCheckProtocol(groupProtocol, groupTargetType);
|
||||
validateLayer7Members(checkProtocol, healthCheckPath, matcher);
|
||||
boolean layer7Check = isHttpProtocol(checkProtocol);
|
||||
validateHealthCheckEnabled(groupTargetType, healthCheckEnabled);
|
||||
Map<String, TargetGroup> regionTgs = targetGroups.computeIfAbsent(region, k -> new ConcurrentHashMap<>());
|
||||
boolean duplicate = regionTgs.values().stream()
|
||||
.anyMatch(tg -> tg.getTargetGroupName().equals(name));
|
||||
@@ -613,7 +614,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
tg.setRegion(region);
|
||||
|
||||
// health check defaults
|
||||
tg.setHealthCheckEnabled(healthCheckEnabled != null ? healthCheckEnabled : true);
|
||||
tg.setHealthCheckEnabled(healthCheckEnabled != null ? healthCheckEnabled : !"lambda".equals(groupTargetType));
|
||||
tg.setHealthCheckProtocol(checkProtocol);
|
||||
tg.setHealthCheckPort(healthCheckPort != null ? healthCheckPort : "traffic-port");
|
||||
tg.setHealthCheckPath(layer7Check ? (healthCheckPath != null ? healthCheckPath : "/") : null);
|
||||
@@ -685,6 +686,7 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
validateHealthCheckTimeout(healthCheckTimeout);
|
||||
TargetGroup tg = requireTargetGroup(region, arn);
|
||||
validateHealthCheckPort(healthCheckPort);
|
||||
validateHealthCheckEnabled(tg.getTargetType(), healthCheckEnabled);
|
||||
validateHealthCheckProtocol(healthCheckProtocol, tg.getProtocol(), tg.getTargetType());
|
||||
String checkProtocol = healthCheckProtocol != null ? healthCheckProtocol : tg.getHealthCheckProtocol();
|
||||
validateLayer7Members(checkProtocol, healthCheckPath, matcher);
|
||||
@@ -778,6 +780,13 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
return "HTTP".equals(protocol) || "HTTPS".equals(protocol);
|
||||
}
|
||||
|
||||
private static void validateHealthCheckEnabled(String targetType, Boolean enabled) {
|
||||
if (Boolean.FALSE.equals(enabled) && !"lambda".equals(targetType)) {
|
||||
throw new AwsException("InvalidConfigurationRequest",
|
||||
"Health check enabled must be true for target groups with target type '" + targetType + "'", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private static void validateHealthCheckTimeout(Integer timeout) {
|
||||
if (timeout != null && (timeout < 2 || timeout > 120)) {
|
||||
String constraint = timeout < 2 ? "greater than or equal to 2" : "less than or equal to 120";
|
||||
@@ -1330,7 +1339,13 @@ public class ElbV2Service implements ResourceProvider, ServerCertificateReferenc
|
||||
th.setTarget(t);
|
||||
if (isLambdaTg) {
|
||||
th.setHealthCheckPort("N/A");
|
||||
th.setState("healthy");
|
||||
if (Boolean.FALSE.equals(tg.getHealthCheckEnabled())) {
|
||||
th.setState("unavailable");
|
||||
th.setReason("Target.HealthCheckDisabled");
|
||||
th.setDescription("Health checks are disabled for the target group");
|
||||
} else {
|
||||
th.setState("healthy");
|
||||
}
|
||||
return th;
|
||||
}
|
||||
int port = ElbV2HealthChecker.effectivePort(t, tg);
|
||||
|
||||
Reference in new issue
Block a user