diff --git a/CHANGELOG.md b/CHANGELOG.md index b03fb9fb23..0aa1a58d3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.39.1](https://github.com/rudderlabs/rudder-transformer/compare/v1.39.0...v1.39.1) (2023-08-28) + + +### Bug Fixes + +* faas pods creation failure due to caching ([9b88c30](https://github.com/rudderlabs/rudder-transformer/commit/9b88c309856698e479858cfe78a0c0166a312f47)) + ## [1.39.0](https://github.com/rudderlabs/rudder-transformer/compare/v1.38.0...v1.39.0) (2023-08-20) diff --git a/package-lock.json b/package-lock.json index b3be1488a3..387d2a1671 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rudder-transformer", - "version": "1.39.0", + "version": "1.39.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rudder-transformer", - "version": "1.39.0", + "version": "1.39.1", "license": "ISC", "dependencies": { "@amplitude/ua-parser-js": "^0.7.24", diff --git a/package.json b/package.json index 62c0c11601..557bc9b4cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rudder-transformer", - "version": "1.39.0", + "version": "1.39.1", "description": "", "homepage": "https://github.com/rudderlabs/rudder-transformer#readme", "bugs": { diff --git a/src/util/openfaas/index.js b/src/util/openfaas/index.js index 343b76be42..1b3e531ceb 100644 --- a/src/util/openfaas/index.js +++ b/src/util/openfaas/index.js @@ -92,8 +92,18 @@ const isFunctionDeployed = (functionName) => { const setFunctionInCache = (functionName) => { const funcList = functionListCache.get(FUNC_LIST_KEY) || []; - funcList.push(functionName); - functionListCache.set(FUNC_LIST_KEY, funcList); + if (funcList.includes(functionName)) return; + const funcListSet = new Set(funcList); + funcListSet.add(functionName); + functionListCache.set(FUNC_LIST_KEY, Array.from(funcListSet)); +}; + +const removeFunctionFromCache = (functionName) => { + const funcList = functionListCache.get(FUNC_LIST_KEY) || []; + if (!funcList.includes(functionName)) return; + const funcListSet = new Set(funcList); + funcListSet.delete(functionName); + functionListCache.set(FUNC_LIST_KEY, Array.from(funcListSet)); }; const invalidateFnCache = () => { @@ -150,7 +160,10 @@ const deployFaasFunction = async (functionName, code, versionId, libraryVersionI logger.error(`[Faas] Error while deploying ${functionName}: ${error.message}`); // To handle concurrent create requests, // throw retry error if deployment or service already exists so that request can be retried - if ((error.statusCode === 500 || error.statusCode === 400) && error.message.includes('already exists')) { + if ( + (error.statusCode === 500 || error.statusCode === 400) && + error.message.includes('already exists') + ) { setFunctionInCache(functionName); throw new RetryRequestError(`${functionName} already exists`); } @@ -199,6 +212,7 @@ const executeFaasFunction = async ( error.statusCode === 404 && error.message.includes(`error finding function ${functionName}`) ) { + removeFunctionFromCache(functionName); await setupFaasFunction(functionName, null, versionId, libraryVersionIDs, testMode); throw new RetryRequestError(`${functionName} not found`); }