Skip to content

Commit c209634

Browse files
author
kkuzmin
authored
Do not include DL blob stats into checkin if DL container is not found. (#17)
* Do not include DL blob stats into checkin if DL container is not found. * Report DL container not found if customer deletes it * Don't try to get DL blob stats if APP_DL_CONTAINER_NAME is not set * Fix tests
1 parent c08444f commit c209634

File tree

4 files changed

+48
-3
lines changed

4 files changed

+48
-3
lines changed

dlblob.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class AlAzureDlBlob {
6464
}
6565

6666
/**
67-
* @function Retrievs the first page (5000) of dead letter blobs and finds the one with the maximum size.
67+
* @function Retrieves the first page (5000) of dead letter blobs and finds the one with the maximum size.
6868
*
6969
* @param callback
7070
* @returns callback

master.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ class AlAzureMaster {
334334
});
335335
}),
336336
async.reflect(function(callback) {
337-
return master._alAzureDlBlob.getDlBlobStats(callback);
337+
if (process.env.APP_DL_CONTAINER_NAME) {
338+
return master._alAzureDlBlob.getDlBlobStats(callback);
339+
} else {
340+
return callback(null, {});
341+
}
338342
})
339343
],
340344
function(err, results){

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alertlogic/al-azure-collector-js",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Alert Logic Azure Collector Common Library",
55
"license": "MIT",
66
"repository": {

test/master_test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const alcollector = require('@alertlogic/al-collector-js');
1515

1616
const AlAzureMaster = require('../master').AlAzureMaster;
1717
const AzureWebAppStats = require('../appstats').AzureWebAppStats;
18+
const CollectionStatRecord = require('../appstats').CollectionStatRecord;
1819
const mock = require('./mock');
1920

2021
describe('Master tests', function() {
@@ -455,6 +456,46 @@ describe('Master tests', function() {
455456
});
456457
});
457458

459+
it('Verify checkin ok, no DL stats', function(done) {
460+
const storedDlName = process.env.APP_DL_CONTAINER_NAME;
461+
delete process.env.APP_DL_CONTAINER_NAME;
462+
463+
// This should not be called
464+
nock('https://testappo365.blob.core.windows.net:443', {'encodedQueryParams':true})
465+
.get('/alertlogic-dl')
466+
.query(true)
467+
.times(5)
468+
.reply(404, mock.CONTAINER_NOT_FOUND);
469+
470+
var master = new AlAzureMaster(mock.DEFAULT_FUNCTION_CONTEXT, 'ehub', '1.0.0');
471+
master.checkin('2017-12-22T14:31:39', function(err, resp){
472+
if (err) console.log(err);
473+
process.env.APP_DL_CONTAINER_NAME = storedDlName;
474+
let cs = new CollectionStatRecord();
475+
cs.log.bytes = 10;
476+
cs.log.events = 15;
477+
const expectedCheckin = {
478+
body: {
479+
version: '1.0.0',
480+
app_tenant_id: 'tenant-id',
481+
collection_stats: cs,
482+
host_id: 'existing-host-id',
483+
source_id: 'existing-source-id',
484+
statistics: [{ 'Master': { 'errors': 0, 'invocations': 2 } }, { 'Collector': { 'errors': 1, 'invocations': 10 } }, { 'Updater': { 'errors': 0, 'invocations': 0 } }],
485+
// No DL stats
486+
//dl_stats: { dl_count: 6, max_dl_size: 4257 },
487+
status: 'ok',
488+
details: []
489+
}
490+
};
491+
const expectedUrl = '/azure/ehub/checkin/subscription-id/kktest11-rg/kktest11-name';
492+
fakeStats.restore();
493+
sinon.assert.calledWith(fakePost, expectedUrl, expectedCheckin);
494+
assert.equal(resp, mock.CHECKIN_RESPONSE_OK);
495+
done();
496+
});
497+
});
498+
458499
it('Verify checkin error', function(done) {
459500
// Mock Azure HTTP calls
460501
nock('https://management.azure.com:443', {'encodedQueryParams':true})

0 commit comments

Comments
 (0)