Skip to content

Commit

Permalink
better timeout and rollback implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
grabnerandi committed May 2, 2018
1 parent c44d314 commit 4ae46c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Binary file modified copytos3/lambdas.zip
Binary file not shown.
6 changes: 4 additions & 2 deletions lambdas/handleDynatraceProblemNotification.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ var findCodeDeployDeploymentInformation = function(mostRecentEvents, index, call
// lets see if there is a rollback deployment

// "previousRevision":{"revisionType":"S3","s3Location":{"bucket":"codepipeline-artifacts-agrabner-dynatracedevops","key":"SampleDevOpsPipeline/SampleDevO/075Icjq.zip","bundleType":"zip","version":"0tUa9GFNfLmnTA0l8oEejg4ODg.9sDzH","eTag":"9ae34d4b55ab28340ade5875173cb20f"}}
// console.log("Previous Revision: " + JSON.stringify(data.deploymentInfo));
console.log("getDeployment: " + JSON.stringify(data));

event.CodeDeploy = data;

Expand Down Expand Up @@ -235,7 +235,9 @@ var getMostRecentDeploymentOnEntity = function(entities, index, timespan, result
// if we got a list of events only look at the most recent one that came from CodePipeline
if(statusCode == 200 && data) {
var events = JSON.parse(data).events;
for(var eventIx=events.length-1;eventIx>=0;eventIx--) {
// May 2nd 2018: changed iteration as it seems Problem Events REST API is now automatically sorting events descending timeorder. this used to be different. I want to find the "newest" AWS CodePipeline deployment
// for(var eventIx=events.length-1;eventIx>=0;eventIx--) {
for(var eventIx=0;eventIx<events.length;eventIx++) {
var event = events[eventIx];
if(event.source == "AWS CodePipeline") {
// only push it if the same deploymentId is not already on the list, e.g: if a deployment deployes to multiple instances we only need the deployment once
Expand Down
6 changes: 5 additions & 1 deletion lambdas/pushDynatraceDeploymentEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ var monspec = require('utils/monspec');
// -- CUSTOM_ANNOTATION: annotationType (mandatory), annotationDescription (optional)
// -- BOTH (optional): source, customProperties

// Global Settings for post retry
var retryTimespan = 10000
var retryCount = 6

// handles the request to create a custom event in Dynatrace
exports.handler = function(event, context, callback) {

Expand Down Expand Up @@ -229,7 +233,7 @@ var postEventToDynatraceApi = function(postedData, codePipelineJobId, context) {
}

// lets log our call to Dynatrace
doPostWithRetry(dtEventUrl, postedData, event, codePipelineJobId, context, 5, 5000);
doPostWithRetry(dtEventUrl, postedData, event, codePipelineJobId, context, retryCount, retryTimespan);
}

/**
Expand Down

0 comments on commit 4ae46c5

Please sign in to comment.