-
Notifications
You must be signed in to change notification settings - Fork 676
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
[draft] Azure Batch worker pool supports managed identity #5670
Open
adamrtalbot
wants to merge
10
commits into
nextflow-io:master
Choose a base branch
from
adamrtalbot:pass_managed_identity_client_id_to_azure_pool
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6720dd8
feat: Azure Batch worker pool supports managed identity
adamrtalbot e3653df
Merge branch 'master' into pass_managed_identity_client_id_to_azure_pool
adamrtalbot cb57238
docs
adamrtalbot 7110d6d
Support for using azcopy with managed identity
adamrtalbot 8d28def
Use native AZ_BATCH_TASK_DIR instead of $PWD for azcopy files and bin/
adamrtalbot ae76265
Merge branch 'master' into pass_managed_identity_client_id_to_azure_pool
adamrtalbot 8d3a663
Merge branch 'master' into pass_managed_identity_client_id_to_azure_pool
adamrtalbot 327d2a9
Merge branch 'master' into pass_managed_identity_client_id_to_azure_pool
adamrtalbot f7719ca
Pass MSI ID to Fusion
adamrtalbot c93dc78
Add some Fusion debugging
adamrtalbot 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 |
---|---|---|
|
@@ -49,6 +49,7 @@ import com.azure.compute.batch.models.ContainerConfiguration | |
import com.azure.compute.batch.models.ContainerRegistryReference | ||
import com.azure.compute.batch.models.ContainerType | ||
import com.azure.compute.batch.models.ElevationLevel | ||
import com.azure.compute.batch.models.EnvironmentSetting | ||
import com.azure.compute.batch.models.MetadataItem | ||
import com.azure.compute.batch.models.MountConfiguration | ||
import com.azure.compute.batch.models.NetworkConfiguration | ||
|
@@ -496,8 +497,13 @@ class AzBatchService implements Closeable { | |
if( fusionEnabled ) { | ||
opts += "--privileged " | ||
for( Map.Entry<String,String> it : launcher.fusionEnv() ) { | ||
opts += "-e $it.key=$it.value " | ||
// This is a bad solution and breaks Fusion for everyone | ||
if (!(pool.opts.managedIdentityId && it.key == "AZURE_STORAGE_SAS_TOKEN")) { | ||
opts += "-e $it.key=$it.value " | ||
} | ||
} | ||
// For testing purposes only, remove before merging | ||
opts += "-e FUSION_LOG_LEVEL=trace -e FUSION_LOG_OUTPUT=stdout " | ||
} | ||
|
||
// Create container settings | ||
|
@@ -516,13 +522,25 @@ class AzBatchService implements Closeable { | |
constraints.setMaxWallClockTime( Duration.of(task.config.getTime().toMillis(), ChronoUnit.MILLIS) ) | ||
|
||
log.trace "[AZURE BATCH] Submitting task: $taskId, cpus=${task.config.getCpus()}, mem=${task.config.getMemory()?:'-'}, slots: $slots" | ||
|
||
// Add environment variables for managed identity if configured | ||
final env = [:] as Map<String,String> | ||
if( pool?.opts?.managedIdentityId ) { | ||
env.put('AZCOPY_AUTO_LOGIN_TYPE', 'MSI') // azcopy | ||
env.put('AZCOPY_MSI_CLIENT_ID', pool.opts.managedIdentityId) // azcopy | ||
Comment on lines
+529
to
+530
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. These looks unrelated |
||
env.put('FUSION_AZ_MSI_CLIENT_ID', pool.opts.managedIdentityId) // fusion | ||
} | ||
|
||
return new BatchTaskCreateContent(taskId, cmd) | ||
.setUserIdentity(userIdentity(pool.opts.privileged, pool.opts.runAs, AutoUserScope.TASK)) | ||
.setContainerSettings(containerOpts) | ||
.setResourceFiles(resourceFileUrls(task, sas)) | ||
.setOutputFiles(outputFileUrls(task, sas)) | ||
.setRequiredSlots(slots) | ||
.setConstraints(constraints) | ||
.setEnvironmentSettings(env.collect { name, value -> | ||
new EnvironmentSetting(name).setValue(value) | ||
}) | ||
} | ||
|
||
AzTaskKey runTask(String poolId, String jobId, TaskRun task) { | ||
|
@@ -583,6 +601,13 @@ class AzBatchService implements Closeable { | |
List<OutputFile> result = new ArrayList<>(20) | ||
result << destFile(TaskRun.CMD_EXIT, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_LOG, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_OUTFILE, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_ERRFILE, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_SCRIPT, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_RUN, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_STAGE, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_TRACE, task.workDir, sas) | ||
result << destFile(TaskRun.CMD_ENV, task.workDir, sas) | ||
return result | ||
} | ||
|
||
|
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
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 should not be affected |
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
3 changes: 3 additions & 0 deletions
3
plugins/nf-azure/src/test/nextflow/cloud/azure/batch/AzBatchTaskHandlerTest.groovy
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
Oops, something went wrong.
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.
This breaks Fusion for everyone who isn't using managed identities. Ideally we take the pool.opts when creating the
launcher
but I've ran out of time.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.
What's the rationale? remove
AZURE_STORAGE_SAS_TOKEN
whenpool.opts.managedIdentityId
is provided?