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

The zoo is under new management (zk cleanup) #1922

Merged
merged 41 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1566cfa
Pull in HTTP2-capable client.
baconmania Apr 26, 2018
b17afad
Add & document new protocol options.
baconmania Apr 26, 2018
9ab089a
Bind client.
baconmania Apr 26, 2018
2c55771
Don't directly implement Ning-specific handler.
baconmania Apr 26, 2018
cb64ac2
Wrap handler & perform healthcheck using appropriate client.
baconmania Apr 26, 2018
8435dda
Manage this dependency here until it's moved to basepom.
baconmania May 12, 2018
6062442
Add managed client which closes underlying resources at shutdown.
baconmania May 12, 2018
4de7bbe
Bind managed client.
baconmania May 12, 2018
9e05566
Configure client before calling healthcheck.
baconmania May 12, 2018
2e96899
Add enum for supported healthcheck methods.
baconmania May 12, 2018
8c5f0d0
Wire up healthcheck method in options object.
baconmania May 12, 2018
260df36
Add new healthcheck parameter to builder.
baconmania May 12, 2018
da22938
Respect configured healthcheck method.
baconmania May 12, 2018
2a54acb
Satisfy this constructor via deprecated deploy healthcheck options co…
baconmania May 12, 2018
9b15faf
Update equals()
baconmania May 14, 2018
dd9f98c
Merge branch 'master' into http2-healthchecks
baconmania May 14, 2018
54f100c
Re-sync with master.
baconmania May 16, 2018
f8ae2e3
UI support.
baconmania Jun 11, 2018
ba3cecd
Make Singularity report byte counts to monitor against jute buffer size
ssalinas Mar 14, 2019
d9c4dbf
migration to clean old zk nodes, namespace active tasks, namespace pe…
ssalinas Apr 22, 2019
d6d4b8e
test fixing, test migration
ssalinas Apr 22, 2019
f671687
do this at the end
ssalinas Apr 22, 2019
545224d
bump dep versions
ssalinas Apr 22, 2019
d5a1dac
fix ning async update
ssalinas Apr 22, 2019
255de95
more test fixing form ning update
ssalinas Apr 22, 2019
0bb47e7
auto-clean request groups
ssalinas Apr 22, 2019
9465b08
also clean existing
ssalinas Apr 22, 2019
f29b402
cleaner
ssalinas Apr 22, 2019
d84badd
actually leader cache slave and rack data, and actually use it
ssalinas Apr 22, 2019
5e3b05d
Add automatic cleanup of inactive hosts list
ssalinas Apr 22, 2019
2efa6df
merge http2 healthcheck PR in to avoid merge conflicts
ssalinas Apr 22, 2019
fa432ca
clear old slave history entries as well
ssalinas Apr 22, 2019
0b2db9c
Merge branch 'zk_bytes_metrics' into general_zk_cleanup
ssalinas Apr 22, 2019
123a669
remove task id bytes calc
ssalinas Apr 22, 2019
fe0565e
bump zk back down to 3.4.x
ssalinas Apr 22, 2019
fc2e60a
older curator-test version
ssalinas Apr 22, 2019
1ef26f9
fix pending path parent calc
ssalinas Apr 22, 2019
3148ed9
check zk migrations before filling leader cache
ssalinas Apr 22, 2019
0131f00
turn down test log level
ssalinas Apr 22, 2019
8c9ae8e
better fallback to zk from leader cache
ssalinas Apr 22, 2019
e7231c7
fix for PR comments
ssalinas Apr 25, 2019
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 @@ -9,6 +9,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.hubspot.singularity.HealthcheckMethod;
import com.hubspot.singularity.HealthcheckProtocol;

