Search in sources :

Example 1 with EmbeddedArtifact

use of com.hubspot.deploy.EmbeddedArtifact in project Singularity by HubSpot.

the class SingularityExecutorTaskProcessBuilder method call.

@Override
public ProcessBuilder call() throws Exception {
    if (task.getTaskInfo().hasContainer() && task.getTaskInfo().getContainer().hasDocker()) {
        executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), TaskState.TASK_STARTING, String.format("Pulling image... (executor pid: %s)", executorPid), task.getLog());
        try {
            dockerUtils.pull(task.getTaskInfo().getContainer().getDocker().getImage());
        } catch (DockerException e) {
            throw new ProcessFailedException("Could not pull docker image", e);
        }
    }
    executorUtils.sendStatusUpdate(task.getDriver(), task.getTaskInfo().getTaskId(), TaskState.TASK_STARTING, String.format("Staging files... (executor pid: %s)", executorPid), task.getLog());
    taskArtifactFetcher = Optional.of(artifactFetcher.buildTaskFetcher(task));
    taskArtifactFetcher.get().fetchFiles(executorData.getEmbeddedArtifacts(), executorData.getS3Artifacts(), executorData.getS3ArtifactSignaturesOrEmpty(), executorData.getExternalArtifacts());
    task.getArtifactVerifier().checkSignatures(executorData.getS3Artifacts(), executorData.getS3ArtifactSignaturesOrEmpty());
    List<ArtifactList> artifactLists = new ArrayList<>();
    artifactLists.addAll(checkArtifactsForArtifactLists(executorData.getS3Artifacts()));
    artifactLists.addAll(checkArtifactsForArtifactLists(executorData.getS3ArtifactSignaturesOrEmpty()));
    artifactLists.addAll(checkArtifactsForArtifactLists(executorData.getExternalArtifacts()));
    if (!artifactLists.isEmpty()) {
        List<EmbeddedArtifact> embeddedArtifacts = new ArrayList<>();
        List<S3Artifact> s3Artifacts = new ArrayList<>();
        List<S3ArtifactSignature> s3ArtifactSignatures = new ArrayList<>();
        List<ExternalArtifact> externalArtifacts = new ArrayList<>();
        for (ArtifactList artifactList : artifactLists) {
            embeddedArtifacts.addAll(artifactList.getEmbeddedArtifacts());
            s3Artifacts.addAll(artifactList.getS3Artifacts());
            s3ArtifactSignatures.addAll(artifactList.getS3ArtifactSignatures());
            externalArtifacts.addAll(artifactList.getExternalArtifacts());
        }
        task.getLog().info("Found {} artifact lists with {} embedded, {} s3, {} external, fetching...", artifactLists.size(), embeddedArtifacts.size(), s3Artifacts.size() + s3ArtifactSignatures.size(), externalArtifacts.size());
        taskArtifactFetcher.get().fetchFiles(embeddedArtifacts, s3Artifacts, s3ArtifactSignatures, externalArtifacts);
        task.getArtifactVerifier().checkSignatures(s3Artifacts, s3ArtifactSignatures);
    }
    ProcessBuilder processBuilder = buildProcessBuilder(task.getTaskInfo(), executorData, task.getTaskDefinition().getServiceLogFileName());
    task.getTaskLogManager().setup();
    return processBuilder;
}
Also used : DockerException(com.spotify.docker.client.exceptions.DockerException) ArtifactList(com.hubspot.deploy.ArtifactList) ArrayList(java.util.ArrayList) S3ArtifactSignature(com.hubspot.deploy.S3ArtifactSignature) ExternalArtifact(com.hubspot.deploy.ExternalArtifact) ProcessFailedException(com.hubspot.singularity.runner.base.shared.ProcessFailedException) S3Artifact(com.hubspot.deploy.S3Artifact) EmbeddedArtifact(com.hubspot.deploy.EmbeddedArtifact)

Aggregations

ArtifactList (com.hubspot.deploy.ArtifactList)1 EmbeddedArtifact (com.hubspot.deploy.EmbeddedArtifact)1 ExternalArtifact (com.hubspot.deploy.ExternalArtifact)1 S3Artifact (com.hubspot.deploy.S3Artifact)1 S3ArtifactSignature (com.hubspot.deploy.S3ArtifactSignature)1 ProcessFailedException (com.hubspot.singularity.runner.base.shared.ProcessFailedException)1 DockerException (com.spotify.docker.client.exceptions.DockerException)1 ArrayList (java.util.ArrayList)1