jenkins-bot has submitted this change and it was merged.
Change subject: Allow preventing retries of failed jobs
......................................................................
Allow preventing retries of failed jobs
If `config.frontend.failed_job_lockout_time` is set, the failure is
cached for the specified time and the jobs can not be force-retried
during this lockout period.
Change-Id: Id7a0e02220a3d69a0b67b6628cd26eb57213558e
---
M defaults.js
M lib/threads/frontend.js
2 files changed, 42 insertions(+), 32 deletions(-)
Approvals:
Cscott: Looks good to me, approved
jenkins-bot: Verified
diff --git a/defaults.js b/defaults.js
index 8aa4f6e..f2b1057 100644
--- a/defaults.js
+++ b/defaults.js
@@ -31,7 +31,12 @@
"frontend": {
"address": null,
"socket": null,
- "port": 17080
+ "port": 17080,
+ /** Failed jobs won't be retried until afer the lockout time
(in seconds).
+ * Should be <= garbage_collection.failed_job_lifetime
+ * A value of zero means that no time limit is enforced.
+ */
+ "failed_job_lockout_time": 0
},
/** Configuration for the backend bundling & and rendering process
threads. */
"backend": {
diff --git a/lib/threads/frontend.js b/lib/threads/frontend.js
index b5a7e84..285cc4c 100644
--- a/lib/threads/frontend.js
+++ b/lib/threads/frontend.js
@@ -449,43 +449,48 @@
var determineCachedStatus = Promise.method( function() {
var jobDetails;
- if ( !forceRender || !metabook ) {
- return redisClient.hget( config.redis.status_set_name,
collectionId )
- .then( function( result ) {
- if ( result ) {
- jobDetails = jd.fromJson(
result );
- if ( !metabook ) {
- metabookObj =
jobDetails.metabook;
- }
- console.debug( 'Checked cache
status for collection %s, status: %s',
- collectionId,
- jobDetails.state,
- {
- channel:
'frontend',
- request: { id:
requestId },
- job: { id:
collectionId }
- }
- );
- return ( jobDetails.state !==
"failed" );
- } else {
- return false;
+ return redisClient.hget( config.redis.status_set_name,
collectionId )
+ .then( function( result ) {
+ if ( result ) {
+ jobDetails = jd.fromJson( result );
+ if ( !metabook ) {
+ metabookObj =
jobDetails.metabook;
}
- } )
- .catch( function( err ) {
- console.error(
- 'Could not obtain cache status
about collection: %s',
+ console.debug( 'Checked cache status
for collection %s, status: %s',
collectionId,
- err,
+ jobDetails.state,
{
- channel:
'frontend.error',
- error: eh.jsonify( err
),
+ channel: 'frontend',
request: { id:
requestId },
job: { id: collectionId
}
}
);
- } );
- }
- return false;
+ // success == cached job, unless we
want to force render
+ if ( jobDetails.state === 'finished' ) {
+ return !forceRender;
+ }
+ // don't retry failed jobs if we've
configured a lockout
+ // and they're in it
+ var jobAge = Date.now() -
jobDetails.timestamp; /* ms */
+ if ( jobAge <
(config.frontend.failed_job_lockout_time * 1000) ) {
+ return true;
+ }
+ }
+ return false;
+ } )
+ .catch( function( err ) {
+ console.error(
+ 'Could not obtain cache status about
collection: %s',
+ collectionId,
+ err,
+ {
+ channel: 'frontend.error',
+ error: eh.jsonify( err ),
+ request: { id: requestId },
+ job: { id: collectionId }
+ }
+ );
+ } );
} );
/**
@@ -544,7 +549,7 @@
return determineCachedStatus().then( function( cacheStatus ) {
isCached = cacheStatus;
- if ( !isCached || forceRender ) {
+ if ( !isCached ) {
return canIRender().then( function( canRender )
{
if ( canRender ) {
return addRenderJob();
--
To view, visit https://gerrit.wikimedia.org/r/168532
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id7a0e02220a3d69a0b67b6628cd26eb57213558e
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>
Gerrit-Reviewer: Arlolra <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits