Skip to content

Commit 59d927f

Browse files
authored
fix no did logs (#1383)
1 parent 515f477 commit 59d927f

3 files changed

Lines changed: 41 additions & 3 deletions

File tree

src/components/core/compute/startCompute.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ export class FreeComputeStartHandler extends CommonComputeHandler {
784784
}
785785
}
786786
for (const elem of [...[task.algorithm], ...task.datasets]) {
787-
if (!('documentId' in elem)) {
787+
if (!('documentId' in elem) || !elem.documentId) {
788788
continue
789789
}
790790
const ddo = await new FindDdoHandler(this.getOceanNode()).findAndFormatDdo(

src/components/core/compute/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export function generateUniqueID(jobStructure: any): string {
2323
}
2424

2525
export async function getAlgoChecksums(
26-
algoDID: string,
27-
algoServiceId: string,
26+
algoDID: string | undefined,
27+
algoServiceId: string | undefined,
2828
oceanNode: OceanNode,
2929
config: OceanNodeConfig
3030
): Promise<AlgoChecksums> {
@@ -33,6 +33,10 @@ export async function getAlgoChecksums(
3333
container: '',
3434
serviceId: algoServiceId
3535
}
36+
// Raw-code algorithms have no DDO to resolve - skip the lookup (no error logs, no DB hit)
37+
if (!algoDID) {
38+
return checksums
39+
}
3640
try {
3741
const algoDDO = await new FindDdoHandler(oceanNode).findAndFormatDdo(algoDID)
3842
if (!algoDDO) {

src/test/unit/compute.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ import {
3838
import { checkManifestPlatform } from '../../components/c2d/compute_engine_docker.js'
3939
import { ValidateParams } from '../../components/httpRoutes/validateCommands.js'
4040
import { Readable } from 'stream'
41+
import sinon from 'sinon'
42+
import { getAlgoChecksums } from '../../components/core/compute/utils.js'
43+
import { FindDdoHandler } from '../../components/core/handler/ddoHandler.js'
44+
import { CORE_LOGGER } from '../../utils/logging/common.js'
4145

4246
/* eslint-disable require-await */
4347
class TestC2DEngine extends C2DEngine {
@@ -517,3 +521,33 @@ describe('Compute Jobs Database', () => {
517521
await tearDownEnvironment(envOverrides)
518522
})
519523
})
524+
525+
describe('getAlgoChecksums', () => {
526+
let findDdoStub: sinon.SinonStub
527+
let loggerErrorSpy: sinon.SinonSpy
528+
529+
beforeEach(() => {
530+
findDdoStub = sinon.stub(FindDdoHandler.prototype, 'findAndFormatDdo')
531+
loggerErrorSpy = sinon.spy(CORE_LOGGER, 'error')
532+
})
533+
534+
afterEach(() => {
535+
findDdoStub.restore()
536+
loggerErrorSpy.restore()
537+
})
538+
539+
it('returns empty checksums without a DDO lookup for raw-code algorithms (no documentId)', async () => {
540+
const checksums = await getAlgoChecksums(
541+
undefined,
542+
undefined,
543+
null as any,
544+
null as any
545+
)
546+
547+
expect(checksums).to.deep.equal({ files: '', container: '', serviceId: undefined })
548+
// no DDO lookup must be attempted when there is no algorithm documentId
549+
expect(findDdoStub.called).to.equal(false)
550+
// and therefore no "Algorithm with id: undefined not found!" error is logged
551+
expect(loggerErrorSpy.called).to.equal(false)
552+
})
553+
})

0 commit comments

Comments
 (0)