-
Notifications
You must be signed in to change notification settings - Fork 630
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
Azure Batch configurable startTask #4841
Changes from 21 commits
da3a436
413ea8d
d714263
59d0b31
a99e616
baaac49
e0bf9f7
16476f8
ad4f2a1
be15693
8ae8eae
119c3ca
b42d983
33969d3
0abaf47
7c2af6a
cd416e4
c145e45
e5c29cf
128e612
98ce78d
5497860
54d07f4
c61e10e
b53386c
b5ce455
21d780c
cb24ef2
5b2d406
c8cc1e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -430,7 +430,7 @@ class AzBatchService implements Closeable { | |||||||||||||||||||||||
|
||||||||||||||||||||||||
return new TaskAddParameter() | ||||||||||||||||||||||||
.withId(taskId) | ||||||||||||||||||||||||
.withUserIdentity(userIdentity(pool.opts.privileged, pool.opts.runAs)) | ||||||||||||||||||||||||
.withUserIdentity(userIdentity(pool.opts.privileged, pool.opts.runAs, AutoUserScope.TASK)) | ||||||||||||||||||||||||
.withContainerSettings(containerOpts) | ||||||||||||||||||||||||
.withCommandLine(cmd) | ||||||||||||||||||||||||
.withResourceFiles(resourceFileUrls(task,sas)) | ||||||||||||||||||||||||
|
@@ -660,7 +660,7 @@ class AzBatchService implements Closeable { | |||||||||||||||||||||||
* | ||||||||||||||||||||||||
* https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/batch/batch-docker-container-workloads.md#:~:text=Run%20container%20applications%20on%20Azure,compatible%20containers%20on%20the%20nodes. | ||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||
final containerConfig = new ContainerConfiguration().withType(DOCKER_COMPATIBLE); | ||||||||||||||||||||||||
final containerConfig = new ContainerConfiguration().withType(DOCKER_COMPATIBLE) | ||||||||||||||||||||||||
final registryOpts = config.registry() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
if( registryOpts && registryOpts.isConfigured() ) { | ||||||||||||||||||||||||
|
@@ -681,18 +681,40 @@ class AzBatchService implements Closeable { | |||||||||||||||||||||||
.withContainerConfiguration(containerConfig) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
protected StartTask createStartTask() { | ||||||||||||||||||||||||
if( config.batch().getCopyToolInstallMode() != CopyToolInstallMode.node ) | ||||||||||||||||||||||||
return null | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
final resourceFiles = new ArrayList(10) | ||||||||||||||||||||||||
resourceFiles << new ResourceFile() | ||||||||||||||||||||||||
.withHttpUrl(AZCOPY_URL) | ||||||||||||||||||||||||
.withFilePath('azcopy') | ||||||||||||||||||||||||
protected StartTask createStartTask(AzPoolOpts opts) { | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
def startCmd = [] as ArrayList | ||||||||||||||||||||||||
final resourceFiles = [] as ArrayList | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
return new StartTask() | ||||||||||||||||||||||||
.withCommandLine('bash -c "chmod +x azcopy && mkdir \$AZ_BATCH_NODE_SHARED_DIR/bin/ && cp azcopy \$AZ_BATCH_NODE_SHARED_DIR/bin/" ') | ||||||||||||||||||||||||
.withResourceFiles(resourceFiles) | ||||||||||||||||||||||||
// Get any custom start task command | ||||||||||||||||||||||||
if ( opts.startTask ) { | ||||||||||||||||||||||||
startCmd << opts.startTask | ||||||||||||||||||||||||
log.debug "Adding custom start task to command: ${opts.startTask}" | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// If enabled, append azcopy installer to start task command | ||||||||||||||||||||||||
if( config.batch().getCopyToolInstallMode() == CopyToolInstallMode.node ) { | ||||||||||||||||||||||||
startCmd << 'chmod +x azcopy && mkdir \$AZ_BATCH_NODE_SHARED_DIR/bin/ && cp azcopy \$AZ_BATCH_NODE_SHARED_DIR/bin/' | ||||||||||||||||||||||||
resourceFiles << new ResourceFile() | ||||||||||||||||||||||||
.withHttpUrl(AZCOPY_URL) | ||||||||||||||||||||||||
.withFilePath('azcopy') | ||||||||||||||||||||||||
log.debug "Adding azcopy installer to start task" | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
final startTaskCmd = "bash -c \"${startCmd.join('; ')}\"" | ||||||||||||||||||||||||
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. What if thre's no startTask script and copyToolInstallMode != node? this is going to be empty. 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. Ah correct. It should return null instead of an empty task (though I guess an empty task will work first time). 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. It would be nice to add a unit test for 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. 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. Tests added: f9708b0 |
||||||||||||||||||||||||
log.debug "Start task final command: $startTaskCmd" | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
// If there is no start task contents we return a null to indicate no start task | ||||||||||||||||||||||||
if ( startCmd.isEmpty() && resourceFiles.isEmpty() ) { | ||||||||||||||||||||||||
return null | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
// else return a StartTask object with the start task command and resource files | ||||||||||||||||||||||||
return new StartTask() | ||||||||||||||||||||||||
.withCommandLine(startTaskCmd) | ||||||||||||||||||||||||
.withResourceFiles(resourceFiles) | ||||||||||||||||||||||||
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. Wonder if the 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. One of my use cases was to remove the azcopy install. Adding the installer feels unexpected, leaving it out is simple so problem solving should be easier. And with Fusion you don't need azcopy. 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. I think it makes sense to allow the customisation of the I've added an option to disable explicitly or implicitly when fusion is enabled. See here 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. Seems sensible! 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. I'm not 100% clear how the two will interact though. We should probably do something like this:
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. Kind of, but it should be taken in consideration that that now the azcopy command can be absent. See here nextflow/plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchService.groovy Lines 685 to 695 in 74d7d7a
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. OK implemented now: 33969d3 |
||||||||||||||||||||||||
.withUserIdentity(userIdentity(opts.startTaskPrivileged, null, AutoUserScope.POOL)) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
protected void createPool(AzVmPoolSpec spec) { | ||||||||||||||||||||||||
|
@@ -706,7 +728,7 @@ class AzBatchService implements Closeable { | |||||||||||||||||||||||
// https://docs.microsoft.com/en-us/azure/batch/batch-parallel-node-tasks | ||||||||||||||||||||||||
.withTaskSlotsPerNode(spec.vmType.numberOfCores) | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
final startTask = createStartTask() | ||||||||||||||||||||||||
final startTask = createStartTask(spec.opts) | ||||||||||||||||||||||||
if( startTask ) { | ||||||||||||||||||||||||
poolParams .withStartTask(startTask) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
@@ -860,14 +882,14 @@ class AzBatchService implements Closeable { | |||||||||||||||||||||||
} | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
protected UserIdentity userIdentity(boolean privileged, String runAs) { | ||||||||||||||||||||||||
protected UserIdentity userIdentity(boolean privileged, String runAs, AutoUserScope scope) { | ||||||||||||||||||||||||
UserIdentity identity = new UserIdentity() | ||||||||||||||||||||||||
if (runAs) { | ||||||||||||||||||||||||
identity.withUserName(runAs) | ||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||
identity.withAutoUser(new AutoUserSpecification() | ||||||||||||||||||||||||
.withElevationLevel(privileged ? ElevationLevel.ADMIN : ElevationLevel.NON_ADMIN) | ||||||||||||||||||||||||
.withScope(AutoUserScope.TASK)) | ||||||||||||||||||||||||
.withScope(scope)) | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
return identity | ||||||||||||||||||||||||
} | ||||||||||||||||||||||||
|
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.
would make sense to run it always as privileged ?
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.
you don't need to if you want to add some basic software to the PATH (azcopy), so I think configurable makes sense.
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.
then, I'd ask to have this organised as
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.
I thought you'd say that. I don't know how, give me some time to work it out.
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.
it's enough to add a small class
and create it using the usual pattern in the config
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.
It will be merged to this branch from here, once finished adamrtalbot#1
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.
All changes in now. startTask is a map: