Skip to content

Commit ef028cb

Browse files
committed
fixed conflicts
2 parents 0e9ff80 + 93ffe5a commit ef028cb

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

docs/env.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ The `DOCKER_COMPUTE_ENVIRONMENTS` environment variable should be a JSON array of
137137
{
138138
"socketPath": "/var/run/docker.sock",
139139
"scanImages": true,
140+
"enableNetwork": false,
140141
"imageRetentionDays": 7,
141142
"imageCleanupInterval": 86400,
142143
"resources": [
@@ -195,7 +196,9 @@ The `DOCKER_COMPUTE_ENVIRONMENTS` environment variable should be a JSON array of
195196
#### Configuration Options
196197

197198
- **socketPath**: Path to the Docker socket (e.g., docker.sock).
198-
- **scanImages**: If the docker images should be scan for vulnerabilities using trivy. If yes and critical vulnerabilities are found, then C2D job is refused
199+
- **scanImages**: Whether Docker images should be scanned for vulnerabilities using Trivy. If enabled and critical vulnerabilities are found, the C2D job is rejected.
200+
- **scanImageDBUpdateInterval**: How often to update the vulnerability database, in seconds. Default: 43200 (12 hours)
201+
- **enableNetwork**: Whether networking is enabled for algorithm containers. Default: false
199202
- **imageRetentionDays** - how long docker images are kept, in days. Default: 7
200203
- **imageCleanupInterval** - how often to run cleanup for docker images, in seconds. Min: 3600 (1hour), Default: 86400 (24 hours)
201204
- **paymentClaimInterval** - how often to run payment claiming, in seconds. Default: 3600 (1 hour)

src/@types/C2D/C2D.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export interface C2DDockerConfig {
167167
scanImages?: boolean
168168
scanImageDBUpdateInterval?: number // Default: 12 hours
169169
environments: C2DEnvironmentConfig[]
170+
enableNetwork?: boolean // whether network is enabled for algorithm containers
170171
}
171172

172173
export type ComputeResultType =

src/components/c2d/compute_engine_docker.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export class C2DEngineDocker extends C2DEngine {
8888
private trivyCachePath: string
8989
private cpuAllocations: Map<string, number[]> = new Map()
9090
private envCpuCoresMap: Map<string, number[]> = new Map()
91+
private enableNetwork: boolean
92+
9193
public constructor(
9294
clusterConfig: C2DClusterInfo,
9395
db: C2DDatabase,
@@ -110,6 +112,7 @@ export class C2DEngineDocker extends C2DEngine {
110112
this.paymentClaimInterval = clusterConfig.connection.paymentClaimInterval || 3600 // 1 hour
111113
this.scanImages = clusterConfig.connection.scanImages || false // default is not to scan images for now, until it's prod ready
112114
this.scanImageDBUpdateInterval = clusterConfig.connection.scanImageDBUpdateInterval
115+
this.enableNetwork = clusterConfig.connection.enableNetwork ?? false
113116
if (
114117
clusterConfig.connection.protocol &&
115118
clusterConfig.connection.host &&
@@ -1788,7 +1791,6 @@ export class C2DEngineDocker extends C2DEngine {
17881791
// create the container
17891792
const mountVols: any = { '/data': {} }
17901793
const hostConfig: HostConfig = {
1791-
NetworkMode: 'none', // no network inside the container
17921794
Mounts: [
17931795
{
17941796
Type: 'volume',
@@ -1798,6 +1800,9 @@ export class C2DEngineDocker extends C2DEngine {
17981800
}
17991801
]
18001802
}
1803+
if (!this.enableNetwork) {
1804+
hostConfig.NetworkMode = 'none' // no network inside the container
1805+
}
18011806
// disk
18021807
// if (diskSize && diskSize > 0) {
18031808
// hostConfig.StorageOpt = {

src/utils/config/schemas.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ export const C2DDockerConfigSchema = z.array(
209209
certPath: z.string().optional(),
210210
keyPath: z.string().optional(),
211211
imageRetentionDays: z.number().int().min(1).optional().default(7),
212-
imageCleanupInterval: z.number().int().min(3600).optional().default(86400),
212+
imageCleanupInterval: z.number().int().min(3600).optional().default(86400), // min 1 hour, default 24 hours
213+
scanImages: z.boolean().optional().default(false),
214+
scanImageDBUpdateInterval: z.number().int().min(3600).optional().default(43200), // default 43200 (12 hours)
215+
enableNetwork: z.boolean().optional().default(false),
213216
environments: z.array(C2DEnvironmentConfigSchema).min(1)
214217
})
215218
)

0 commit comments

Comments
 (0)