Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/@types/C2D/C2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface ComputeEnvironmentBaseConfig {
access: ComputeAccessList
free?: ComputeEnvironmentFreeOptions
platform: RunningPlatform
enableNetwork?: boolean // whether network is enabled for algorithm containers
}

export interface ComputeRuntimes {
Expand Down Expand Up @@ -152,6 +153,7 @@ export interface C2DEnvironmentConfig {
access?: ComputeAccessList
free?: ComputeEnvironmentFreeOptions
resources?: ComputeResource[]
enableNetwork?: boolean // whether network is enabled for algorithm containers
}

export interface C2DDockerConfig {
Expand All @@ -168,7 +170,6 @@ export interface C2DDockerConfig {
scanImages?: boolean
scanImageDBUpdateInterval?: number // Default: 12 hours
environments: C2DEnvironmentConfig[]
enableNetwork?: boolean // whether network is enabled for algorithm containers
}

export type ComputeResultType =
Expand Down
11 changes: 6 additions & 5 deletions src/components/c2d/compute_engine_docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export class C2DEngineDocker extends C2DEngine {
private trivyCachePath: string
private cpuAllocations: Map<string, number[]> = new Map()
private envCpuCoresMap: Map<string, number[]> = new Map()
private enableNetwork: boolean

public constructor(
clusterConfig: C2DClusterInfo,
Expand All @@ -115,7 +114,7 @@ export class C2DEngineDocker extends C2DEngine {
this.paymentClaimInterval = clusterConfig.connection.paymentClaimInterval || 3600 // 1 hour
this.scanImages = clusterConfig.connection.scanImages || false // default is not to scan images for now, until it's prod ready
this.scanImageDBUpdateInterval = clusterConfig.connection.scanImageDBUpdateInterval
this.enableNetwork = clusterConfig.connection.enableNetwork ?? false

if (
clusterConfig.connection.protocol &&
clusterConfig.connection.host &&
Expand Down Expand Up @@ -236,7 +235,8 @@ export class C2DEngineDocker extends C2DEngine {
{ [BASE_CHAIN_ID]: [getAddress('0xcb7Db55Ca9Aa9C3b25F5Bc266da63317fa02086a')] }
]
},
fees: benchmarkFees
fees: benchmarkFees,
enableNetwork: true
}

envConfig.environments.push(benchmarkEnv)
Expand Down Expand Up @@ -367,7 +367,8 @@ export class C2DEngineDocker extends C2DEngine {
queMaxWaitTime: 0,
queMaxWaitTimeFree: 0,
runMaxWaitTime: 0,
runMaxWaitTimeFree: 0
runMaxWaitTimeFree: 0,
enableNetwork: envDef.enableNetwork
}

if (envDef.storageExpiry !== undefined) env.storageExpiry = envDef.storageExpiry
Expand Down Expand Up @@ -1836,7 +1837,7 @@ export class C2DEngineDocker extends C2DEngine {
}
]
}
if (!this.enableNetwork) {
if (!env.enableNetwork) {
hostConfig.NetworkMode = 'none' // no network inside the container
}
// disk
Expand Down
4 changes: 2 additions & 2 deletions src/utils/config/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ export const C2DEnvironmentConfigSchema = z
})
.optional(),
free: ComputeEnvironmentFreeOptionsSchema.optional(),
resources: z.array(ComputeResourceSchema).optional()
resources: z.array(ComputeResourceSchema).optional(),
enableNetwork: z.boolean().optional().default(false)
})
.refine(
(data) =>
Expand Down Expand Up @@ -270,7 +271,6 @@ export const C2DDockerConfigSchema = z.array(
imageCleanupInterval: z.number().int().min(3600).optional().default(86400), // min 1 hour, default 24 hours
scanImages: z.boolean().optional().default(false),
scanImageDBUpdateInterval: z.number().int().min(3600).optional().default(43200), // default 43200 (12 hours)
enableNetwork: z.boolean().optional().default(false),
environments: z.array(C2DEnvironmentConfigSchema).min(1)
})
)
Expand Down
Loading