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

Commit b1027d2

Browse files
author
Matt Loring
committed
Add registration retries
1 parent 222209b commit b1027d2

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ module.exports = {
7070

7171
// These configuration options are for internal experimentation only.
7272
internal: {
73-
registerDelayOnFetcherErrorSec: 300 // 5 minutes.
73+
registerDelayOnFetcherErrorSec: 300, // 5 minutes.
74+
maxRegistrationRetryDelay: 40
7475
}
7576
}
7677
};

lib/debuglet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ Debuglet.prototype.scheduleRegistration_ = function(seconds) {
142142

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

149149
setTimeout(function() {

test/standalone/test-debuglet.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ describe(__filename, function(){
9292
debuglet.start();
9393
});
9494

95+
it('should retry on failed registration', function(done) {
96+
this.timeout(10000);
97+
process.env.GCLOUD_PROJECT='11020304f2934';
98+
99+
var scope = nock(API)
100+
.post(REGISTER_PATH)
101+
.reply(404)
102+
.post(REGISTER_PATH)
103+
.reply(509)
104+
.post(REGISTER_PATH)
105+
.reply(200, {
106+
debuggee: {
107+
id: DEBUGGEE_ID
108+
}
109+
});
110+
111+
debuglet.once('registered', function(id) {
112+
assert(id === DEBUGGEE_ID);
113+
scope.done();
114+
done();
115+
});
116+
117+
debuglet.start();
118+
});
119+
95120
it('should error if a package.json doesn\'t exist');
96121

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

0 commit comments

Comments
 (0)