Fix: Update node data even when skipping.

Also prevents infinite loop as the SELECT to loads the batch
checks modified_at.
This commit is contained in:
baldo 2016-06-29 12:02:46 +02:00
parent 402b6e1156
commit eaaf659674

View file

@ -193,7 +193,20 @@ angular.module('ffffng')
callback(null, data); callback(null, data);
} }
function sendMonitoringMailsBatched(name, mailType, findBatchFun, callback) { function updateSkippedNode(id, node, callback) {
Database.run(
'UPDATE node_state ' +
'SET hostname = ?, monitoring_state = ?, modified_at = ?' +
'WHERE id = ?',
[
node ? node.hostname : '', node ? node.monitoringState : '', moment().unix(),
id
],
callback
);
}
function sendMonitoringMailsBatched(name, mailType, findBatchFun, callback) {
Logger.tag('monitoring', 'mail-sending').debug('Sending "%s" mails...', name); Logger.tag('monitoring', 'mail-sending').debug('Sending "%s" mails...', name);
var sendNextBatch = function (err) { var sendNextBatch = function (err) {
@ -230,9 +243,9 @@ angular.module('ffffng')
Logger Logger
.tag('monitoring', 'mail-sending') .tag('monitoring', 'mail-sending')
.debug( .debug(
'Node not found. Skipping sending of "' + name + '" mail: ' + mac 'Node not found. Skipping sending of "' + name + '" mail: ' + mac
); );
return mailCallback(null); return updateSkippedNode(nodeState.id, {}, mailCallback);
} }
if (node.monitoring && node.monitoringConfirmed) { if (node.monitoring && node.monitoringConfirmed) {
@ -278,7 +291,7 @@ angular.module('ffffng')
Logger Logger
.tag('monitoring', 'mail-sending') .tag('monitoring', 'mail-sending')
.info('Monitoring disabled, skipping "%s" mail for: %s', name, mac); .info('Monitoring disabled, skipping "%s" mail for: %s', name, mac);
return mailCallback(null); return updateSkippedNode(nodeState.id, {}, mailCallback);
} }
}); });
}, },