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:
parent
402b6e1156
commit
eaaf659674
|
@ -193,7 +193,20 @@ angular.module('ffffng')
|
|||
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);
|
||||
|
||||
var sendNextBatch = function (err) {
|
||||
|
@ -230,9 +243,9 @@ angular.module('ffffng')
|
|||
Logger
|
||||
.tag('monitoring', 'mail-sending')
|
||||
.debug(
|
||||
'Node not found. Skipping sending of "' + name + '" mail: ' + mac
|
||||
);
|
||||
return mailCallback(null);
|
||||
'Node not found. Skipping sending of "' + name + '" mail: ' + mac
|
||||
);
|
||||
return updateSkippedNode(nodeState.id, {}, mailCallback);
|
||||
}
|
||||
|
||||
if (node.monitoring && node.monitoringConfirmed) {
|
||||
|
@ -278,7 +291,7 @@ angular.module('ffffng')
|
|||
Logger
|
||||
.tag('monitoring', 'mail-sending')
|
||||
.info('Monitoring disabled, skipping "%s" mail for: %s', name, mac);
|
||||
return mailCallback(null);
|
||||
return updateSkippedNode(nodeState.id, {}, mailCallback);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue