Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
Add registration retries
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Loring committed May 18, 2016
1 parent 222209b commit b1027d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ module.exports = {

// These configuration options are for internal experimentation only.
internal: {
registerDelayOnFetcherErrorSec: 300 // 5 minutes.
registerDelayOnFetcherErrorSec: 300, // 5 minutes.
maxRegistrationRetryDelay: 40
}
}
};
4 changes: 2 additions & 2 deletions lib/debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ Debuglet.prototype.scheduleRegistration_ = function(seconds) {

function onError(err) {
that.logger_.error('Failed to re-register debuggee: ' + err);
that.logger_.error('Disabling gcloud debuglet');
that.stop(); // fatal error
that.scheduleRegistration_(Math.min((seconds + 1) * 2,
that.config_.internal.maxRegistrationRetryDelay));
}

setTimeout(function() {
Expand Down
25 changes: 25 additions & 0 deletions test/standalone/test-debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,31 @@ describe(__filename, function(){
debuglet.start();
});

it('should retry on failed registration', function(done) {
this.timeout(10000);
process.env.GCLOUD_PROJECT='11020304f2934';

var scope = nock(API)
.post(REGISTER_PATH)
.reply(404)
.post(REGISTER_PATH)
.reply(509)
.post(REGISTER_PATH)
.reply(200, {
debuggee: {
id: DEBUGGEE_ID
}
});

debuglet.once('registered', function(id) {
assert(id === DEBUGGEE_ID);
scope.done();
done();
});

debuglet.start();
});

it('should error if a package.json doesn\'t exist');

it('should register successfully otherwise', function(done) {
Expand Down

0 comments on commit b1027d2

Please sign in to comment.