Skip to content

Commit d62f219

Browse files
committed
Remove hardcoded value, refactor fallback.
1 parent d73c45a commit d62f219

2 files changed

Lines changed: 5 additions & 27 deletions

File tree

src/components/core/compute/startCompute.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { decrypt } from '../../../utils/crypt.js'
2222
import { verifyProviderFees } from '../utils/feesHandler.js'
2323
import { Blockchain } from '../../../utils/blockchain.js'
2424
import { validateOrderTransaction } from '../utils/validateOrders.js'
25-
import { getConfiguration, validUntil5Mins } from '../../../utils/index.js'
25+
import { getConfiguration } from '../../../utils/index.js'
2626
import { sanitizeServiceFiles } from '../../../utils/util.js'
2727
import { FindDdoHandler } from '../handler/ddoHandler.js'
2828
import { ProviderFeeValidation } from '../../../@types/Fees.js'
@@ -429,7 +429,7 @@ export class FreeComputeStartHandler extends CommandHandler {
429429
}
430430
}
431431
let engine = null
432-
let validUntil = validUntil5Mins
432+
let validUntil = null
433433
try {
434434
// split compute env (which is already in hash-envId format) and get the hash
435435
// then get env which might contain dashes as well
@@ -475,29 +475,9 @@ export class FreeComputeStartHandler extends CommandHandler {
475475
)
476476
await engine.checkIfResourcesAreAvailable(task.resources, env, true)
477477
if (task.validUntil) {
478-
validUntil = task.validUntil
479-
if (env.maxJobDuration && validUntil > env.maxJobDuration) {
480-
CORE_LOGGER.logMessage(
481-
'FreeComputeStartCommand validUntil bigger than supported max duration job: ' +
482-
validUntil +
483-
' fallback to supported max duration job: ' +
484-
env.maxJobDuration,
485-
true
486-
)
487-
488-
validUntil = env.maxJobDuration
489-
}
490-
} else {
491-
// If task.validUntil is not provided, use 'env.maxJobDuration' if available
492-
if (env.maxJobDuration) {
493-
CORE_LOGGER.logMessage(
494-
'FreeComputeStartCommand validUntil is null,' +
495-
' fallback to supported max duration job: ' +
496-
env.maxJobDuration,
497-
true
498-
)
499-
validUntil = env.maxJobDuration
500-
}
478+
validUntil = env.free.maxJobDuration
479+
? Math.min(task.validUntil, env.free.maxJobDuration)
480+
: task.validUntil
501481
}
502482
} catch (e) {
503483
console.error(e)

src/utils/constants.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,5 +496,3 @@ export const knownUnsafeURLs: string[] = [
496496
// k8s ETCD
497497
'^.*(127.0.0.1).*'
498498
]
499-
500-
export const validUntil5Mins: number = 300

0 commit comments

Comments
 (0)