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

Burwood dockerhub credentials #7141

Merged
merged 3 commits into from
May 22, 2023
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 @@ -49,6 +49,7 @@ import wom.values._

import java.io.{FileNotFoundException, OutputStreamWriter}
import java.nio.charset.Charset
import java.util.Base64
import scala.concurrent.Future
import scala.concurrent.duration._
import scala.io.Source
Expand Down Expand Up @@ -563,6 +564,13 @@ class GcpBatchAsyncBackendJobExecutionActor(override val standardParams: Standar
val referenceDisksToMount =
batchAttributes.referenceFileToDiskImageMappingOpt.map(getReferenceDisksToMount(_, inputFilePaths))

val dockerhubCredentials: (String, String) = {
new String(Base64.getDecoder.decode(batchAttributes.dockerhubToken), "UTF-8").split(":", 2) match {
case Array(username, password) => (username, password)
case _ => ("", "")
}
}

val workflowOptions = workflowDescriptor.workflowOptions

val monitoringImage = new MonitoringImage(
Expand Down Expand Up @@ -625,6 +633,7 @@ class GcpBatchAsyncBackendJobExecutionActor(override val standardParams: Standar
checkpointingConfiguration,
enableSshAccess = enableSshAccess,
vpcNetworkAndSubnetworkProjectLabels = data.vpcNetworkAndSubnetworkProjectLabels,
dockerhubCredentials = dockerhubCredentials
//dockerImageCacheDiskOpt = isDockerImageCacheUsageRequested.option(dockerImageCacheDiskOpt).flatten
)
case Some(other) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ object GcpBatchRequestFactory {
checkpointingConfiguration: CheckpointingConfiguration,
enableSshAccess: Boolean,
vpcNetworkAndSubnetworkProjectLabels: Option[VpcAndSubnetworkProjectLabelValues],
dockerhubCredentials: (String, String)
//dockerImageCacheDiskOpt: Option[String]
) {
def literalInputs = inputOutputParameters.literalInputParameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ case class GcpBatchConfigurationAttributes(project: String,
computeServiceAccount: String,
auths: GcpBatchAuths,
restrictMetadataAccess: Boolean,
dockerhubToken: String,
enableFuse: Boolean,
executionBucket: String,
location: String,
Expand Down Expand Up @@ -196,6 +197,11 @@ object GcpBatchConfigurationAttributes extends GcpBatchDockerCacheMappingOperati
val genomicsEnableFuse: ErrorOr[Boolean] = validate {
backendConfig.as[Option[Boolean]]("genomics.enable-fuse").getOrElse(false)
}

val dockerhubToken: ErrorOr[String] = validate {
backendConfig.as[Option[String]]("dockerhub.token").getOrElse("")
}

val gcsFilesystemAuthName: ErrorOr[String] = validate {
backendConfig.as[String]("filesystems.gcs.auth")
}
Expand Down Expand Up @@ -266,6 +272,7 @@ object GcpBatchConfigurationAttributes extends GcpBatchDockerCacheMappingOperati
genomicsName: String,
location: String,
restrictMetadata: Boolean,
dockerhubToken: String,
enableFuse: Boolean,
gcsName: String,
qps: Int Refined Positive,
Expand All @@ -289,6 +296,7 @@ object GcpBatchConfigurationAttributes extends GcpBatchDockerCacheMappingOperati
computeServiceAccount = computeServiceAccount,
auths = GcpBatchAuths(genomicsAuth, gcsAuth),
restrictMetadataAccess = restrictMetadata,
dockerhubToken = dockerhubToken,
enableFuse = enableFuse,
executionBucket = bucket,
location = location,
Expand All @@ -313,6 +321,7 @@ object GcpBatchConfigurationAttributes extends GcpBatchDockerCacheMappingOperati
genomicsAuthName,
location,
genomicsRestrictMetadataAccess,
dockerhubToken,
genomicsEnableFuse,
gcsFilesystemAuthName,
qpsValidation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,26 @@ object RunnableBuilder {
)
}

//privateDockerKeyAndToken: Option[CreatePipelineDockerKeyAndToken],
//fuseEnabled: Boolean)
def userRunnable(docker: String,
scriptContainerPath: String,
jobShell: String,
//privateDockerKeyAndToken: Option[CreatePipelineDockerKeyAndToken],
volumes: List[Volume]): Runnable.Builder = {

//val dockerImageIdentifier = DockerImageIdentifier.fromString(docker)

val container = Container.newBuilder
.setImageUri(docker)
.setEntrypoint(jobShell)
.addCommands(scriptContainerPath)
volumes: List[Volume],
dockerhubCredentials: (String, String)): Runnable.Builder = {

val container = (dockerhubCredentials._1, dockerhubCredentials._2) match {
case (username, password) if username.nonEmpty && password.nonEmpty =>
Container.newBuilder
.setImageUri(docker)
.setEntrypoint(jobShell)
.addCommands(scriptContainerPath)
.setUsername(username)
.setPassword(password)
case _ =>
Container.newBuilder
.setImageUri(docker)
.setEntrypoint(jobShell)
.addCommands(scriptContainerPath)
}
Runnable.newBuilder()
.setContainer(container)
.withVolumes(volumes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package cromwell.backend.google.batch.runnable
import com.google.cloud.batch.v1.{Runnable, Volume}
import cromwell.backend.google.batch.api.GcpBatchRequestFactory.CreatePipelineParameters


trait UserRunnable {

def userRunnables(createPipelineParameters: CreatePipelineParameters, volumes: List[Volume]): List[Runnable] = {
val userRunnable = RunnableBuilder.userRunnable(
docker = createPipelineParameters.dockerImage,
scriptContainerPath = createPipelineParameters.commandScriptContainerPath.pathAsString,
jobShell = createPipelineParameters.jobShell,
volumes = volumes
volumes = volumes,
dockerhubCredentials = createPipelineParameters.dockerhubCredentials
// not necessary for now
//createPipelineParameters.privateDockerKeyAndEncryptedToken,
//createPipelineParameters.fuseEnabled
Expand Down