Skip to content

Commit

Permalink
Merge pull request #800 from oceanprotocol/issue-769-c2d-storage-limit
Browse files Browse the repository at this point in the history
issue 769 - c2d docker disk usage/storage limits
  • Loading branch information
paulo-ocean authored Jan 8, 2025
2 parents 43d7e41 + 1fc4415 commit 43b3823
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/components/c2d/compute_engine_docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,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) {
Expand All @@ -503,8 +512,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': {} }
let hostConfig: HostConfig = {
Expand All @@ -518,7 +526,10 @@ export class C2DEngineDocker extends C2DEngine {
]
}
if (environment != null) {
// limit container CPU & Memory usage according to env specs
// storage (container)
hostConfig.StorageOpt = {
size: environment.diskGB > 0 ? `${environment.diskGB}G` : '1G'
}
hostConfig = {
...hostConfig,
...(await buildCPUAndMemoryConstraints(environment, this.docker))
Expand Down

0 comments on commit 43b3823

Please sign in to comment.