-
Notifications
You must be signed in to change notification settings - Fork 360
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-859 Accept workflow execution identity in config #6967
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1f8dda7
WX-859 Accept workflow execution identity in config
kraefrei 6e35a6b
Clean up separation of used identity logic
kraefrei 7b640f4
Fix tests with previous refactor
kraefrei 27eaedf
Fix test name
kraefrei 348052d
Clean up typo and some scala
kraefrei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,10 @@ package cromwell.backend.impl.tes | |
import common.collections.EnhancedCollections._ | ||
import common.util.StringUtil._ | ||
import cromwell.backend.impl.tes.OutputMode.OutputMode | ||
import cromwell.backend.{BackendConfigurationDescriptor, BackendJobDescriptor, BackendWorkflowDescriptor} | ||
import cromwell.backend.{BackendConfigurationDescriptor, BackendJobDescriptor} | ||
import cromwell.core.logging.JobLogger | ||
import cromwell.core.path.{DefaultPathBuilder, Path} | ||
import net.ceedubs.ficus.Ficus._ | ||
import wdl.draft2.model.FullyQualifiedName | ||
import wdl4s.parser.MemoryUnit | ||
import wom.InstantiatedCommand | ||
|
@@ -16,6 +17,8 @@ import wom.values._ | |
import scala.language.postfixOps | ||
import scala.util.Try | ||
|
||
final case class WorkflowExecutionIdentityConfig(value: String) {override def toString: String = value.toString} | ||
final case class WorkflowExecutionIdentityOption(value: String) {override def toString: String = value} | ||
final case class TesTask(jobDescriptor: BackendJobDescriptor, | ||
configurationDescriptor: BackendConfigurationDescriptor, | ||
jobLogger: JobLogger, | ||
|
@@ -32,6 +35,16 @@ final case class TesTask(jobDescriptor: BackendJobDescriptor, | |
private val workflowDescriptor = jobDescriptor.workflowDescriptor | ||
private val workflowName = workflowDescriptor.callable.name | ||
private val fullyQualifiedTaskName = jobDescriptor.taskCall.fullyQualifiedName | ||
private val workflowExecutionIdentityConfig: Option[WorkflowExecutionIdentityConfig] = | ||
configurationDescriptor.backendConfig | ||
.getAs[String]("workflow-execution-identity") | ||
.map(WorkflowExecutionIdentityConfig) | ||
private val workflowExecutionIdentifyOption: Option[WorkflowExecutionIdentityOption] = | ||
workflowDescriptor | ||
.workflowOptions | ||
.get(TesWorkflowOptionKeys.WorkflowExecutionIdentity) | ||
.toOption | ||
.map(WorkflowExecutionIdentityOption) | ||
val name: String = fullyQualifiedTaskName | ||
val description: String = jobDescriptor.toString | ||
|
||
|
@@ -212,7 +225,15 @@ final case class TesTask(jobDescriptor: BackendJobDescriptor, | |
result | ||
} | ||
|
||
val resources: Resources = TesTask.makeResources(runtimeAttributes, workflowDescriptor) | ||
val preferedWorkflowExecutionIdentity = TesTask.getPreferredWorkflowExecutionIdentity( | ||
workflowExecutionIdentityConfig, | ||
workflowExecutionIdentifyOption | ||
) | ||
|
||
val resources: Resources = TesTask.makeResources( | ||
runtimeAttributes, | ||
preferedWorkflowExecutionIdentity | ||
) | ||
|
||
val executors = Seq(Executor( | ||
image = dockerImageUsed, | ||
|
@@ -226,21 +247,26 @@ final case class TesTask(jobDescriptor: BackendJobDescriptor, | |
} | ||
|
||
object TesTask { | ||
// Helper to determine which source to use for a workflowExecutionIdentity | ||
def getPreferredWorkflowExecutionIdentity(configIdentity: Option[WorkflowExecutionIdentityConfig], | ||
workflowOptionsIdentity: Option[WorkflowExecutionIdentityOption]): Option[String] = { | ||
(configIdentity, workflowOptionsIdentity) match { | ||
case (Some(configId), _) => Some(configId.value) | ||
case (None, Some(workflowOptionsId)) => Some(workflowOptionsId.value) | ||
case _ => None | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks correct, but here's a shorter way:
|
||
} | ||
def makeResources(runtimeAttributes: TesRuntimeAttributes, | ||
workflowDescriptor: BackendWorkflowDescriptor): Resources = { | ||
workflowExecutionId: Option[String]): Resources = { | ||
|
||
// This was added in BT-409 to let us pass information to an Azure | ||
// TES server about which user identity to run tasks as. | ||
// Note that we validate the type of WorkflowExecutionIdentity | ||
// in TesInitializationActor. | ||
val backendParameters = runtimeAttributes.backendParameters ++ | ||
workflowDescriptor | ||
.workflowOptions | ||
.get(TesWorkflowOptionKeys.WorkflowExecutionIdentity) | ||
.toOption | ||
workflowExecutionId | ||
.map(TesWorkflowOptionKeys.WorkflowExecutionIdentity -> Option(_)) | ||
.toMap | ||
|
||
val disk :: ram :: _ = Seq(runtimeAttributes.disk, runtimeAttributes.memory) map { | ||
case Some(x) => | ||
Option(x.to(MemoryUnit.GB).amount) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such a nitpick, but this seems to be an ever-so-subtle typo that might hurt someone not using autocomplete...
workflowExecutionIdentifyOption
->workflowExecutionIdentityOption
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof good catch!