com.hubspot.singularity.config.SingularityConfiguration Maven / Gradle / Ivy
package com.hubspot.singularity.config;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.hubspot.singularity.AgentPlacement;
import com.hubspot.singularity.RequestType;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
@JsonIgnoreProperties(ignoreUnknown = true)
public class SingularityConfiguration extends Configuration {
private boolean allowRequestsWithoutOwners = true;
private boolean allowTestResourceCalls = false;
private long askDriverToKillTasksAgainAfterMillis = TimeUnit.MINUTES.toMillis(5);
private long cacheOffersForMillis = TimeUnit.MINUTES.toMillis(1);
private int offerCacheSize = 125;
private boolean cacheOffers = false;
private long cacheForWebForMillis = TimeUnit.SECONDS.toMillis(30);
private int cacheTasksMaxSize = 5000;
private int cacheTasksInitialSize = 100;
private long cacheTasksForMillis = TimeUnit.DAYS.toMillis(1);
private int cacheDeploysMaxSize = 2000;
private int cacheDeploysInitialSize = 100;
private long cacheDeploysForMillis = TimeUnit.DAYS.toMillis(5);
@Deprecated
private long cacheStateForMillis = TimeUnit.SECONDS.toMillis(60);
private long checkDeploysEverySeconds = 5;
private long checkAutoSpreadAllAgentsEverySeconds = 30;
private long checkNewTasksEverySeconds = 5;
private long checkExpiringUserActionEveryMillis = TimeUnit.SECONDS.toMillis(45);
private int checkNewTasksScheduledThreads = 3;
private long checkReconcileWhenRunningEveryMillis = TimeUnit.SECONDS.toMillis(30);
private long checkJobsEveryMillis = TimeUnit.MINUTES.toMillis(10);
private long checkSchedulerEverySeconds = 5;
private long checkWebhooksEveryMillis = TimeUnit.SECONDS.toMillis(10);
private long checkUsageEveryMillis = TimeUnit.MINUTES.toMillis(1);
private long checkMesosMasterHeartbeatEverySeconds = 20;
private long checkUpstreamsEverySeconds = 600;
private long maxMissedMesosMasterHeartbeats = 5;
private int maxConcurrentUsageCollections = 15;
private boolean shuffleTasksForOverloadedAgents = false; // recommended 'true' when oversubscribing resources for larger clusters
private double shuffleTasksWhenAgentMemoryUtilizationPercentageExceeds = 0.82;
private int maxTasksToShuffleTotal = 6; // Do not allow more than this many shuffle cleanups at once cluster-wide
private int maxTasksToShufflePerHost = 2;
@Deprecated
private List doNotShuffleRequests = new ArrayList<>();
private int minutesBeforeNewTaskEligibleForShuffle = 15;
private long cleanUsageEveryMillis = TimeUnit.MINUTES.toMillis(5);
private int numUsageToKeep = 15;
private long cleanupEverySeconds = 5;
private long checkQueuedMailsEveryMillis = TimeUnit.SECONDS.toMillis(15);
private boolean ldapCacheEnabled = true;
private long ldapCacheSize = 100;
private long ldapCacheExpireMillis = TimeUnit.MINUTES.toMillis(1);
private long closeWaitSeconds = 5;
private String commonHostnameSuffixToOmit;
private boolean compressLargeDataObjects = true;
private long considerTaskHealthyAfterRunningForSeconds = 5;
private long cooldownMinScheduleSeconds = 120;
@JsonProperty("database")
private DataSourceFactory databaseConfiguration;
@Min(value = 1, message = "Must be positive and non-zero")
private int defaultBounceExpirationMinutes = 60;
@NotNull
private AgentPlacement defaultAgentPlacement = AgentPlacement.GREEDY;
@Min(value = 0, message = "Must be non-negative")
private double placementLeniency = 0.09d;
private boolean defaultValueForKillTasksOfPausedRequests = true;
private int defaultDeployStepWaitTimeMs = 0;
private int defaultDeployMaxTaskRetries = 0;
private long deleteDeploysFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(14);
private Optional maxStaleDeploysPerRequestInZkWhenNoDatabase = Optional.empty();
private long deleteDeadAgentsAfterHours = TimeUnit.DAYS.toHours(7);
private int maxMachineHistoryEntries = 10;
private long deleteStaleRequestsFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(
14
);
private Optional maxRequestsWithHistoryInZkWhenNoDatabase = Optional.empty();
private long deleteTasksFromZkWhenNoDatabaseAfterHours = TimeUnit.DAYS.toHours(7);
private Optional maxStaleTasksPerRequestInZkWhenNoDatabase = Optional.empty();
private long deleteUndeliverableWebhooksAfterHours = TimeUnit.DAYS.toHours(7);
private long deltaAfterWhichTasksAreLateMillis = TimeUnit.SECONDS.toMillis(30);
private long deployHealthyBySeconds = 120;
private int dispatchTaskShellCommandsEverySeconds = 5;
private long debugCuratorCallOverBytes = 25000;
private long debugCuratorCallOverMillis = 250;
@Deprecated
private boolean enableCorsFilter = false;
private CorsConfiguration cors = new CorsConfiguration();
private int healthcheckIntervalSeconds = 5;
private int healthcheckStartThreads = 3;
private int healthcheckTimeoutSeconds = 5;
private Optional startupDelaySeconds = Optional.empty();
private int startupTimeoutSeconds = 45;
private int startupIntervalSeconds = 2;
private int schedulerStartupConcurrency = 20;
private Optional healthcheckMaxRetries = Optional.empty();
private Optional healthcheckMaxTotalTimeoutSeconds = Optional.empty();
private long killTaskIfNotHealthyAfterSeconds = 600;
@NotNull
private List healthcheckFailureStatusCodes = Collections.emptyList();
private String hostname;
private long killAfterTasksDoNotRunDefaultSeconds = 600;
private long killNonLongRunningTasksInCleanupAfterSeconds = TimeUnit.HOURS.toSeconds(
24
);
private int listenerThreadpoolSize = 3;
@JsonProperty("loadBalancerQueryParams")
private Map loadBalancerQueryParams;
private long loadBalancerRequestTimeoutMillis = 2000;
private long loadBalancerRemovalGracePeriodMillis = 0;
private String loadBalancerUri;
private boolean deleteRemovedRequestsFromLoadBalancer = false;
private Optional taskLabelForLoadBalancerUpstreamGroup = Optional.empty();
private boolean preResolveUpstreamDNS = false;
private Set skipDNSPreResolutionForRequests = new HashSet<>();
private int logFetchMaxThreads = 15;
private int maxDeployIdSize = 50;
private int maxHealthcheckResponseBodyBytes = 8192;
private int maxQueuedUpdatesPerWebhook = 50;
private int maxTasksPerOffer = 0;
private int maxTasksPerOfferPerRequest = 0;
private int maxRequestIdSize = 100;
private int maxUserIdSize = 100;
private boolean storeAllMesosTaskInfoForDebugging = false;
@JsonProperty("historyPurging")
@Valid
private HistoryPurgingConfiguration historyPurgingConfiguration = new HistoryPurgingConfiguration();
private boolean sqlFallBackToBytesFields = true;
@JsonProperty("mesos")
@Valid
private MesosConfiguration mesosConfiguration;
@JsonProperty("network")
@Valid
private NetworkConfiguration networkConfiguration = new NetworkConfiguration();
private int newTaskCheckerBaseDelaySeconds = 1;
private long pendingDeployHoldTaskDuringDecommissionMillis = TimeUnit.MINUTES.toMillis(
10
);
private long persistHistoryEverySeconds = TimeUnit.MINUTES.toSeconds(2);
private int maxPendingImmediatePersists = 200;
private long reconcileAgentsEveryMinutes = TimeUnit.HOURS.toMinutes(1);
private long cleanInactiveHostListEveryHours = 24;
@JsonProperty("s3")
private S3Configuration s3Configuration;
private boolean sandboxDefaultsToTaskId = false;
private long sandboxHttpTimeoutMillis = TimeUnit.SECONDS.toMillis(2);
private long saveStateEverySeconds = 30;
@JsonProperty("sentry")
@Valid
private SentryConfiguration sentryConfiguration;
@JsonProperty("taskMetadata")
@Valid
private SingularityTaskMetadataConfiguration taskMetadataConfiguration = new SingularityTaskMetadataConfiguration();
@JsonProperty("smtp")
@Valid
private SMTPConfiguration smtpConfiguration;
private long startNewReconcileEverySeconds = TimeUnit.MINUTES.toSeconds(10);
@JsonProperty("ui")
@Valid
private UIConfiguration uiConfiguration = new UIConfiguration();
/** If true, the event system waits for all listeners having processed an event. */
private boolean waitForListeners = true;
private long warnIfScheduledJobIsRunningForAtLeastMillis = TimeUnit.DAYS.toMillis(1);
@JsonProperty("taskExecutionTimeLimitMillis")
private Optional taskExecutionTimeLimitMillis = Optional.empty();
private int warnIfScheduledJobIsRunningPastNextRunPct = 200;
private long zookeeperAsyncTimeout = 5000;
private int coreThreadpoolSize = 8;
private long threadpoolShutdownDelayInSeconds = 10;
@Valid
@JsonProperty("customExecutor")
@NotNull
private CustomExecutorConfiguration customExecutorConfiguration = new CustomExecutorConfiguration();
private boolean createDeployIds = false;
@Min(4)
@Max(32)
private int deployIdLength = 8;
@JsonProperty("zookeeper")
@Valid
private ZooKeeperConfiguration zooKeeperConfiguration;
@JsonProperty("ldap")
@Valid
private LDAPConfiguration ldapConfiguration;
@JsonProperty("webhookAuth")
@Valid
private WebhookAuthConfiguration webhookAuthConfiguration = new WebhookAuthConfiguration();
@JsonProperty("webhookQueue")
@Valid
private WebhookQueueConfiguration webhookQueueConfiguration = new WebhookQueueConfiguration();
private int maxConcurrentWebhooks = 100;
@JsonProperty("auth")
@NotNull
@Valid
private AuthConfiguration authConfiguration = new AuthConfiguration();
@NotNull
private Map> reserveAgentsWithAttributes = Collections.emptyMap();
@JsonProperty("graphite")
@NotNull
@Valid
private GraphiteConfiguration graphiteConfiguration = new GraphiteConfiguration();
private boolean taskHistoryQueryUsesZkFirst = false;
@JsonProperty("disasterDetection")
@NotNull
@Valid
private DisasterDetectionConfiguration disasterDetection = new DisasterDetectionConfiguration();
@Min(0)
@Max(1)
private double defaultTaskPriorityLevel = 0.3;
@NotNull
private Map defaultTaskPriorityLevelForRequestType = ImmutableMap.of(
RequestType.WORKER,
0.5,
RequestType.SERVICE,
0.7
);
@Min(0)
private long checkPriorityKillsEveryMillis = TimeUnit.SECONDS.toMillis(30);
@Min(0)
@Max(5)
private double schedulerPriorityWeightFactor = 1.0;
private boolean rebalanceRacksOnScaleDown = false;
private boolean allowBounceToSameHost = false;
private int maxActiveOnDemandTasksPerRequest = 0;
private int maxDecommissioningAgents = 2;
private boolean spreadAllAgentsEnabled = false;
private int maxRunNowTaskLaunchDelayDays = 30;
private boolean allowDeployOfPausedRequests = false;
private Optional cpuHardLimit = Optional.empty();
// If cpuHardLimit is specified and a task is requesting a base cpu of > cpuHardLimit, that task's new hard limit is requested cpus * cpuHardLimitScaleFactor
private double cpuHardLimitScaleFactor = 1.25;
private Map preemptibleTasksOnlyMachineAttributes = Collections.emptyMap();
private long preemptibleTaskMaxExpectedRuntimeMs = 900000; // 15 minutes
private long maxAgentUsageMetricAgeMs = 30000;
private boolean reCheckMetricsForLargeNewTaskCount = false;
private boolean proxyRunNowToLeader = true;
private Optional expectedRacksCount = Optional.empty();
private double preferredAgentScaleFactor = 1.5;
// high cpu agent, based on cpu to memory ratio
private double highCpuAgentCutOff = 1.5; //TODO
// high memory agent, based on cpu to memory ratio
private double highMemoryAgentCutOff = 0.5; //TODO
private long reconcileLaunchAfterMillis = TimeUnit.MINUTES.toMillis(3);
@JsonProperty("crashLoop")
private CrashLoopConfiguration crashLoopConfiguration = new CrashLoopConfiguration();
// If true, only allow artifacts with an attached signature. This disallows embedded + external artifacts, only allowing lists + s3
private boolean enforceSignedArtifacts = false;
// If not empty, disallow docker images in deploys unless they are in this list
private Set validDockerRegistries = Collections.emptySet();
public long getAskDriverToKillTasksAgainAfterMillis() {
return askDriverToKillTasksAgainAfterMillis;
}
@Deprecated
public long getCacheStateForMillis() {
return cacheStateForMillis;
}
public long getDispatchTaskShellCommandsEverySeconds() {
return dispatchTaskShellCommandsEverySeconds;
}
public long getCheckDeploysEverySeconds() {
return checkDeploysEverySeconds;
}
public long getCheckAutoSpreadAllAgentsEverySeconds() {
return checkAutoSpreadAllAgentsEverySeconds;
}
public long getCheckNewTasksEverySeconds() {
return checkNewTasksEverySeconds;
}
public int getCheckNewTasksScheduledThreads() {
return checkNewTasksScheduledThreads;
}
public long getCheckReconcileWhenRunningEveryMillis() {
return checkReconcileWhenRunningEveryMillis;
}
public long getCheckJobsEveryMillis() {
return checkJobsEveryMillis;
}
public long getCheckSchedulerEverySeconds() {
return checkSchedulerEverySeconds;
}
public long getCheckWebhooksEveryMillis() {
return checkWebhooksEveryMillis;
}
public long getCheckUpstreamsEverySeconds() {
return checkUpstreamsEverySeconds;
}
public long getCleanupEverySeconds() {
return cleanupEverySeconds;
}
public long getCloseWaitSeconds() {
return closeWaitSeconds;
}
public Optional getCommonHostnameSuffixToOmit() {
return Optional.ofNullable(Strings.emptyToNull(commonHostnameSuffixToOmit));
}
public long getConsiderTaskHealthyAfterRunningForSeconds() {
return considerTaskHealthyAfterRunningForSeconds;
}
public long getDebugCuratorCallOverBytes() {
return debugCuratorCallOverBytes;
}
public void setDebugCuratorCallOverBytes(long debugCuratorCallOverBytes) {
this.debugCuratorCallOverBytes = debugCuratorCallOverBytes;
}
public long getPendingDeployHoldTaskDuringDecommissionMillis() {
return pendingDeployHoldTaskDuringDecommissionMillis;
}
public long getCacheForWebForMillis() {
return cacheForWebForMillis;
}
public void setCacheForWebForMillis(long cacheForWebForMillis) {
this.cacheForWebForMillis = cacheForWebForMillis;
}
public void setPendingDeployHoldTaskDuringDecommissionMillis(
long pendingDeployHoldTaskDuringDecommissionMillis
) {
this.pendingDeployHoldTaskDuringDecommissionMillis =
pendingDeployHoldTaskDuringDecommissionMillis;
}
public long getDebugCuratorCallOverMillis() {
return debugCuratorCallOverMillis;
}
public void setDebugCuratorCallOverMillis(long debugCuratorCallOverMillis) {
this.debugCuratorCallOverMillis = debugCuratorCallOverMillis;
}
public long getCooldownMinScheduleSeconds() {
return cooldownMinScheduleSeconds;
}
public int getCacheTasksMaxSize() {
return cacheTasksMaxSize;
}
public void setCacheTasksMaxSize(int cacheTasksMaxSize) {
this.cacheTasksMaxSize = cacheTasksMaxSize;
}
public int getCacheTasksInitialSize() {
return cacheTasksInitialSize;
}
public void setCacheTasksInitialSize(int cacheTasksInitialSize) {
this.cacheTasksInitialSize = cacheTasksInitialSize;
}
public int getCacheDeploysMaxSize() {
return cacheDeploysMaxSize;
}
public void setCacheDeploysMaxSize(int cacheDeploysMaxSize) {
this.cacheDeploysMaxSize = cacheDeploysMaxSize;
}
public int getCacheDeploysInitialSize() {
return cacheDeploysInitialSize;
}
public void setCacheDeploysInitialSize(int cacheDeploysInitialSize) {
this.cacheDeploysInitialSize = cacheDeploysInitialSize;
}
public long getCacheDeploysForMillis() {
return cacheDeploysForMillis;
}
public void setCacheDeploysForMillis(long cacheDeploysForMillis) {
this.cacheDeploysForMillis = cacheDeploysForMillis;
}
public int getCoreThreadpoolSize() {
return coreThreadpoolSize;
}
public CustomExecutorConfiguration getCustomExecutorConfiguration() {
return customExecutorConfiguration;
}
public Optional getDatabaseConfiguration() {
return Optional.ofNullable(databaseConfiguration);
}
public int getDefaultBounceExpirationMinutes() {
return defaultBounceExpirationMinutes;
}
public void setDefaultBounceExpirationMinutes(int defaultBounceExpirationMinutes) {
this.defaultBounceExpirationMinutes = defaultBounceExpirationMinutes;
}
public AgentPlacement getDefaultAgentPlacement() {
return defaultAgentPlacement;
}
@Deprecated
public AgentPlacement getDefaultSlavePlacement() {
return defaultAgentPlacement;
}
public double getPlacementLeniency() {
return placementLeniency;
}
public int getDefaultDeployStepWaitTimeMs() {
return defaultDeployStepWaitTimeMs;
}
public void setDefaultDeployStepWaitTimeMs(int defaultDeployStepWaitTimeMs) {
this.defaultDeployStepWaitTimeMs = defaultDeployStepWaitTimeMs;
}
public int getDefaultDeployMaxTaskRetries() {
return defaultDeployMaxTaskRetries;
}
public boolean isLdapCacheEnabled() {
return ldapCacheEnabled;
}
public void setLdapCacheEnabled(boolean ldapCacheEnabled) {
this.ldapCacheEnabled = ldapCacheEnabled;
}
public long getLdapCacheSize() {
return ldapCacheSize;
}
public void setLdapCacheSize(long ldapCacheSize) {
this.ldapCacheSize = ldapCacheSize;
}
public long getLdapCacheExpireMillis() {
return ldapCacheExpireMillis;
}
public void setLdapCacheExpireMillis(long ldapCacheExpireMillis) {
this.ldapCacheExpireMillis = ldapCacheExpireMillis;
}
public void setDefaultDeployMaxTaskRetries(int defaultDeployMaxTaskRetries) {
this.defaultDeployMaxTaskRetries = defaultDeployMaxTaskRetries;
}
public long getDeleteDeploysFromZkWhenNoDatabaseAfterHours() {
return deleteDeploysFromZkWhenNoDatabaseAfterHours;
}
public long getDeleteStaleRequestsFromZkWhenNoDatabaseAfterHours() {
return deleteStaleRequestsFromZkWhenNoDatabaseAfterHours;
}
public long getDeleteTasksFromZkWhenNoDatabaseAfterHours() {
return deleteTasksFromZkWhenNoDatabaseAfterHours;
}
public long getDeleteUndeliverableWebhooksAfterHours() {
return deleteUndeliverableWebhooksAfterHours;
}
public long getDeltaAfterWhichTasksAreLateMillis() {
return deltaAfterWhichTasksAreLateMillis;
}
public long getDeployHealthyBySeconds() {
return deployHealthyBySeconds;
}
public int getDeployIdLength() {
return deployIdLength;
}
public int getHealthcheckIntervalSeconds() {
return healthcheckIntervalSeconds;
}
public int getHealthcheckStartThreads() {
return healthcheckStartThreads;
}
public int getHealthcheckTimeoutSeconds() {
return healthcheckTimeoutSeconds;
}
public Optional getHealthcheckMaxRetries() {
return healthcheckMaxRetries;
}
public Optional getHealthcheckMaxTotalTimeoutSeconds() {
return healthcheckMaxTotalTimeoutSeconds;
}
public long getKillTaskIfNotHealthyAfterSeconds() {
return killTaskIfNotHealthyAfterSeconds;
}
public Optional getHostname() {
return Optional.ofNullable(Strings.emptyToNull(hostname));
}
public long getKillAfterTasksDoNotRunDefaultSeconds() {
return killAfterTasksDoNotRunDefaultSeconds;
}
public long getKillNonLongRunningTasksInCleanupAfterSeconds() {
return killNonLongRunningTasksInCleanupAfterSeconds;
}
public long getLoadBalancerRemovalGracePeriodMillis() {
return loadBalancerRemovalGracePeriodMillis;
}
public void setLoadBalancerRemovalGracePeriodMillis(
long loadBalancerRemovalGracePeriodMillis
) {
this.loadBalancerRemovalGracePeriodMillis = loadBalancerRemovalGracePeriodMillis;
}
public long getDeleteDeadAgentsAfterHours() {
return deleteDeadAgentsAfterHours;
}
public void setDeleteDeadAgentsAfterHours(long deleteDeadAgentsAfterHours) {
this.deleteDeadAgentsAfterHours = deleteDeadAgentsAfterHours;
}
@Deprecated
public long getDeleteDeadSlavesAfterHours() {
return deleteDeadAgentsAfterHours;
}
@Deprecated
public void setDeleteDeadSlavesAfterHours(long deleteDeadAgentsAfterHours) {
this.deleteDeadAgentsAfterHours = deleteDeadAgentsAfterHours;
}
public int getMaxMachineHistoryEntries() {
return maxMachineHistoryEntries;
}
public void setMaxMachineHistoryEntries(int maxMachineHistoryEntries) {
this.maxMachineHistoryEntries = maxMachineHistoryEntries;
}
public int getListenerThreadpoolSize() {
return listenerThreadpoolSize;
}
public Optional