Skip to content

Commit 48c52a1

Browse files
C50-582 Total BOTs count is not updated in bots library, It was showing 0
2 parents 7e1b4c9 + d8bd3cf commit 48c52a1

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

server/app/engine/bots/scriptExecutor.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,21 @@ scriptExecutor.execute = function execute(botsDetails,auditTrail,userName,execut
122122

123123

124124
function executeScriptOnLocal(botsScriptDetails,auditTrail,userName,botHostDetails,callback) {
125+
logger.info("Bot script details",JSON.stringify(botsScriptDetails))
125126
var cryptoConfig = appConfig.cryptoSettings;
126127
var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password);
128+
var taskId = 'xxxxxx';
129+
if (botsScriptDetails.params){
130+
if(botsScriptDetails.params.data){
131+
if(botsScriptDetails.params.data.sysid){
132+
sysId = botsScriptDetails.params.data.sysid
133+
var decryptedText = cryptography.decryptText(sysId, cryptoConfig.decryptionEncoding,
134+
cryptoConfig.encryptionEncoding);
135+
taskId = decryptedText
136+
logger.info("Task ID",taskId)
137+
}
138+
}
139+
}
127140
var actionId = uuid.v4();
128141
var logsReferenceIds = [botsScriptDetails.id, actionId];
129142
var replaceTextObj = {
@@ -209,7 +222,8 @@ function executeScriptOnLocal(botsScriptDetails,auditTrail,userName,botHostDetai
209222
});
210223
request.post(options, function (err, res, body) {
211224
if (err) {
212-
logger.error(err);
225+
logger.error("task_id"+taskId+" "+JSON.stringify(err))
226+
logger.error("Error: task_id"+taskId+" Configure appropriate bot executor with proper osType ")
213227
var timestampEnded = new Date().getTime();
214228
logsDao.insertLog({
215229
referenceId: logsReferenceIds,

server/app/services/botService.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,16 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
379379
var botId = null;
380380
var botRemoteServerDetails = {};
381381
var bots = [];
382+
var taskId = 'xxxxxx';
383+
var cryptoConfig = appConfig.cryptoSettings;
384+
var cryptography = new Cryptography(cryptoConfig.algorithm, cryptoConfig.password);
382385
logger.info("Entering WF");
386+
if (reqBody.data){
387+
if(reqBody.data.sysid){
388+
logger.info("SYS ID",reqBody.data.sysid)
389+
taskId = reqBody.data.sysid
390+
}
391+
}
383392
async.waterfall([
384393
function (next) {
385394
botDao.getBotsByBotId(botsId, next);
@@ -408,30 +417,31 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
408417
//logger.info("Executing BOTs Deatails", bots[0].execution[0].os, bots[0].execution[0].type);
409418
masterUtil.getBotRemoteServerDetailByOrgId(bots[0].orgId, function (err, botServerDetails) {
410419
if (err) {
411-
logger.error("Error while fetching BOTs Server Details");
420+
logger.error("Error while fetching BOTs Server Details "+"task_id"+taskId);
412421
callback(err, null);
413422
return;
414423

415424
} else if (botServerDetails !== null && botServerDetails.length > 0) {
416-
logger.info("Checking flag status--->", appConfig.enableBotExecuterOsCheck)
425+
logger.info("task_id"+taskId+" Checking flag status--->", appConfig.enableBotExecuterOsCheck)
417426
if (bots[0].type === 'blueprints') {
418427
botRemoteServerDetails.hostIP = botServerDetails[0].hostIP;
419428
botRemoteServerDetails.hostPort = botServerDetails[0].hostPort;
420429
} else {
421430
//As env variable will always be in string changed the check value to string
422431
if (appConfig.enableBotExecuterOsCheck === true || process.env.enableBotExecuterOsCheck === 'true') {
423-
logger.info("Inn OS check condition");
432+
logger.info("task_id"+taskId+" Inn OS check condition");
424433
executorOsTypeConditionCheck(botServerDetails, botRemoteServerDetails, bots);
425434
} else {
426435

427436
botRemoteServerDetails.hostIP = botServerDetails[0].hostIP;
428437
botRemoteServerDetails.hostPort = botServerDetails[0].hostPort;
429-
logger.info("Default Details as working without Multiple executor feature", botRemoteServerDetails.hostIP, botRemoteServerDetails.hostPort);
438+
logger.info("task_id"+taskId+" Default Details as working without Multiple executor feature", botRemoteServerDetails.hostIP, botRemoteServerDetails.hostPort);
430439
}
431440
}
432441
encryptedParam(reqBody, next);
433442
} else {
434443
var error = new Error();
444+
logger.error("task_id"+taskId+" BOTs Remote Engine is not configured or not in running mode")
435445
error.message = 'BOTs Remote Engine is not configured or not in running mode';
436446
error.status = 403;
437447
//next(error, null);
@@ -443,6 +453,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
443453

444454
} else {
445455
var error = new Error();
456+
logger.error("task_id"+taskId+" There is no record available in DB against BOT :"+botsId)
446457
error.message = 'There is no record available in DB against BOT : ' + botsId;
447458
error.status = 403;
448459
next(error, null);
@@ -455,15 +466,15 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
455466
if (reqBody.nodeIds) {
456467
botObj.params.nodeIds = reqBody.nodeIds;
457468
}
458-
logger.info("Updating bot details" + JSON.stringify(botObj));
469+
logger.info("task_id"+taskId+" Updating bot details" + JSON.stringify(botObj));
459470
botDao.updateBotsDetail(botId, botObj, next);
460471
},
461472
function (updateStatus, next) {
462473
botDao.getBotsById(botId, next);
463474
},
464475
function (botDetails, next) {
465476
if (botDetails.length > 0) {
466-
logger.info("Executor in parallel " + JSON.stringify(botDetails));
477+
logger.info("task_id"+taskId+" Executor in parallel " + JSON.stringify(botDetails));
467478
async.parallel({
468479
executor: function (callback) {
469480
async.waterfall([
@@ -503,7 +514,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
503514
gitHubId: botDetails[0].gitHubId
504515
}, { $inc: { "runningCount": 1 } }, { upsert: true }, function (err, data) {
505516
if (err) logger.error(JSON.stringify(err))
506-
else logger.info("Running count of bot ", botDetails[0].name, "incremented successfully")
517+
else logger.info("task_id"+taskId+" Running count of bot ", botDetails[0].name, "incremented successfully")
507518
})
508519
auditTrailService.insertAuditTrail(botDetails[0], auditTrailObj, actionObj, next);
509520
},
@@ -527,6 +538,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
527538
jenkinsExecutor.execute(botDetails[0], auditTrail, reqBody, userName, next);
528539
} else {
529540
var err = new Error('Invalid BOT Type');
541+
logger.error("Error: Invalid BOT Type "+"task_id"+taskId)
530542
err.status = 400;
531543
err.msg = 'Invalid BOT Type';
532544
callback(err, null);
@@ -552,6 +564,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
552564
botDao.updateBotsDetail(botId, botUpdateObj, callback);
553565
} else {
554566
var err = new Error('Invalid BOT Type');
567+
logger.error("Error: Invalid BOT Type "+"task_id"+taskId)
555568
err.status = 400;
556569
err.msg = 'Invalid BOT Type';
557570
callback(err, null);
@@ -565,7 +578,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
565578
}
566579
});
567580
} else {
568-
logger.info("No Botdetails found ");
581+
logger.error("Error: No Botdetails found "+"task_id"+taskId);
569582
next(null, botDetails);
570583
}
571584
}
@@ -575,7 +588,7 @@ botService.executeBots = function executeBots(botsId, reqBody, userName, executi
575588
callback(err, null);
576589
return;
577590
} else {
578-
logger.info("Completed Bot execution " + JSON.stringify(results));
591+
logger.info("task_id"+taskId+" Completed Bot execution " + JSON.stringify(results));
579592
callback(null, results);
580593
return;
581594
}

0 commit comments

Comments
 (0)