Skip to content

Commit

Permalink
Move S3 file configuration to SingularityService
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalinas committed Jan 4, 2017
1 parent 2ab38a7 commit 4690e9e
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 241 deletions.
13 changes: 2 additions & 11 deletions SingularityBase/src/main/java/com/hubspot/deploy/ExecutorData.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class ExecutorData {
private final Optional<Long> sigKillProcessesAfterMillis;
private final Optional<Integer> maxTaskThreads;
private final Optional<Boolean> preserveTaskSandboxAfterFinish;
private final Optional<String> loggingS3Bucket;
private final Optional<Integer> maxOpenFiles;
private final Optional<Boolean> skipLogrotateAndCompress;
private final Optional<List<S3ArtifactSignature>> s3ArtifactSignatures;
Expand All @@ -39,8 +38,7 @@ public ExecutorData(@JsonProperty("cmd") String cmd, @JsonProperty("embeddedArti
@JsonProperty("s3Artifacts") List<S3Artifact> s3Artifacts, @JsonProperty("successfulExitCodes") List<Integer> successfulExitCodes, @JsonProperty("user") Optional<String> user,
@JsonProperty("runningSentinel") Optional<String> runningSentinel, @JsonProperty("extraCmdLineArgs") List<String> extraCmdLineArgs, @JsonProperty("loggingTag") Optional<String> loggingTag,
@JsonProperty("loggingExtraFields") Map<String, String> loggingExtraFields, @JsonProperty("sigKillProcessesAfterMillis") Optional<Long> sigKillProcessesAfterMillis,
@JsonProperty("maxTaskThreads") Optional<Integer> maxTaskThreads, @JsonProperty("preserveTaskSandboxAfterFinish") Optional<Boolean> preserveTaskSandboxAfterFinish,
@JsonProperty("loggingS3Bucket") Optional<String> loggingS3Bucket, @JsonProperty("maxOpenFiles") Optional<Integer> maxOpenFiles,
@JsonProperty("maxTaskThreads") Optional<Integer> maxTaskThreads, @JsonProperty("preserveTaskSandboxAfterFinish") Optional<Boolean> preserveTaskSandboxAfterFinish, @JsonProperty("maxOpenFiles") Optional<Integer> maxOpenFiles,
@JsonProperty("skipLogrotateAndCompress") Optional<Boolean> skipLogrotateAndCompress, @JsonProperty("s3ArtifactSignatures") Optional<List<S3ArtifactSignature>> s3ArtifactSignatures,
@JsonProperty("logrotateFrequency") Optional<SingularityExecutorLogrotateFrequency> logrotateFrequency) {
this.cmd = cmd;
Expand All @@ -56,7 +54,6 @@ public ExecutorData(@JsonProperty("cmd") String cmd, @JsonProperty("embeddedArti
this.sigKillProcessesAfterMillis = sigKillProcessesAfterMillis;
this.maxTaskThreads = maxTaskThreads;
this.preserveTaskSandboxAfterFinish = preserveTaskSandboxAfterFinish;
this.loggingS3Bucket = loggingS3Bucket;
this.maxOpenFiles = maxOpenFiles;
this.skipLogrotateAndCompress = skipLogrotateAndCompress;
this.s3ArtifactSignatures = s3ArtifactSignatures;
Expand All @@ -65,7 +62,7 @@ public ExecutorData(@JsonProperty("cmd") String cmd, @JsonProperty("embeddedArti

public ExecutorDataBuilder toBuilder() {
return new ExecutorDataBuilder(cmd, embeddedArtifacts, externalArtifacts, s3Artifacts, successfulExitCodes, runningSentinel, user, extraCmdLineArgs, loggingTag,
loggingExtraFields, sigKillProcessesAfterMillis, maxTaskThreads, preserveTaskSandboxAfterFinish, loggingS3Bucket, maxOpenFiles, skipLogrotateAndCompress, s3ArtifactSignatures, logrotateFrequency);
loggingExtraFields, sigKillProcessesAfterMillis, maxTaskThreads, preserveTaskSandboxAfterFinish, maxOpenFiles, skipLogrotateAndCompress, s3ArtifactSignatures, logrotateFrequency);
}

@ApiModelProperty(required=true, value="Command for the custom executor to run")
Expand Down Expand Up @@ -133,11 +130,6 @@ public Optional<Boolean> getPreserveTaskSandboxAfterFinish() {
return preserveTaskSandboxAfterFinish;
}

@ApiModelProperty(required=false, value="Override the default bucket used by the S3Uploader to store log files")
public Optional<String> getLoggingS3Bucket() {
return loggingS3Bucket;
}

@ApiModelProperty(required=false, value="Maximum number of open files the task process is allowed")
public Optional<Integer> getMaxOpenFiles() {
return maxOpenFiles;
Expand Down Expand Up @@ -174,7 +166,6 @@ public String toString() {
.add("sigKillProcessesAfterMillis", sigKillProcessesAfterMillis)
.add("maxTaskThreads", maxTaskThreads)
.add("preserveTaskSandboxAfterFinish", preserveTaskSandboxAfterFinish)
.add("loggingS3Bucket", loggingS3Bucket)
.add("maxOpenFiles", maxOpenFiles)
.add("skipLogrotateAndCompress", skipLogrotateAndCompress)
.add("s3ArtifactSignatures", s3ArtifactSignatures)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ public class ExecutorDataBuilder {
private Optional<Long> sigKillProcessesAfterMillis;
private Optional<Integer> maxTaskThreads;
private Optional<Boolean> preserveTaskSandboxAfterFinish;
private Optional<String> loggingS3Bucket;
private Optional<Integer> maxOpenFiles;
private Optional<Boolean> skipLogrotateAndCompress;
private Optional<List<S3ArtifactSignature>> s3ArtifactSignatures;
private Optional<SingularityExecutorLogrotateFrequency> logrotateFrequency;

public ExecutorDataBuilder(String cmd, List<EmbeddedArtifact> embeddedArtifacts, List<ExternalArtifact> externalArtifacts, List<S3Artifact> s3Artifacts, List<Integer> successfulExitCodes,
Optional<String> runningSentinel, Optional<String> user, List<String> extraCmdLineArgs, Optional<String> loggingTag, Map<String, String> loggingExtraFields,
Optional<Long> sigKillProcessesAfterMillis, Optional<Integer> maxTaskThreads, Optional<Boolean> preserveTaskSandboxAfterFinish, Optional<String> loggingS3Bucket,
Optional<Long> sigKillProcessesAfterMillis, Optional<Integer> maxTaskThreads, Optional<Boolean> preserveTaskSandboxAfterFinish,
Optional<Integer> maxOpenFiles, Optional<Boolean> skipLogrotateAndCompress, Optional<List<S3ArtifactSignature>> s3ArtifactSignatures, Optional<SingularityExecutorLogrotateFrequency> logrotateFrequency) {
this.cmd = cmd;
this.embeddedArtifacts = embeddedArtifacts;
Expand All @@ -44,7 +43,6 @@ public ExecutorDataBuilder(String cmd, List<EmbeddedArtifact> embeddedArtifacts,
this.sigKillProcessesAfterMillis = sigKillProcessesAfterMillis;
this.maxTaskThreads = maxTaskThreads;
this.preserveTaskSandboxAfterFinish = preserveTaskSandboxAfterFinish;
this.loggingS3Bucket = loggingS3Bucket;
this.maxOpenFiles = maxOpenFiles;
this.skipLogrotateAndCompress = skipLogrotateAndCompress;
this.s3ArtifactSignatures = s3ArtifactSignatures;
Expand All @@ -57,7 +55,7 @@ public ExecutorDataBuilder() {

public ExecutorData build() {
return new ExecutorData(cmd, embeddedArtifacts, externalArtifacts, s3Artifacts, successfulExitCodes, user, runningSentinel, extraCmdLineArgs, loggingTag, loggingExtraFields,
sigKillProcessesAfterMillis, maxTaskThreads, preserveTaskSandboxAfterFinish, loggingS3Bucket, maxOpenFiles, skipLogrotateAndCompress, s3ArtifactSignatures, logrotateFrequency);
sigKillProcessesAfterMillis, maxTaskThreads, preserveTaskSandboxAfterFinish, maxOpenFiles, skipLogrotateAndCompress, s3ArtifactSignatures, logrotateFrequency);
}

public Optional<String> getLoggingTag() {
Expand Down Expand Up @@ -177,15 +175,6 @@ public ExecutorDataBuilder setPreserveTaskSandboxAfterFinish(Optional<Boolean> p
return this;
}

public Optional<String> getLoggingS3Bucket() {
return loggingS3Bucket;
}

public ExecutorDataBuilder setLoggingS3Bucket(Optional<String> loggingS3Bucket) {
this.loggingS3Bucket = loggingS3Bucket;
return this;
}

public Optional<Integer> getMaxOpenFiles() {
return maxOpenFiles;
}
Expand Down Expand Up @@ -238,7 +227,6 @@ public String toString() {
", sigKillProcessesAfterMillis=" + sigKillProcessesAfterMillis +
", maxTaskThreads=" + maxTaskThreads +
", preserveTaskSandboxAfterFinish=" + preserveTaskSandboxAfterFinish +
", loggingS3Bucket=" + loggingS3Bucket +
", maxOpenFiles=" + maxOpenFiles +
", skipLogrotateAndCompress=" + skipLogrotateAndCompress +
", s3ArtifactSignatures=" + s3ArtifactSignatures +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.hubspot.singularity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;

public class SingularityS3UploaderFile {
private final String filename;
private final Optional<String> s3UploaderBucket;
private final Optional<String> s3UploaderKeyPattern;
private final Optional<String> s3UploaderFilenameHint;
private final Optional<String> directory;

@JsonCreator
public static SingularityS3UploaderFile fromString(String value) {
return new SingularityS3UploaderFile(value, Optional.<String>absent(), Optional.<String>absent(), Optional.<String>absent(), Optional.<String>absent());
}

@JsonCreator
public SingularityS3UploaderFile(@JsonProperty("filename") String filename,
@JsonProperty("s3UploaderBucket") Optional<String> s3UploaderBucket,
@JsonProperty("s3UploaderKeyPattern") Optional<String> s3UploaderKeyPattern,
@JsonProperty("s3UploaderFilenameHint") Optional<String> s3UploaderFilenameHint,
@JsonProperty("directory") Optional<String> directory) {
this.filename = filename;
this.s3UploaderBucket = s3UploaderBucket;
this.s3UploaderKeyPattern = s3UploaderKeyPattern;
this.s3UploaderFilenameHint = s3UploaderFilenameHint;
this.directory = directory;
}

public String getFilename() {
return filename;
}

public Optional<String> getS3UploaderBucket() {
return s3UploaderBucket;
}

public Optional<String> getS3UploaderKeyPattern() {
return s3UploaderKeyPattern;
}

public Optional<String> getS3UploaderFilenameHint() {
return s3UploaderFilenameHint;
}

public Optional<String> getDirectory() {
return directory;
}

@Override
public String toString() {
return "SingularityExecutorS3UploaderAdditionalFile[" +
"filename='" + filename + '\'' +
", s3UploaderBucket=" + s3UploaderBucket +
", s3UploaderKeyPattern=" + s3UploaderKeyPattern +
", s3UploaderFilenameHint=" + s3UploaderFilenameHint +
", directory=" + directory +
']';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package com.hubspot.singularity;

import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Optional;
import com.hubspot.deploy.EmbeddedArtifact;
import com.hubspot.deploy.ExecutorData;
import com.hubspot.deploy.ExternalArtifact;
import com.hubspot.deploy.S3Artifact;
import com.hubspot.deploy.S3ArtifactSignature;
import com.hubspot.singularity.executor.SingularityExecutorLogrotateFrequency;

public class SingularityTaskExecutorData extends ExecutorData {
private final List<SingularityS3UploaderFile> s3UploaderAdditionalFiles;
private final String defaultS3Bucket;
private final String s3UploaderKeyPattern;
private final String serviceLog;
private final String serviceFinishedTailLog;

public SingularityTaskExecutorData(ExecutorData executorData, List<SingularityS3UploaderFile> s3UploaderAdditionalFiles, String defaultS3Bucket, String s3UploaderKeyPattern, String serviceLog, String serviceFinishedTailLog) {
this(executorData.getCmd(),
executorData.getEmbeddedArtifacts(),
executorData.getExternalArtifacts(),
executorData.getS3Artifacts(),
executorData.getSuccessfulExitCodes(),
executorData.getUser(),
executorData.getRunningSentinel(),
executorData.getExtraCmdLineArgs(),
executorData.getLoggingTag(),
executorData.getLoggingExtraFields(),
executorData.getSigKillProcessesAfterMillis(),
executorData.getMaxTaskThreads(),
executorData.getPreserveTaskSandboxAfterFinish(),
executorData.getMaxOpenFiles(),
executorData.getSkipLogrotateAndCompress(),
executorData.getS3ArtifactSignatures(),
executorData.getLogrotateFrequency(),
s3UploaderAdditionalFiles,
defaultS3Bucket,
s3UploaderKeyPattern,
serviceLog,
serviceFinishedTailLog);
}

@JsonCreator
public SingularityTaskExecutorData(@JsonProperty("cmd") String cmd,
@JsonProperty("embeddedArtifacts") List<EmbeddedArtifact> embeddedArtifacts,
@JsonProperty("externalArtifacts") List<ExternalArtifact> externalArtifacts,
@JsonProperty("s3Artifacts") List<S3Artifact> s3Artifacts,
@JsonProperty("successfulExitCodes") List<Integer> successfulExitCodes,
@JsonProperty("user") Optional<String> user,
@JsonProperty("runningSentinel") Optional<String> runningSentinel,
@JsonProperty("extraCmdLineArgs") List<String> extraCmdLineArgs,
@JsonProperty("loggingTag") Optional<String> loggingTag,
@JsonProperty("loggingExtraFields") Map<String, String> loggingExtraFields,
@JsonProperty("sigKillProcessesAfterMillis") Optional<Long> sigKillProcessesAfterMillis,
@JsonProperty("maxTaskThreads") Optional<Integer> maxTaskThreads,
@JsonProperty("preserveTaskSandboxAfterFinish") Optional<Boolean> preserveTaskSandboxAfterFinish,
@JsonProperty("maxOpenFiles") Optional<Integer> maxOpenFiles,
@JsonProperty("skipLogrotateAndCompress") Optional<Boolean> skipLogrotateAndCompress,
@JsonProperty("s3ArtifactSignatures") Optional<List<S3ArtifactSignature>> s3ArtifactSignatures,
@JsonProperty("logrotateFrequency") Optional<SingularityExecutorLogrotateFrequency> logrotateFrequency,
@JsonProperty("s3UploaderAdditionalFiles") List<SingularityS3UploaderFile> s3UploaderAdditionalFiles,
@JsonProperty("defaultS3Bucket") String defaultS3Bucket,
@JsonProperty("s3UploaderKeyPattern") String s3UploaderKeyPattern,
@JsonProperty("serviceLog") String serviceLog,
@JsonProperty("serviceFinishedTailLog") String serviceFinishedTailLog) {
super(cmd, embeddedArtifacts, externalArtifacts, s3Artifacts, successfulExitCodes, user, runningSentinel, extraCmdLineArgs, loggingTag, loggingExtraFields,
sigKillProcessesAfterMillis, maxTaskThreads, preserveTaskSandboxAfterFinish, maxOpenFiles, skipLogrotateAndCompress, s3ArtifactSignatures, logrotateFrequency);
this.s3UploaderAdditionalFiles = s3UploaderAdditionalFiles;
this.defaultS3Bucket = defaultS3Bucket;
this.s3UploaderKeyPattern = s3UploaderKeyPattern;
this.serviceLog = serviceLog;
this.serviceFinishedTailLog = serviceFinishedTailLog;
}

public List<SingularityS3UploaderFile> getS3UploaderAdditionalFiles() {
return s3UploaderAdditionalFiles;
}

public String getDefaultS3Bucket() {
return defaultS3Bucket;
}

public String getS3UploaderKeyPattern() {
return s3UploaderKeyPattern;
}

public String getServiceLog() {
return serviceLog;
}

public String getServiceFinishedTailLog() {
return serviceFinishedTailLog;
}

@Override
public String toString() {
return "SingularityTaskExecutorData{" +
"s3UploaderAdditionalFiles=" + s3UploaderAdditionalFiles +
", defaultS3Bucket='" + defaultS3Bucket + '\'' +
", s3UploaderKeyPattern='" + s3UploaderKeyPattern + '\'' +
", serviceLog='" + serviceLog + '\'' +
", serviceFinishedTailLog='" + serviceFinishedTailLog + '\'' +
"} " + super.toString();
}
}
Loading

0 comments on commit 4690e9e

Please sign in to comment.