import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -20,6 +21,7 @@ public class HealthcheckOptions {
private final Optional<Integer> portIndex;
private final Optional<Long> portNumber;
private final Optional<HealthcheckProtocol> protocol;
private final Optional<HealthcheckMethod> method;
private final Optional<Integer> startupTimeoutSeconds;
private final Optional<Integer> startupDelaySeconds;
private final Optional<Integer> startupIntervalSeconds;
Expand All @@ -34,6 +36,7 @@ public HealthcheckOptions(@JsonProperty("uri") Optional<String> uri,
@JsonProperty("portIndex") Optional<Integer> portIndex,
@JsonProperty("portNumber") Optional<Long> portNumber,
@JsonProperty("protocol") Optional<HealthcheckProtocol> protocol,
@JsonProperty("method") Optional<HealthcheckMethod> method,
@JsonProperty("startupTimeoutSeconds") Optional<Integer> startupTimeoutSeconds,
@JsonProperty("startupDelaySeconds") Optional<Integer> startupDelaySeconds,
@JsonProperty("startupIntervalSeconds") Optional<Integer> startupIntervalSeconds,
Expand All @@ -46,6 +49,7 @@ public HealthcheckOptions(@JsonProperty("uri") Optional<String> uri,
this.portIndex = portIndex;
this.portNumber = portNumber;
this.protocol = protocol;
this.method = method;
this.startupTimeoutSeconds = startupTimeoutSeconds;
this.startupDelaySeconds = startupDelaySeconds;
this.startupIntervalSeconds = startupIntervalSeconds;
Expand All @@ -59,7 +63,9 @@ public HealthcheckOptions(@JsonProperty("uri") Optional<String> uri,
public HealthcheckOptions(String uri,
Optional<Integer> portIndex,
Optional<Long> portNumber,
Optional<HealthcheckProtocol> protocol,Optional<Integer> startupTimeoutSeconds,
Optional<HealthcheckProtocol> protocol,
Optional<HealthcheckMethod> method,
Optional<Integer> startupTimeoutSeconds,
Optional<Integer> startupDelaySeconds,
Optional<Integer> startupIntervalSeconds,
Optional<Integer> intervalSeconds,
Expand All @@ -71,6 +77,7 @@ public HealthcheckOptions(String uri,
this.portIndex = portIndex;
this.portNumber = portNumber;
this.protocol = protocol;
this.method = method;
this.startupTimeoutSeconds = startupTimeoutSeconds;
this.startupDelaySeconds = startupDelaySeconds;
this.startupIntervalSeconds = startupIntervalSeconds;
Expand All @@ -87,6 +94,7 @@ public HealthcheckOptionsBuilder toBuilder() {
.setPortIndex(portIndex)
.setPortNumber(portNumber)
.setProtocol(protocol)
.setMethod(method)
.setStartupTimeoutSeconds(startupTimeoutSeconds)
.setStartupDelaySeconds(startupDelaySeconds)
.setStartupIntervalSeconds(startupIntervalSeconds)
Expand All @@ -102,7 +110,7 @@ public Optional<String> getUri() {
return uri;
}

@Schema(description = "Perform healthcheck on this dynamically allocated port (e.g. 0 for first port), defaults to first port")
@Schema(description = "Perform healthcheck on this dynamically allocated port (e.g. 0 for first port); defaults to first port")
public Optional<Integer> getPortIndex() {
return portIndex;
}
Expand All @@ -112,11 +120,16 @@ public Optional<Long> getPortNumber() {
return portNumber;
}

@Schema(description = "Healthcheck protocol - HTTP or HTTPS")
@Schema(description = "Healthcheck protocol - HTTP or HTTPS for HTTP/1, HTTP2 or HTTPS2 for HTTP/2")
public Optional<HealthcheckProtocol> getProtocol() {
return protocol;
}

@Schema(description ="Healthcheck HTTP method - GET or POST; GET by default")
public Optional<HealthcheckMethod> getMethod() {
return method;
}

@Schema(description = "Consider the task unhealthy/failed if the app has not started responding to healthchecks in this amount of time")
public Optional<Integer> getStartupTimeoutSeconds() {
return startupTimeoutSeconds;
Expand Down Expand Up @@ -170,6 +183,7 @@ public boolean equals(Object o) {
Objects.equals(portIndex, that.portIndex) &&
Objects.equals(portNumber, that.portNumber) &&
Objects.equals(protocol, that.protocol) &&
Objects.equals(method, that.method) &&
Objects.equals(startupTimeoutSeconds, that.startupTimeoutSeconds) &&
Objects.equals(startupDelaySeconds, that.startupDelaySeconds) &&
Objects.equals(startupIntervalSeconds, that.startupIntervalSeconds) &&
Expand All @@ -182,7 +196,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes, healthcheckResultFilePath);
return Objects.hash(uri, portIndex, portNumber, protocol, method, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes, healthcheckResultFilePath);
}

@Override
Expand All @@ -192,6 +206,7 @@ public String toString() {
", portIndex=" + portIndex +
", portNumber=" + portNumber +
", protocol=" + protocol +
", method=" + method +
", startupTimeoutSeconds=" + startupTimeoutSeconds +
", startupDelaySeconds=" + startupDelaySeconds +
", startupIntervalSeconds=" + startupIntervalSeconds +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.validation.constraints.NotNull;

import com.google.common.base.Optional;
import com.hubspot.singularity.HealthcheckMethod;
import com.hubspot.singularity.HealthcheckProtocol;

public class HealthcheckOptionsBuilder {
Expand All @@ -14,6 +15,7 @@ public class HealthcheckOptionsBuilder {
private Optional<Integer> portIndex;
private Optional<Long> portNumber;
private Optional<HealthcheckProtocol> protocol;
private Optional<HealthcheckMethod> method;
private Optional<Integer> startupTimeoutSeconds;
private Optional<Integer> startupDelaySeconds;
private Optional<Integer> startupIntervalSeconds;
Expand All @@ -32,6 +34,7 @@ public HealthcheckOptionsBuilder(Optional<String> uri) {
this.portIndex = Optional.absent();
this.portNumber = Optional.absent();
this.protocol = Optional.absent();
this.method = Optional.absent();
this.startupTimeoutSeconds = Optional.absent();
this.startupDelaySeconds = Optional.absent();
this.startupIntervalSeconds = Optional.absent();
Expand Down Expand Up @@ -78,6 +81,15 @@ public HealthcheckOptionsBuilder setProtocol(Optional<HealthcheckProtocol> proto
return this;
}

public Optional<HealthcheckMethod> getMethod() {
return method;
}

public HealthcheckOptionsBuilder setMethod(Optional<HealthcheckMethod> method) {
this.method = method;
return this;
}

public Optional<Integer> getStartupTimeoutSeconds() {
return startupTimeoutSeconds;
}
Expand Down Expand Up @@ -151,7 +163,7 @@ public HealthcheckOptionsBuilder setHealthcheckResultFilePath(Optional<String> h
}

public HealthcheckOptions build() {
return new HealthcheckOptions(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes, healthcheckResultFilePath);
return new HealthcheckOptions(uri, portIndex, portNumber, protocol, method, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes, healthcheckResultFilePath);
}

@Override
Expand All @@ -167,6 +179,7 @@ public boolean equals(Object o) {
Objects.equals(portIndex, that.portIndex) &&
Objects.equals(portNumber, that.portNumber) &&
Objects.equals(protocol, that.protocol) &&
Objects.equals(method, that.method) &&
Objects.equals(startupTimeoutSeconds, that.startupTimeoutSeconds) &&
Objects.equals(startupDelaySeconds, that.startupDelaySeconds) &&
Objects.equals(startupIntervalSeconds, that.startupIntervalSeconds) &&
Expand All @@ -179,7 +192,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Objects.hash(uri, portIndex, portNumber, protocol, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes, healthcheckResultFilePath);
return Objects.hash(uri, portIndex, portNumber, protocol, method, startupTimeoutSeconds, startupDelaySeconds, startupIntervalSeconds, intervalSeconds, responseTimeoutSeconds, maxRetries, failureStatusCodes, healthcheckResultFilePath);
}

@Override
Expand All @@ -189,6 +202,7 @@ public String toString() {
", portIndex=" + portIndex +
", portNumber=" + portNumber +
", protocol=" + protocol +
", method=" + method +
", startupTimeoutSeconds=" + startupTimeoutSeconds +
", startupDelaySeconds=" + startupDelaySeconds +
", startupIntervalSeconds=" + startupIntervalSeconds +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.hubspot.singularity;

public enum HealthcheckMethod {

GET("GET"), POST("POST");

private String method;

private HealthcheckMethod(String method) {
this.method = method;
}

public String getMethod() {
return method;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@Schema
public enum HealthcheckProtocol {

HTTP("http"), HTTPS("https");
HTTP("http"), HTTPS("https"), HTTP2("http"), HTTPS2("https");

private final String protocol;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public SingularityDeploy(@JsonProperty("requestId") String requestId,
healthcheckPortIndex,
Optional.<Long>absent(),
healthcheckProtocol,
Optional.<HealthcheckMethod>absent(),
Optional.<Integer>absent(),
Optional.<Integer>absent(),
Optional.<Integer>absent(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ protected void configure() {
@Named(LOCAL_DOWNLOAD_HTTP_CLIENT)
public AsyncHttpClient providesHttpClient(SingularityExecutorConfiguration configuration) {
AsyncHttpClientConfig.Builder configBldr = new AsyncHttpClientConfig.Builder();
configBldr.setRequestTimeoutInMs((int) configuration.getLocalDownloadServiceTimeoutMillis());
configBldr.setIdleConnectionTimeoutInMs((int) configuration.getLocalDownloadServiceTimeoutMillis());
configBldr.setRequestTimeout((int) configuration.getLocalDownloadServiceTimeoutMillis());
configBldr.setPooledConnectionIdleTimeout((int) configuration.getLocalDownloadServiceTimeoutMillis());
configBldr.addRequestFilter(new ThrottleRequestFilter(configuration.getLocalDownloadServiceMaxConnections()));

return new AsyncHttpClient(configBldr.build());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.hubspot.singularity.executor.task;

import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -172,8 +171,8 @@ private void downloadFilesFromLocalDownloadService(List<? extends S3Artifact> s3
ListenableFuture<Response> future = localDownloadHttpClient.executeRequest(postRequestBldr.build());

futures.add(new FutureHolder(future, System.currentTimeMillis(), s3Artifact));
} catch (IOException ioe) {
throw Throwables.propagate(ioe);
} catch (Throwable t) {
throw new RuntimeException(t);
}
}

Expand Down
15 changes: 15 additions & 0 deletions SingularityService/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
<basepom.shaded.main-class>com.hubspot.singularity.SingularityService</basepom.shaded.main-class>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>

<dependency>
Expand Down Expand Up @@ -136,6 +146,11 @@
<artifactId>async-http-client</artifactId>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>

<dependency>
<groupId>com.palominolabs.metrics</groupId>
<artifactId>metrics-guice</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public void configure(Binder binder) {
if (clazz == SingularityAuthenticatorClass.WEBHOOK) {
AuthConfiguration authConfiguration = getConfiguration().getAuthConfiguration();
AsyncHttpClientConfig clientConfig = new AsyncHttpClientConfig.Builder()
.setConnectionTimeoutInMs(authConfiguration.getWebhookAuthConnectTimeoutMs())
.setRequestTimeoutInMs(authConfiguration.getWebhookAuthRequestTimeoutMs())
.setConnectTimeout(authConfiguration.getWebhookAuthConnectTimeoutMs())
.setRequestTimeout(authConfiguration.getWebhookAuthRequestTimeoutMs())
.setMaxRequestRetry(authConfiguration.getWebhookAuthRetries())
.build();
SingularityAsyncHttpClient webhookAsyncHttpClient = new SingularityAsyncHttpClient(clientConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
import io.dropwizard.jetty.HttpsConnectorFactory;
import io.dropwizard.server.DefaultServerFactory;
import io.dropwizard.server.SimpleServerFactory;
import okhttp3.OkHttpClient;


public class SingularityMainModule implements Module {
Expand Down Expand Up @@ -158,6 +159,7 @@ public void configure(Binder binder) {
binder.bind(MetricRegistry.class).toProvider(DropwizardMetricRegistryProvider.class).in(Scopes.SINGLETON);

binder.bind(AsyncHttpClient.class).to(SingularityAsyncHttpClient.class).in(Scopes.SINGLETON);
binder.bind(OkHttpClient.class).to(SingularityOkHttpClient.class).in(Scopes.SINGLETON);
binder.bind(ServerProvider.class).in(Scopes.SINGLETON);

binder.bind(SingularityDropwizardHealthcheck.class).in(Scopes.SINGLETON);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.hubspot.singularity;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;

import io.dropwizard.lifecycle.Managed;
import okhttp3.OkHttpClient;

public class SingularityOkHttpClient extends OkHttpClient implements Managed {
private static final Logger LOG = LoggerFactory.getLogger(SingularityOkHttpClient.class);

@Inject
SingularityOkHttpClient() {}

@Override
public void start() {}

@Override
public void stop() {
dispatcher().executorService().shutdown();
connectionPool().evictAll();
if (cache() != null) {
try {
cache().delete();
} catch (IOException e) {
LOG.warn("Unable to clean up client cache!");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public class SingularityConfiguration extends Configuration {

private long deleteDeadSlavesAfterHours = TimeUnit.DAYS.toHours(7);

private int maxMachineHistoryEntries = 10;

private long deleteStaleRequestsFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(14);

private Optional<Integer> maxRequestsWithHistoryInZkWhenNoDatabase = Optional.absent();
Expand Down Expand Up @@ -251,6 +253,8 @@ public class SingularityConfiguration extends Configuration {

private long reconcileSlavesEveryMinutes = TimeUnit.HOURS.toMinutes(1);

private long cleanInactiveHostListEveryHours = 24;

@JsonProperty("s3")
private S3Configuration s3Configuration;

Expand Down Expand Up @@ -688,6 +692,14 @@ public void setDeleteDeadSlavesAfterHours(long deleteDeadSlavesAfterHours) {
this.deleteDeadSlavesAfterHours = deleteDeadSlavesAfterHours;
}

public int getMaxMachineHistoryEntries() {
return maxMachineHistoryEntries;
}

public void setMaxMachineHistoryEntries(int maxMachineHistoryEntries) {
this.maxMachineHistoryEntries = maxMachineHistoryEntries;
}

public int getListenerThreadpoolSize() {
return listenerThreadpoolSize;
}
Expand Down Expand Up @@ -1219,6 +1231,14 @@ public void setReconcileSlavesEveryMinutes(long reconcileSlavesEveryMinutes) {
this.reconcileSlavesEveryMinutes = reconcileSlavesEveryMinutes;
}

public long getCleanInactiveHostListEveryHours() {
return cleanInactiveHostListEveryHours;
}

public void setCleanInactiveHostListEveryHours(long cleanInactiveHostListEveryHours) {
this.cleanInactiveHostListEveryHours = cleanInactiveHostListEveryHours;
}

public long getCacheTasksForMillis() {
return cacheTasksForMillis;
}
Expand Down
Loading