From 27e7eadf9ab2fbb0cd6acfb8571e1439dddc5d60 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Wed, 18 Dec 2024 09:56:44 +0000 Subject: [PATCH 1/3] set disk usage --- src/components/c2d/compute_engine_docker.ts | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/components/c2d/compute_engine_docker.ts b/src/components/c2d/compute_engine_docker.ts index 69577ed55..83adf1e56 100644 --- a/src/components/c2d/compute_engine_docker.ts +++ b/src/components/c2d/compute_engine_docker.ts @@ -517,15 +517,22 @@ export class C2DEngineDocker extends C2DEngine { ] } if (environment != null) { + // TODO the CPU and MEM part is addressed in the PR #799 https://github.com/oceanprotocol/ocean-node/pull/799/ + // REMOVE AFTER MERGE // limit container CPU & Memory usage according to env specs - hostConfig.CpuCount = environment.cpuNumber || 1 - // if more than 1 CPU - if (hostConfig.CpuCount > 1) { - hostConfig.CpusetCpus = `0-${hostConfig.CpuCount - 1}` + // hostConfig.CpuCount = environment.cpuNumber || 1 + // // if more than 1 CPU + // if (hostConfig.CpuCount > 1) { + // hostConfig.CpusetCpus = `0-${hostConfig.CpuCount - 1}` + // } + // hostConfig.Memory = 0 || convertGigabytesToBytes(environment.ramGB) + // // set swap to same memory value means no swap (otherwise it use like 2X mem) + // hostConfig.MemorySwap = hostConfig.Memory + + // storage + hostConfig.StorageOpt = { + size: environment.diskGB > 0 ? `${environment.diskGB}G` : '1G' } - hostConfig.Memory = 0 || convertGigabytesToBytes(environment.ramGB) - // set swap to same memory value means no swap (otherwise it use like 2X mem) - hostConfig.MemorySwap = hostConfig.Memory } // console.log('host config: ', hostConfig) const containerInfo: ContainerCreateOptions = { From 5cffae399ad77b31a9d6a2acaa5cf4b928b2f9a9 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Wed, 18 Dec 2024 10:04:01 +0000 Subject: [PATCH 2/3] fix lint --- src/components/c2d/compute_engine_docker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/c2d/compute_engine_docker.ts b/src/components/c2d/compute_engine_docker.ts index 83adf1e56..747e9e044 100644 --- a/src/components/c2d/compute_engine_docker.ts +++ b/src/components/c2d/compute_engine_docker.ts @@ -40,7 +40,7 @@ import { Service } from '../../@types/DDO/Service.js' import { decryptFilesObject, omitDBComputeFieldsFromComputeJob } from './index.js' import * as drc from 'docker-registry-client' import { ValidateParams } from '../httpRoutes/validateCommands.js' -import { convertGigabytesToBytes } from '../../utils/util.js' +// import { convertGigabytesToBytes } from '../../utils/util.js' export class C2DEngineDocker extends C2DEngine { private envs: ComputeEnvironment[] = [] From d4e9767dd2e167b75057c24d6fd82eb9a5fe0187 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Mon, 6 Jan 2025 11:19:56 +0000 Subject: [PATCH 3/3] add driveropts for volume --- src/components/c2d/compute_engine_docker.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/c2d/compute_engine_docker.ts b/src/components/c2d/compute_engine_docker.ts index 747e9e044..3b3027d2a 100644 --- a/src/components/c2d/compute_engine_docker.ts +++ b/src/components/c2d/compute_engine_docker.ts @@ -490,9 +490,18 @@ export class C2DEngineDocker extends C2DEngine { if (job.status === C2DStatusNumber.ConfiguringVolumes) { // create the volume & create container // TO DO C2D: Choose driver & size + // get env info + const environment = await this.getJobEnvironment(job) + const volume: VolumeCreateOptions = { Name: job.jobId + '-volume' } + // volume + if (environment != null) { + volume.DriverOpts = { + size: environment.diskGB > 0 ? `${environment.diskGB}G` : '1G' + } + } try { await this.docker.createVolume(volume) } catch (e) { @@ -502,8 +511,7 @@ export class C2DEngineDocker extends C2DEngine { await this.db.updateJob(job) await this.cleanupJob(job) } - // get env info - const environment = await this.getJobEnvironment(job) + // create the container const mountVols: any = { '/data': {} } const hostConfig: HostConfig = { @@ -529,7 +537,7 @@ export class C2DEngineDocker extends C2DEngine { // // set swap to same memory value means no swap (otherwise it use like 2X mem) // hostConfig.MemorySwap = hostConfig.Memory - // storage + // storage (container) hostConfig.StorageOpt = { size: environment.diskGB > 0 ? `${environment.diskGB}G` : '1G' }