You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/03/08 17:03:23 UTC
[incubator-openwhisk-package-alarms] branch master updated: disable
a throttled alarms trigger if retries exhausted (#136)
This is an automated email from the ASF dual-hosted git repository.
csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-package-alarms.git
The following commit(s) were added to refs/heads/master by this push:
new 84af22f disable a throttled alarms trigger if retries exhausted (#136)
84af22f is described below
commit 84af22f7df01d6b31846060d38241de4c521c827
Author: Jason Peterson <ja...@us.ibm.com>
AuthorDate: Thu Mar 8 12:03:21 2018 -0500
disable a throttled alarms trigger if retries exhausted (#136)
---
provider/lib/utils.js | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/provider/lib/utils.js b/provider/lib/utils.js
index 75125d8..ba38adf 100644
--- a/provider/lib/utils.js
+++ b/provider/lib/utils.js
@@ -79,7 +79,7 @@ module.exports = function(logger, triggerDB, redisClient) {
});
};
- this.postTrigger = function(dataTrigger, auth, retryCount) {
+ this.postTrigger = function(dataTrigger, auth, retryCount, throttleCount) {
var method = 'postTrigger';
return new Promise(function(resolve, reject) {
@@ -103,11 +103,14 @@ module.exports = function(logger, triggerDB, redisClient) {
logger.info(method, triggerIdentifier, 'http post request, STATUS:', response ? response.statusCode : undefined);
if (error || response.statusCode >= 400) {
+ logger.error(method, 'there was an error invoking', triggerIdentifier, response ? response.statusCode : error);
+ var throttleCounter = throttleCount || 0;
+
// only manage trigger fires if they are not infinite
if (dataTrigger.maxTriggers && dataTrigger.maxTriggers !== -1) {
dataTrigger.triggersLeft++;
}
- logger.error(method, 'there was an error invoking', triggerIdentifier, response ? response.statusCode : error);
+
if (!error && utils.shouldDisableTrigger(response.statusCode)) {
//disable trigger
var message = 'Automatically disabled after receiving a ' + response.statusCode + ' status code when firing the trigger';
@@ -116,18 +119,26 @@ module.exports = function(logger, triggerDB, redisClient) {
}
else {
if (retryCount < retryAttempts) {
+ throttleCounter = response && response.statusCode === HttpStatus.TOO_MANY_REQUESTS ? throttleCounter + 1 : throttleCounter;
logger.info(method, 'attempting to fire trigger again', triggerIdentifier, 'Retry Count:', (retryCount + 1));
setTimeout(function () {
- utils.postTrigger(dataTrigger, auth, (retryCount + 1))
+ utils.postTrigger(dataTrigger, auth, (retryCount + 1), throttleCounter)
.then(triggerId => {
resolve(triggerId);
})
.catch(err => {
reject(err);
});
- }, retryDelay);
+ }, Math.max(retryDelay, 1000 * Math.pow(throttleCounter, 2)));
} else {
- reject('Unable to reach server to fire trigger ' + triggerIdentifier);
+ if (throttleCounter === retryAttempts) {
+ var msg = 'Automatically disabled after continuously receiving a 429 status code when firing the trigger';
+ utils.disableTrigger(triggerIdentifier, 429, msg);
+ reject('Disabled trigger ' + triggerIdentifier + ' due to status code: 429');
+ }
+ else {
+ reject('Unable to reach server to fire trigger ' + triggerIdentifier);
+ }
}
}
} else {
--
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.