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

WX-744 Optionally rewrite blob paths to appear as local paths #6941

Merged
merged 4 commits into from
Nov 1, 2022
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
1 change: 1 addition & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ lazy val tesBackend = (project in backendRoot / "tes")
.dependsOn(sfsBackend)
.dependsOn(ftpFileSystem)
.dependsOn(drsFileSystem)
.dependsOn(azureBlobFileSystem)
.dependsOn(backend % "test->test")
.dependsOn(common % "test->test")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ class TesAsyncBackendJobExecutionActor(override val standardParams: StandardAsyn

private val tesEndpoint = workflowDescriptor.workflowOptions.getOrElse("endpoint", tesConfiguration.endpointURL)

// Temporary support for configuring the format we use to send BlobPaths to TES.
// Added 10/2022 as a workaround for the CromwellOnAzure TES server expecting
// blob containers to be mounted via blobfuse rather than addressed natively.
private val transformBlobToLocalPaths: Boolean =
configurationDescriptor.backendConfig
.getAs[Boolean]("transform-blob-to-local-path")
.getOrElse(false)

override lazy val jobTag: String = jobDescriptor.key.tag

private val outputMode = validate {
Expand Down Expand Up @@ -148,7 +156,7 @@ class TesAsyncBackendJobExecutionActor(override val standardParams: StandardAsyn
mode)
})

tesTask.map(TesTask.makeTask)
tesTask.map(TesTask.makeTask(_, transformBlobToLocalPaths))
}

def writeScriptFile(): Future[Unit] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,21 +258,37 @@ object TesTask {
)
}

def makeTask(tesTask: TesTask): Task = {
def makeTask(tesTask: TesTask, transformBlobToLocalPath: Boolean = false): Task = {
val inputs = if (transformBlobToLocalPath) transformInputs(tesTask.inputs) else tesTask.inputs
val outputs = if (transformBlobToLocalPath) transformOutputs(tesTask.outputs) else tesTask.outputs
Task(
id = None,
state = None,
name = Option(tesTask.name),
description = Option(tesTask.description),
inputs = Option(tesTask.inputs),
outputs = Option(tesTask.outputs),
inputs = Option(inputs),
outputs = Option(outputs),
resources = Option(tesTask.resources),
executors = tesTask.executors,
volumes = None,
tags = Option(tesTask.jobDescriptor.workflowDescriptor.customLabels.asMap),
logs = None
)
}

def transformInputs(inputs: Seq[Input]): Seq[Input] = inputs.map(i =>
i.copy(url=i.url.map(transformBlobString))
)

def transformOutputs(outputs: Seq[Output]): Seq[Output] = outputs.map(i =>
i.copy(url=i.url.map(transformBlobString))
)

val blobSegment = ".blob.core.windows.net"
def transformBlobString(s: String): String = if (s.contains(blobSegment)) {
s.replaceFirst("https:/", "").replaceFirst(blobSegment, "")
} else s

}

// Field requirements in classes below based off GA4GH schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,28 @@ class TesTaskSpec

task.tags shouldBe Option(Map("foo" -> "bar"))
}

it should "apply the correct transformation to a blob path" in {
val orig = "https://coaexternalstorage.blob.core.windows.net/cromwell/mydir/myfile.txt"
TesTask.transformBlobString(orig) shouldBe "/coaexternalstorage/cromwell/mydir/myfile.txt"
}

it should "not transform a non-blob path" in {
val orig = "https://some-bogus-url.test/cromwell/mydir/myfile.txt"
TesTask.transformBlobString(orig) shouldBe orig
}

it should "transform inputs" in {
val baseInput = Input(
Option("name"),
Option("descr"),
Option("https://coaexternalstorage.blob.core.windows.net/cromwell/mydir/myfile.txt"),
"path",
Option("type"),
Option("content"),
)
val inputs = Option(Seq(baseInput))
val outcome = inputs.map(TesTask.transformInputs)
outcome.get.head.url.get shouldBe "/coaexternalstorage/cromwell/mydir/myfile.txt"
}
}