Skip to content
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

Configurably request DNS preresolution for load-balanced services #1958

Merged
merged 2 commits into from
Jun 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import javax.validation.Valid;
Expand Down Expand Up @@ -217,6 +219,10 @@ public class SingularityConfiguration extends Configuration {

private Optional<String> taskLabelForLoadBalancerUpstreamGroup = Optional.absent();

private boolean preResolveUpstreamDNS = false;

private Set<String> skipDNSPreResolutionForRequests = new HashSet<>();

private int logFetchMaxThreads = 15;

private int maxDeployIdSize = 50;
Expand Down Expand Up @@ -722,6 +728,22 @@ public String getLoadBalancerUri() {
return loadBalancerUri;
}

public boolean isPreResolveUpstreamDNS() {
return preResolveUpstreamDNS;
}

public void setPreResolveUpstreamDNS(boolean preResolveUpstreamDNS) {
this.preResolveUpstreamDNS = preResolveUpstreamDNS;
}

public Set<String> getSkipDNSPreResolutionForRequests() {
return skipDNSPreResolutionForRequests;
}

public void setSkipDNSPreResolutionForRequests(Set<String> skipDNSPreResolutionForRequests) {
this.skipDNSPreResolutionForRequests = skipDNSPreResolutionForRequests;
}

public int getLogFetchMaxThreads() {
return logFetchMaxThreads;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public class LoadBalancerClientImpl implements LoadBalancerClient {
private final AsyncHttpClient httpClient;
private final ObjectMapper objectMapper;
private final Optional<String> taskLabelForLoadBalancerUpstreamGroup;
private final boolean preResolveUpstreamDNS;
private final Set<String> skipDNSPreResolutionForRequests;
private final MesosProtosUtils mesosProtosUtils;

private static final String OPERATION_URI = "%s/%s";
Expand All @@ -68,6 +70,8 @@ public LoadBalancerClientImpl(SingularityConfiguration configuration, ObjectMapp
this.loadBalancerTimeoutMillis = configuration.getLoadBalancerRequestTimeoutMillis();
this.loadBalancerQueryParams = configuration.getLoadBalancerQueryParams();
this.taskLabelForLoadBalancerUpstreamGroup = configuration.getTaskLabelForLoadBalancerUpstreamGroup();
this.skipDNSPreResolutionForRequests = configuration.getSkipDNSPreResolutionForRequests();
this.preResolveUpstreamDNS = configuration.isPreResolveUpstreamDNS();
this.mesosProtosUtils = mesosProtosUtils;
}

Expand Down Expand Up @@ -208,9 +212,17 @@ public SingularityLoadBalancerUpdate makeAndSendLoadBalancerRequest(LoadBalancer
SingularityDeploy deploy, SingularityRequest request) {
final List<String> serviceOwners = request.getOwners().or(Collections.<String> emptyList());
final Set<String> loadBalancerGroups = deploy.getLoadBalancerGroups().or(Collections.<String>emptySet());

boolean enableDNSPreResolution;
if (skipDNSPreResolutionForRequests.contains(request.getId())) {
enableDNSPreResolution = false;
} else {
enableDNSPreResolution = preResolveUpstreamDNS;
}

final BaragonService lbService = new BaragonService(deploy.getLoadBalancerServiceIdOverride().or(request.getId()), serviceOwners, deploy.getServiceBasePath().get(),
deploy.getLoadBalancerAdditionalRoutes().or(Collections.<String>emptyList()), loadBalancerGroups, deploy.getLoadBalancerOptions().orNull(),
deploy.getLoadBalancerTemplate(), deploy.getLoadBalancerDomains().or(Collections.<String>emptySet()));
deploy.getLoadBalancerTemplate(), deploy.getLoadBalancerDomains().or(Collections.<String>emptySet()), Optional.absent(), Collections.emptySet(), enableDNSPreResolution);
final BaragonRequest loadBalancerRequest = new BaragonRequest(loadBalancerRequestId.toString(), lbService, addUpstreams, removeUpstreams, Collections.<UpstreamInfo>emptyList(),Optional.<String>absent(), Optional.of(RequestAction.UPDATE), false, false, false, true);
return sendLoadBalancerRequest(loadBalancerRequestId, loadBalancerRequest, LoadBalancerMethod.ENQUEUE);
}
Expand Down