From 3a2f7ae74226a751f7c84268266f3b517e772696 Mon Sep 17 00:00:00 2001 From: Matias Date: Sat, 4 May 2019 22:44:27 -0300 Subject: [PATCH] Fixing retry on getTextFile --- AzureBlobStorage.js | 8 +++----- Context.js | 13 +++++++------ Root.js | 2 +- package.json | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/AzureBlobStorage.js b/AzureBlobStorage.js index 86b50a6ce..5f4425a02 100644 --- a/AzureBlobStorage.js +++ b/AzureBlobStorage.js @@ -10,7 +10,7 @@ exports.newAzureBlobBlobStorage = function newAzureBlobBlobStorage(BOT, logger) const MODULE_NAME = "Azure Blob Storage"; const RETRY_WAIT_TIME = 10000; - const MAX_RETRIES = 30; + const MAX_RETRIES = 5; let AZURE_STORAGE = require('./AzureStorage') let storage = AZURE_STORAGE.newAzureStorage(bot, logger); @@ -230,7 +230,7 @@ exports.newAzureBlobBlobStorage = function newAzureBlobBlobStorage(BOT, logger) logger.write(MODULE_NAME, "[INFO] getTextFile -> onFileReceived -> text = " + text); } - if (err || text === undefined) { + if (err) { if (ERROR_LOG === true && logger !== undefined && err.code !== 'BlobNotFound') { logger.write(MODULE_NAME, "[ERROR] getTextFile -> onFileReceived -> Error trying to get this file."); @@ -238,7 +238,6 @@ exports.newAzureBlobBlobStorage = function newAzureBlobBlobStorage(BOT, logger) logger.write(MODULE_NAME, "[ERROR] getTextFile -> onFileReceived -> pFolderPath = " + pFolderPath); logger.write(MODULE_NAME, "[ERROR] getTextFile -> onFileReceived -> pFileName = " + pFileName); logger.write(MODULE_NAME, "[ERROR] getTextFile -> onFileReceived -> err.code = " + err.code); - logger.write(MODULE_NAME, "[ERROR] getTextFile -> onFileReceived -> text = " + text); } if ( @@ -251,8 +250,7 @@ exports.newAzureBlobBlobStorage = function newAzureBlobBlobStorage(BOT, logger) err.code === 'EAI_AGAIN' || err.code === 'AuthenticationFailed' || err.code === 'OperationTimedOut' || - err.code === 'ServerBusy' || - text === undefined + err.code === 'ServerBusy' ) { setTimeout(retryCreateFile, RETRY_WAIT_TIME); diff --git a/Context.js b/Context.js index 676277ee0..7026378d1 100644 --- a/Context.js +++ b/Context.js @@ -419,11 +419,16 @@ let fileName = "Execution.Context." + bot.startMode + "." + runIndex +".json"; let dateForPath = bot.processDatetime.getUTCFullYear() + '/' + utilities.pad(bot.processDatetime.getUTCMonth() + 1, 2) + '/' + utilities.pad(bot.processDatetime.getUTCDate(), 2) + '/' + utilities.pad(bot.processDatetime.getUTCHours(), 2) + '/' + utilities.pad(bot.processDatetime.getUTCMinutes(), 2); let filePath = bot.filePathRoot + "/Output/" + bot.process + '/' + dateForPath; + let fileContent = JSON.stringify(thisObject.executionContext); + + if(fileContent === undefined){ + logger.write(MODULE_NAME, "[ERROR] saveThemAll -> writeExecutionContext -> executionContext is undefined."); + callBackFunction(global.DEFAULT_RETRY_RESPONSE); + } if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] saveThemAll -> writeExecutionContext -> fileName = " + fileName); } if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] saveThemAll -> writeExecutionContext -> filePath = " + filePath); } - - let fileContent = JSON.stringify(thisObject.executionContext); + if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { logger.write(MODULE_NAME, "[INFO] saveThemAll -> writeExecutionContext -> fileContent = " + fileContent); } cloudStorage.createTextFile(filePath, fileName, fileContent + '\n', onFileCreated); @@ -437,10 +442,6 @@ return; } - if (global.LOG_CONTROL[MODULE_NAME].logContent === true) { - logger.write(MODULE_NAME, "[INFO] saveThemAll -> writeExecutionContext -> onFileCreated -> Content written = " + fileContent); - } - writeExucutionHistory(callBack); return; } diff --git a/Root.js b/Root.js index 2034f14f5..e440c9870 100644 --- a/Root.js +++ b/Root.js @@ -119,7 +119,7 @@ logInfo: true, logWarnings: false, logErrors: true, - logContent: false, + logContent: true, intensiveLogging: false } }; diff --git a/package.json b/package.json index dac117026..b5dadd98a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@superalgos/clone-executor", - "version": "1.0.8", + "version": "1.0.9", "description": "Module responsible for executing the bots on the cloud.", "author": "Superalgos, ltd.", "license": "Apache-2.0",