Skip to content

Commit

Permalink
fix(aws): Add support to enable connection termination on deregistrat…
Browse files Browse the repository at this point in the history
…ion for NLB (#5178)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
aravindmd and mergify[bot] committed Jan 12, 2021
1 parent 0d8bf67 commit c86a270
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ public static class Attributes {
private String stickinessType;
private Integer stickinessDuration;
private Boolean proxyProtocolV2;
private Boolean deregistrationDelayConnectionTermination;

/** The following attribute is supported only if the target is a Lambda function. */
private Boolean multiValueHeadersEnabled;

Expand Down Expand Up @@ -386,6 +388,15 @@ public Boolean getMultiValueHeadersEnabled() {
public void setMultiValueHeadersEnabled(Boolean multiValueHeadersEnabled) {
this.multiValueHeadersEnabled = multiValueHeadersEnabled;
}

public Boolean getDeregistrationDelayConnectionTermination() {
return deregistrationDelayConnectionTermination;
}

public void setDeregistrationDelayConnectionTermination(
Boolean deregistrationDelayConnectionTermination) {
this.deregistrationDelayConnectionTermination = deregistrationDelayConnectionTermination;
}
}

public static class RuleCondition {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class LoadBalancerV2UpsertHandler {
private static final String STICKINESS_TYPE = "lb_cookie"
private static final String STICKINESS_DURATION = "86400"
private static final Boolean PROXY_PROTOCOL_V2 = false
private static final Boolean CONNECTION_TERMINATION = false
/** The following attribute is supported only if the target is a Lambda function. */
private static final Boolean MULTI_VALUE_HEADERS_ENABLED = false

Expand Down Expand Up @@ -78,6 +79,9 @@ class LoadBalancerV2UpsertHandler {
def proxyProtocolV2Attribute = attributes.proxyProtocolV2 ?: PROXY_PROTOCOL_V2
targetGroupAttributes.add(new TargetGroupAttribute(key: "proxy_protocol_v2.enabled", value: proxyProtocolV2Attribute))

def enableConnectionTermination = attributes.deregistrationDelayConnectionTermination ?: CONNECTION_TERMINATION
targetGroupAttributes.add(new TargetGroupAttribute(key: "deregistration_delay.connection_termination.enabled", value: enableConnectionTermination))

}
}
return updateTargetGroupAttributes(loadBalancing, targetGroup, targetGroupAttributes)
Expand Down Expand Up @@ -113,6 +117,11 @@ class LoadBalancerV2UpsertHandler {
if (attributes.proxyProtocolV2 != null) {
targetGroupAttributes.add(new TargetGroupAttribute(key: "proxy_protocol_v2.enabled", value: attributes.proxyProtocolV2))
}

if(attributes.deregistrationDelayConnectionTermination != null) {
targetGroupAttributes.add(new TargetGroupAttribute(key: "deregistration_delay.connection_termination.enabled", value: attributes.deregistrationDelayConnectionTermination))
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ class UpsertAmazonLoadBalancerV2AtomicOperationSpec extends Specification {
1 * loadBalancing.modifyTargetGroupAttributes(_) >> { ModifyTargetGroupAttributesRequest request ->
assert request.attributes.find { it.key == 'deregistration_delay.timeout_seconds' }.value == "300"
assert request.attributes.find { it.key == 'proxy_protocol_v2.enabled' }.withValue("false")
assert request.attributes.find { it.key == 'deregistration_delay.connection_termination.enabled' }.withValue("false")
assert request.targetGroupArn == "test:target:group:arn"
return new ModifyTargetGroupAttributesResult()
}
Expand Down

0 comments on commit c86a270

Please sign in to comment.