diff --git a/asset-bundle-converter/Assets/AssetBundleConverter/ErrorCodes.cs b/asset-bundle-converter/Assets/AssetBundleConverter/ErrorCodes.cs index 0864366..a503103 100644 --- a/asset-bundle-converter/Assets/AssetBundleConverter/ErrorCodes.cs +++ b/asset-bundle-converter/Assets/AssetBundleConverter/ErrorCodes.cs @@ -17,6 +17,7 @@ public enum ErrorCodes DOWNLOAD_FAILED, INVALID_PLATFORM, GLTF_PROCESS_MISMATCH, - CONVERSION_ERRORS_TOLERATED + CONVERSION_ERRORS_TOLERATED, + ALREADY_CONVERTED } } diff --git a/consumer-server/package.json b/consumer-server/package.json index 7ace4fb..0c00d07 100644 --- a/consumer-server/package.json +++ b/consumer-server/package.json @@ -17,7 +17,7 @@ "dependencies": { "@aws-sdk/client-sns": "^3.699.0", "@dcl/cdn-uploader": "^1.4.1-20230208155013.commit-f75a6ee", - "@dcl/schemas": "^15.2.0", + "@dcl/schemas": "15.3.3", "@sentry/node": "^8.27.0", "@well-known-components/env-config-provider": "^1.2.0", "@well-known-components/http-server": "^2.1.0", diff --git a/consumer-server/src/logic/conversion-task.ts b/consumer-server/src/logic/conversion-task.ts index 8c0259a..5ad68bf 100644 --- a/consumer-server/src/logic/conversion-task.ts +++ b/consumer-server/src/logic/conversion-task.ts @@ -83,7 +83,7 @@ export async function executeLODConversion( components: Pick, entityId: string, lods: string[] -) { +): Promise { const $LOGS_BUCKET = await components.config.getString('LOGS_BUCKET') const $UNITY_PATH = await components.config.requireString('UNITY_PATH') const $PROJECT_PATH = await components.config.requireString('PROJECT_PATH') @@ -105,7 +105,7 @@ export async function executeLODConversion( if (!unityBuildTarget) { logger.error('Could not find a build target', { ...defaultLoggerMetadata } as any) - return + return 5 // UNEXPECTED_ERROR exit code } try { @@ -128,7 +128,7 @@ export async function executeLODConversion( // this is an error, if succeeded, we should see at least a manifest file components.metrics.increment('ab_converter_empty_conversion', { ab_version: $AB_VERSION }) logger.error('Empty conversion', { ...defaultLoggerMetadata } as any) - return + return 5 // UNEXPECTED_ERROR exit code } await uploadDir(components.cdnS3, cdnBucket, outDirectory, 'LOD', { @@ -145,6 +145,8 @@ export async function executeLODConversion( } ] }) + + return exitCode ?? -1 } catch (error: any) { logger.debug(await promises.readFile(logFile, 'utf8'), defaultLoggerMetadata) components.metrics.increment('ab_converter_exit_codes', { exit_code: 'FAIL' }) @@ -201,7 +203,7 @@ export async function executeConversion( contentServerUrl: string, force: boolean | undefined, animation: string | undefined -) { +): Promise { const $LOGS_BUCKET = await components.config.getString('LOGS_BUCKET') const $UNITY_PATH = await components.config.requireString('UNITY_PATH') const $PROJECT_PATH = await components.config.requireString('PROJECT_PATH') @@ -214,13 +216,13 @@ export async function executeConversion( const unityBuildTarget = getUnityBuildTarget($BUILD_TARGET) if (!unityBuildTarget) { logger.info('Invalid build target ' + $BUILD_TARGET) - return + return 5 // UNEXPECTED_ERROR exit code } if (!force) { if (await shouldIgnoreConversion(components, entityId, $AB_VERSION, $BUILD_TARGET)) { logger.info('Ignoring conversion', { entityId, contentServerUrl, $AB_VERSION }) - return + return 13 // ALREADY_CONVERTED exit code } } else { logger.info('Forcing conversion', { entityId, contentServerUrl, $AB_VERSION }) @@ -347,6 +349,8 @@ export async function executeConversion( process.exit(1) } } + + return exitCode ?? -1 } catch (err: any) { logger.debug(await promises.readFile(logFile, 'utf8'), defaultLoggerMetadata) components.metrics.increment('ab_converter_exit_codes', { exit_code: 'FAIL' }) diff --git a/consumer-server/src/service.ts b/consumer-server/src/service.ts index f1f25fc..5665f57 100644 --- a/consumer-server/src/service.ts +++ b/consumer-server/src/service.ts @@ -3,7 +3,7 @@ import { setupRouter } from './controllers/routes' import { executeConversion, executeLODConversion } from './logic/conversion-task' import checkDiskSpace from 'check-disk-space' import { AppComponents, GlobalContext, TestComponents } from './types' -import { AssetBundleConvertedEvent, Events } from '@dcl/schemas' +import { AssetBundleConversionFinishedEvent, Events } from '@dcl/schemas' // this function wires the business logic (adapters & controllers) with the components (ports) export async function main(program: Lifecycle.EntryPointParameters) { @@ -39,12 +39,13 @@ export async function main(program: Lifecycle.EntryPointParameters { + let statusCode: number try { components.metrics.increment('ab_converter_running_conversion') if (job.lods) { - await executeLODConversion(components, job.entity.entityId, job.lods) + statusCode = await executeLODConversion(components, job.entity.entityId, job.lods) } else { - await executeConversion( + statusCode = await executeConversion( components, job.entity.entityId, job.contentServerUrls![0], @@ -53,14 +54,16 @@ export async function main(program: Lifecycle.EntryPointParameters