From 38d3b6178342088ac422d5ceacb0d7d8b71705b6 Mon Sep 17 00:00:00 2001 From: Chris Garson Date: Wed, 18 Sep 2024 19:56:04 -0400 Subject: [PATCH 1/3] Update aws.js: Add support for local bind mount for NodeODM data directory --- libs/asr-providers/aws.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libs/asr-providers/aws.js b/libs/asr-providers/aws.js index b2737f8..47b3039 100644 --- a/libs/asr-providers/aws.js +++ b/libs/asr-providers/aws.js @@ -53,6 +53,7 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{ "addSwap": 1, "dockerImage": "opendronemap/nodeodm", + "dockerDataDirMountPath": "", "iamrole": "", "nodeSetupCmd": "" }, userConfig); @@ -120,6 +121,7 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{ const dockerImage = this.getConfig("dockerImage"); const accessKey = this.getConfig("accessKey"); const secretKey = this.getConfig("secretKey"); + const dataDirMountPath = this.getConfig("dataDirMountPath"); const s3 = this.getConfig("s3"); const webhook = netutils.publicAddressPath("/commit", req, token); @@ -129,14 +131,22 @@ module.exports = class AWSAsrProvider extends AbstractASRProvider{ await dm.ssh(setupCmd); } - await dm.ssh([`sudo docker run -d -p 3000:3000 ${dockerImage} -q 1`, - `--s3_access_key ${accessKey}`, - `--s3_secret_key ${secretKey}`, - `--s3_endpoint ${s3.endpoint}`, - `--s3_bucket ${s3.bucket}`, - `--s3_acl ${s3.acl}`, - `--webhook ${webhook}`, - `--token ${nodeToken}`].join(" ")); + let dockerRunArgs = [`sudo docker run -d -p 3000:3000`]; + + if(dataDirMountPath.length > 0){ + dockerRunArgs.push(`--mount type=bind,source=${dataDirMountPath},target=/var/www/data`); + } + + dockerRunArgs.push(`${dockerImage} -q 1`); + dockerRunArgs.push(`--s3_access_key ${accessKey}`); + dockerRunArgs.push(`--s3_secret_key ${secretKey}`); + dockerRunArgs.push(`--s3_endpoint ${s3.endpoint}`); + dockerRunArgs.push(`--s3_bucket ${s3.bucket}`); + dockerRunArgs.push(`--s3_acl ${s3.acl}`); + dockerRunArgs.push(`--webhook ${webhook}`); + dockerRunArgs.push(`--token ${nodeToken}`); + + await dm.ssh(dockerRunArgs.join(" ")); } getImagePropertiesFor(imagesCount){ From 853f6a0bce111c8b120896b9ec5771c3a6debf37 Mon Sep 17 00:00:00 2001 From: Chris Garson Date: Wed, 18 Sep 2024 20:10:36 -0400 Subject: [PATCH 2/3] Update aws.md: Update doc for dockerDataDirMountPath and other updates --- docs/aws.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/aws.md b/docs/aws.md index fd72324..6448962 100644 --- a/docs/aws.md +++ b/docs/aws.md @@ -62,7 +62,8 @@ the on-demand instance cost - you'll always pay the current market price, not yo ], "addSwap": 1, - "dockerImage": "opendronemap/nodeodm" + "dockerImage": "opendronemap/nodeodm", + "dockerDataDirMountPath": "" } ``` @@ -82,12 +83,14 @@ the on-demand instance cost - you'll always pay the current market price, not yo | monitoring | Set to true to enable detailed Cloudwatch monitoring for the instance. | | region | Region identifier where the instances should be created. | | zone | Zone identifier where the instances should be created. | -| ami | The AMI (machine image) to launch this instance from. | +| ami | The AMI (machine image) to launch this instance from. Note that AMIs are region-specific. | +| engineInstallUrl | Specify installer for Docker engine. This can be cleared if AMI already has Docker engine installed. | | tags | Comma-separated list of key,value tags to associate to the instance. | | spot | Whether to request spot instances. If this is true, a `spotPrice` needs to be provided in the `imageSizeMapping`. | | imageSizeMapping | Max images count to instance size mapping. (See below.) | | addSwap | Optionally add this much swap space to the instance as a factor of total RAM (`RAM * addSwap`). A value of `1` sets a swapfile equal to the available RAM. | | dockerImage | Docker image to launch | +| dockerDataDirMountPath | Path on node host to map to NodeODM data directory (/var/www/data). Use local instance storage for much faster I/O. If set, root EBS vol storage is moot. | | nodeSetupCmd | Can be optionally used to run a setup command on auto-scaled nodes right before we run ODM. | ## Image Size Mapping @@ -103,3 +106,7 @@ instance able to process the requested number of images is always selected. | slug | EC2 instance type to request (for example, `t3.medium`). | | storage | Amount of storage to allocate to this instance's EBS root volume, in GB. | | spotPrice | The maximum hourly price you're willing to bid for this instance (if spot instances are enabled). | + +If `dockerDataDirMountPath` is specified and a local mount path is used for NodeODM's data directory (such as local NVMe storage on AWS 'd' instances), +the `storage` parameter here does not need to scale with image sizes and can be statically set lower. This is because the local NVMe storage will be used for temporary data +storage and not the instance's root EBS volume. However, it is important to ensure that the local storage size will be sufficient for the desired image count. From 27b9ac6b7b3272967ab7c72fed878cb12f8c9e7a Mon Sep 17 00:00:00 2001 From: Chris Garson Date: Wed, 18 Sep 2024 20:11:48 -0400 Subject: [PATCH 3/3] Update aws.md --- docs/aws.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/aws.md b/docs/aws.md index 6448962..8294a4e 100644 --- a/docs/aws.md +++ b/docs/aws.md @@ -90,7 +90,7 @@ the on-demand instance cost - you'll always pay the current market price, not yo | imageSizeMapping | Max images count to instance size mapping. (See below.) | | addSwap | Optionally add this much swap space to the instance as a factor of total RAM (`RAM * addSwap`). A value of `1` sets a swapfile equal to the available RAM. | | dockerImage | Docker image to launch | -| dockerDataDirMountPath | Path on node host to map to NodeODM data directory (/var/www/data). Use local instance storage for much faster I/O. If set, root EBS vol storage is moot. | +| dockerDataDirMountPath | Path on node host to map to NodeODM data directory (/var/www/data). Use local instance storage for much faster I/O. | | nodeSetupCmd | Can be optionally used to run a setup command on auto-scaled nodes right before we run ODM. | ## Image Size Mapping