diff --git a/docs/reference/config.md b/docs/reference/config.md index f8e678fa45..586055d267 100644 --- a/docs/reference/config.md +++ b/docs/reference/config.md @@ -923,6 +923,13 @@ The following settings are available: ::: : List of custom mount options for `gcsfuse` (default: `['-o rw', '-implicit-dirs']`). +`google.batch.installOpsAgent` +: Enable the installation of the Ops Agent on Google Batch instances for enhanced monitoring and logging (default: `false`). + +: :::{note} + The Ops Agent requires a compatible boot disk image. For Google Batch, use [Batch-debian images](https://docs.cloud.google.com/batch/docs/vm-os-environment-overview#vm-os-image-options) (e.g., `batch-debian`) with `google.batch.bootDiskImage`. The default Container-Optimized OS (`batch-cos`) is not compatible with the Ops Agent. + ::: + `google.batch.logsPath` : :::{versionadded} 25.11.0-edge ::: diff --git a/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchTaskHandler.groovy b/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchTaskHandler.groovy index f5f4da785d..303a517a20 100644 --- a/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchTaskHandler.groovy +++ b/plugins/nf-google/src/main/nextflow/cloud/google/batch/GoogleBatchTaskHandler.groovy @@ -410,6 +410,9 @@ class GoogleBatchTaskHandler extends TaskHandler implements FusionAwareTask { instancePolicyOrTemplate.setPolicy( instancePolicy ) } + if( batchConfig.installOpsAgent ) + instancePolicyOrTemplate.setInstallOpsAgent( true ) + allocationPolicy.addInstances(instancePolicyOrTemplate) // network policy diff --git a/plugins/nf-google/src/main/nextflow/cloud/google/batch/client/BatchConfig.groovy b/plugins/nf-google/src/main/nextflow/cloud/google/batch/client/BatchConfig.groovy index 154fc4d4b3..477c28256a 100644 --- a/plugins/nf-google/src/main/nextflow/cloud/google/batch/client/BatchConfig.groovy +++ b/plugins/nf-google/src/main/nextflow/cloud/google/batch/client/BatchConfig.groovy @@ -84,6 +84,12 @@ class BatchConfig implements ConfigScope { """) final boolean installGpuDrivers + @ConfigOption + @Description(""" + Enable the installation of the Ops Agent on Google Batch instances for enhanced monitoring and logging (default: `false`). + """) + final boolean installOpsAgent + @ConfigOption @Description(""" The Google Cloud Storage path where job logs should be stored, e.g. `gs://my-logs-bucket/logs`. @@ -147,6 +153,7 @@ class BatchConfig implements ConfigScope { cpuPlatform = opts.cpuPlatform gcsfuseOptions = opts.gcsfuseOptions as List ?: DEFAULT_GCSFUSE_OPTS installGpuDrivers = opts.installGpuDrivers as boolean + installOpsAgent = opts.installOpsAgent as boolean logsPath = opts.logsPath maxSpotAttempts = opts.maxSpotAttempts != null ? opts.maxSpotAttempts as int : DEFAULT_MAX_SPOT_ATTEMPTS network = opts.network diff --git a/plugins/nf-google/src/test/nextflow/cloud/google/batch/GoogleBatchTaskHandlerTest.groovy b/plugins/nf-google/src/test/nextflow/cloud/google/batch/GoogleBatchTaskHandlerTest.groovy index 9525def0bf..3b2a64db03 100644 --- a/plugins/nf-google/src/test/nextflow/cloud/google/batch/GoogleBatchTaskHandlerTest.groovy +++ b/plugins/nf-google/src/test/nextflow/cloud/google/batch/GoogleBatchTaskHandlerTest.groovy @@ -158,6 +158,7 @@ class GoogleBatchTaskHandlerTest extends Specification { getServiceAccountEmail() >> 'foo@bar.baz' getSubnetwork() >> 'subnet-1' usePrivateAddress >> true + installOpsAgent >> true logsPath() >> LOGS_PATH } } @@ -224,6 +225,7 @@ class GoogleBatchTaskHandlerTest extends Specification { allocationPolicy.getLocation().getAllowedLocations(0) == 'zones/us-central1-a' allocationPolicy.getLocation().getAllowedLocations(1) == 'zones/us-central1-c' allocationPolicy.getInstances(0).getInstallGpuDrivers() == true + allocationPolicy.getInstances(0).getInstallOpsAgent() == true allocationPolicy.getLabelsMap() == [foo: 'bar'] allocationPolicy.getServiceAccount().getEmail() == 'foo@bar.baz' allocationPolicy.getTagsList() == ['tag1', 'tag2'] diff --git a/plugins/nf-google/src/test/nextflow/cloud/google/batch/client/BatchConfigTest.groovy b/plugins/nf-google/src/test/nextflow/cloud/google/batch/client/BatchConfigTest.groovy index 4b24d652ea..eddbdb0a8a 100644 --- a/plugins/nf-google/src/test/nextflow/cloud/google/batch/client/BatchConfigTest.groovy +++ b/plugins/nf-google/src/test/nextflow/cloud/google/batch/client/BatchConfigTest.groovy @@ -49,7 +49,8 @@ class BatchConfigTest extends Specification { retryPolicy: [maxAttempts: 10], bootDiskImage: 'batch-foo', bootDiskSize: '100GB', - logsPath: 'gs://my-logs-bucket/logs' + logsPath: 'gs://my-logs-bucket/logs', + installOpsAgent: true ] when: @@ -65,6 +66,8 @@ class BatchConfigTest extends Specification { config.bootDiskSize == MemoryUnit.of('100GB') and: config.logsPath == 'gs://my-logs-bucket/logs' + and: + config.installOpsAgent == true } }