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

Commit 66d67f8

Browse files
authored
Revert "Use service name as debuggee id on gke (#275)" (#278)
This reverts commit d3994f8 as it breaks on non-GKE GCP enviornments. See: #275 (comment)
1 parent e3c4853 commit 66d67f8

File tree

2 files changed

+3
-40
lines changed

2 files changed

+3
-40
lines changed

src/agent/debuglet.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ Debuglet.normalizeConfig_ = function(config) {
146146
var envConfig = {
147147
logLevel: process.env.GCLOUD_DEBUG_LOGLEVEL,
148148
serviceContext: {
149-
// If running on GKE, we will set service context later once
150-
// the cluster name can be retrieved from the metadata service.
151149
service: process.env.GAE_SERVICE || process.env.GAE_MODULE_NAME,
152150
version: process.env.GAE_VERSION || process.env.GAE_MODULE_VERSION,
153151
// Debug UI expects GAE_MINOR_VERSION to be available for AppEngine, but
@@ -208,23 +206,14 @@ Debuglet.prototype.start = function() {
208206

209207
that.logger_.info('Unique ID for this Application: ' + id);
210208

211-
that.getMetadataValues_(function(err, values) {
209+
that.getProjectId_(function(err, project, onGCP) {
212210
if (err) {
213211
that.logger_.error('Unable to discover projectId. Please provide ' +
214212
'the projectId to be able to use the Debuglet',
215213
err);
216214
that.emit('initError', err);
217215
return;
218216
}
219-
var project = values.project;
220-
var clusterName = values.clusterName;
221-
var onGCP = values.onGCP;
222-
223-
if (clusterName) {
224-
// If we succeeded to get a cluster name, we must be running on gke.
225-
that.config_.serviceContext.service = clusterName;
226-
that.config_.serviceContext.version = 'unversioned';
227-
}
228217

229218
that.getSourceContext_(function(err, sourceContext) {
230219
if (err) {
@@ -330,7 +319,7 @@ Debuglet.createDebuggee =
330319
/**
331320
* @private
332321
*/
333-
Debuglet.prototype.getMetadataValues_ = function(callback) {
322+
Debuglet.prototype.getProjectId_ = function(callback) {
334323
var that = this;
335324

336325
// We need to figure out whether we are running on GCP. We can use our ability
@@ -350,11 +339,7 @@ Debuglet.prototype.getMetadataValues_ = function(callback) {
350339
if (!project) {
351340
return callback(err);
352341
}
353-
metadata.instance(
354-
'attributes/cluster-name', function(err, response, metadataCluster) {
355-
return callback(null,
356-
{ project: project, clusterName: metadataCluster, onGCP: onGCP});
357-
});
342+
return callback(null, project, onGCP);
358343
});
359344
};
360345

test/test-debuglet.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,6 @@ describe('Debuglet', function() {
295295
assert.ok(_.isString(debuglet.config_.serviceContext.minorVersion_));
296296
});
297297

298-
it('should use GKE cluster name if available', function(done) {
299-
var scope = nock('http://metadata.google.internal')
300-
.get('/computeMetadata/v1/instance/attributes/cluster-name')
301-
.once()
302-
.reply(200, 'my-cool-cluster');
303-
var debug = require('../src/debug.js')(
304-
{projectId: 'fake-project', credentials: fakeCredentials});
305-
var debuglet = new Debuglet(debug, defaultConfig);
306-
debuglet.once('started', function(id) {
307-
debuglet.stop();
308-
assert.ok(debuglet.config_);
309-
assert.ok(debuglet.config_.serviceContext);
310-
assert.strictEqual(debuglet.config_.serviceContext.service,
311-
'my-cool-cluster');
312-
assert.strictEqual(debuglet.config_.serviceContext.version,
313-
'unversioned');
314-
scope.done();
315-
done();
316-
});
317-
debuglet.start();
318-
});
319-
320298
it('should not have minorVersion unless enviroment provides it',
321299
function() {
322300
var debug = require('../src/debug.js')();

0 commit comments

Comments
 (0)