From 327d928229e377649ed9d5185321e8897243c4e4 Mon Sep 17 00:00:00 2001 From: Ben Sherman Date: Mon, 6 Mar 2023 14:36:58 -0600 Subject: [PATCH] Add azure batch pool virtualNetwork option (#3723) Signed-off-by: Ben Sherman Co-authored-by: Paolo Di Tommaso --- docs/azure.rst | 1 + .../main/nextflow/cloud/azure/batch/AzBatchService.groovy | 6 +++++- .../src/main/nextflow/cloud/azure/config/AzPoolOpts.groovy | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/azure.rst b/docs/azure.rst index 81545ee694..3154fe81d7 100644 --- a/docs/azure.rst +++ b/docs/azure.rst @@ -418,6 +418,7 @@ azure.batch.pools..scaleInterval Specify the interval at which to azure.batch.pools..schedulePolicy Specify the scheduling policy for the pool identified with ````. It can be either ``spread`` or ``pack`` (default: ``spread``). azure.batch.pools..privileged Enable the task to run with elevated access. Ignored if `runAs` is set (default: ``false``). azure.batch.pools..runAs Specify the username under which the task is run. The user must already exist on each node of the pool. +azure.batch.pools..virtualNetwork Specify the subnet ID of a virtual network in which to create the pool (requires version ``23.03.0-edge`` or later). azure.registry.server Specify the container registry from which to pull the Docker images (default: ``docker.io``, requires ``nf-azure@0.9.8``). azure.registry.userName Specify the username to connect to a private container registry (requires ``nf-azure@0.9.8``). azure.registry.password Specify the password to connect to a private container registry (requires ``nf-azure@0.9.8``). diff --git a/plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchService.groovy b/plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchService.groovy index 2ade51bc9b..73644ecb64 100644 --- a/plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchService.groovy +++ b/plugins/nf-azure/src/main/nextflow/cloud/azure/batch/AzBatchService.groovy @@ -40,6 +40,7 @@ import com.microsoft.azure.batch.protocol.models.ContainerRegistry import com.microsoft.azure.batch.protocol.models.ElevationLevel import com.microsoft.azure.batch.protocol.models.ImageInformation import com.microsoft.azure.batch.protocol.models.MountConfiguration +import com.microsoft.azure.batch.protocol.models.NetworkConfiguration import com.microsoft.azure.batch.protocol.models.OutputFile import com.microsoft.azure.batch.protocol.models.OutputFileBlobContainerDestination import com.microsoft.azure.batch.protocol.models.OutputFileDestination @@ -663,7 +664,6 @@ class AzBatchService implements Closeable { .withCommandLine('bash -c "chmod +x azcopy && mkdir \$AZ_BATCH_NODE_SHARED_DIR/bin/ && cp azcopy \$AZ_BATCH_NODE_SHARED_DIR/bin/" ') .withResourceFiles(resourceFiles) - final poolParams = new PoolAddParameter() .withId(spec.poolId) .withVirtualMachineConfiguration(poolVmConfig(spec.opts)) @@ -674,6 +674,10 @@ class AzBatchService implements Closeable { .withTaskSlotsPerNode(spec.vmType.numberOfCores) .withStartTask(poolStartTask) + // virtual network + if( spec.opts.virtualNetwork ) + poolParams.withNetworkConfiguration( new NetworkConfiguration().withSubnetId(spec.opts.virtualNetwork) ) + // scheduling policy if( spec.opts.schedulePolicy ) { final pol = ComputeNodeFillType.fromString(spec.opts.schedulePolicy) diff --git a/plugins/nf-azure/src/main/nextflow/cloud/azure/config/AzPoolOpts.groovy b/plugins/nf-azure/src/main/nextflow/cloud/azure/config/AzPoolOpts.groovy index c7ad6e62d5..178c34e47f 100644 --- a/plugins/nf-azure/src/main/nextflow/cloud/azure/config/AzPoolOpts.groovy +++ b/plugins/nf-azure/src/main/nextflow/cloud/azure/config/AzPoolOpts.groovy @@ -65,6 +65,8 @@ class AzPoolOpts implements CacheFunnel { String userName String password + String virtualNetwork + AzPoolOpts() { this(Collections.emptyMap()) } @@ -86,6 +88,7 @@ class AzPoolOpts implements CacheFunnel { this.registry = opts.registry this.userName = opts.userName this.password = opts.password + this.virtualNetwork = opts.virtualNetwork } @Override @@ -104,6 +107,7 @@ class AzPoolOpts implements CacheFunnel { hasher.putBoolean(autoScale) hasher.putUnencodedChars(scaleFormula ?: '') hasher.putUnencodedChars(schedulePolicy ?: '') + hasher.putUnencodedChars(virtualNetwork ?: '') return hasher }