Skip to content

Commit 125032f

Browse files
committed
chore: review
1 parent 079d7a6 commit 125032f

1 file changed

Lines changed: 4 additions & 76 deletions

File tree

src/components/c2d/compute_engine_docker.ts

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,59 +1520,6 @@ export class C2DEngineDocker extends C2DEngine {
15201520
}
15211521
}
15221522

1523-
// private async ensureImage(image: string): Promise<void> {
1524-
// try {
1525-
// await this.docker.getImage(image).inspect()
1526-
// } catch {
1527-
// CORE_LOGGER.info(`Image ${image} not found locally, pulling...`)
1528-
// const pullStream = await this.docker.pull(image)
1529-
// await new Promise<void>((resolve, reject) => {
1530-
// this.docker.modem.followProgress(pullStream, (err: any) => {
1531-
// if (err) reject(err)
1532-
// else resolve()
1533-
// })
1534-
// })
1535-
// }
1536-
// }
1537-
1538-
// private async initializeVolumePermissions(volumeName: string): Promise<boolean> {
1539-
// let initContainer: Dockerode.Container | null = null
1540-
// try {
1541-
// await this.ensureImage('busybox')
1542-
// initContainer = await this.docker.createContainer({
1543-
// Image: 'busybox',
1544-
// Cmd: [
1545-
// 'sh',
1546-
// '-c',
1547-
// 'mkdir -p /data/inputs /data/outputs /data/transformations /data/ddos /data/logs && chmod 777 /data /data/inputs /data/outputs /data/transformations /data/ddos /data/logs'
1548-
// ],
1549-
// HostConfig: {
1550-
// NetworkMode: 'none',
1551-
// Mounts: [{ Type: 'volume', Source: volumeName, Target: '/data' }]
1552-
// }
1553-
// })
1554-
// await initContainer.start()
1555-
// const { StatusCode } = await initContainer.wait()
1556-
// if (StatusCode !== 0) {
1557-
// CORE_LOGGER.error(
1558-
// `Volume permission init container exited with code ${StatusCode} for volume ${volumeName}`
1559-
// )
1560-
// return false
1561-
// }
1562-
// CORE_LOGGER.info(`Volume permissions initialized successfully for ${volumeName}`)
1563-
// return true
1564-
// } catch (e) {
1565-
// CORE_LOGGER.error(`Failed to initialize volume permissions: ${e.message}`)
1566-
// return false
1567-
// } finally {
1568-
// if (initContainer) {
1569-
// try {
1570-
// await initContainer.remove()
1571-
// } catch {}
1572-
// }
1573-
// }
1574-
// }
1575-
15761523
private async createDockerVolume(
15771524
volume: VolumeCreateOptions,
15781525
retry: boolean = false
@@ -1689,26 +1636,18 @@ export class C2DEngineDocker extends C2DEngine {
16891636
await this.cleanupJob(job)
16901637
return
16911638
}
1692-
// if (!(await this.initializeVolumePermissions(volume.Name))) {
1693-
// job.status = C2DStatusNumber.VolumeCreationFailed
1694-
// job.statusText = C2DStatusText.VolumeCreationFailed
1695-
// job.isRunning = false
1696-
// job.dateFinished = String(Date.now() / 1000)
1697-
// await this.db.updateJob(job)
1698-
// await this.cleanupJob(job)
1699-
// return
1700-
// }
17011639

17021640
// create the container
17031641
const mountVols: any = { '/data': {} }
17041642
const hostConfig: HostConfig = {
17051643
NetworkMode: 'none', // no network inside the container
17061644
ReadonlyRootfs: true,
1645+
// limit number of Pids container can spawn, to avoid flooding
17071646
PidsLimit: 512,
17081647
Tmpfs: {
1648+
'/home/ubuntu/.cache': 'rw,noexec,nosuid,size=512m',
17091649
'/tmp': 'rw,noexec,nosuid,size=256m',
1710-
'/run': 'rw,noexec,nosuid,size=64m',
1711-
'/home/ubuntu/.cache': 'rw,noexec,nosuid,size=256m'
1650+
'/run': 'rw,noexec,nosuid,size=64m'
17121651
},
17131652
Mounts: [
17141653
{
@@ -2812,23 +2751,12 @@ export class C2DEngineDocker extends C2DEngine {
28122751
const destination = jobFolderPath + '/tarData/upload.tar.gz'
28132752
try {
28142753
tar.create(
2815-
// map is a valid runtime option but missing from type definitions
28162754
{
28172755
gzip: true,
28182756
file: destination,
28192757
sync: true,
28202758
C: folderToTar
2821-
// map: (header: any) => {
2822-
// header.uid = C2D_CONTAINER_UID
2823-
// header.gid = C2D_CONTAINER_GID
2824-
// // Docker's putArchive applies chmod but not chown — set directories
2825-
// // world-writable so the container user (uid 1000) can write to them
2826-
// if (header.type === 'Directory') {
2827-
// header.mode = 0o777
2828-
// }
2829-
// return header
2830-
// }
2831-
} as any,
2759+
},
28322760
['./']
28332761
)
28342762
// check if tar.gz actually exists

0 commit comments

Comments
 (0)