push2cloud-cf-adapter
Advanced tools
Comparing version 1.7.2 to 1.7.3
const _ = require('lodash'); | ||
const APP_NOT_FOUND = 100004; | ||
module.exports = (api) => { | ||
@@ -23,3 +25,3 @@ return (options, callback) => { | ||
var appIdx = -1; | ||
if (result && result.code === 100004) { | ||
if (result && result.code === APP_NOT_FOUND) { | ||
appIdx = _.findIndex(api.actualDeploymentConfig.apps, { guid: options.appGuid }); | ||
@@ -34,3 +36,3 @@ if (appIdx >= 0) { | ||
if (err && !(result && result.code === 100004)) { | ||
if (err && !(result && result.code === APP_NOT_FOUND)) { | ||
return callback(err); | ||
@@ -37,0 +39,0 @@ } |
const _ = require('lodash'); | ||
const asyncOperationInProgressCheck = require('../lib/graceRequestHandler/asyncOperationInProgress'); | ||
const debug = require('debug')('push2cloud-cf-adapter:waitForServiceUnbound'); | ||
@@ -29,10 +30,9 @@ module.exports = (api) => { | ||
api.getServiceBinding({ serviceBindingGuid: options.serviceBindingGuid }, (newError, result) => { | ||
if (newError) { | ||
return callback(newError); | ||
} | ||
if (!result) { | ||
debug(`Unable to find service binding ${options.name || options.serviceBindingGuid}`); | ||
return callback(err); | ||
} | ||
debug(`Retrying to delete ${options.name || options.serviceBindingGuid}`); | ||
api.graceRequest({ | ||
@@ -46,7 +46,3 @@ method: 'DELETE', | ||
if (api.actualDeploymentConfig) { | ||
_.remove(api.actualDeploymentConfig.serviceBindings, { guid: options.serviceBindingGuid }); | ||
} | ||
callback(null, result); | ||
waitForServiceUnbound(options.serviceBindingGuid, result); | ||
}); | ||
@@ -56,13 +52,36 @@ }); | ||
if (err) { | ||
return callback(err); | ||
} | ||
waitForServiceUnbound(options.serviceBindingGuid, result); | ||
}); | ||
if (api.actualDeploymentConfig) { | ||
_.remove(api.actualDeploymentConfig.serviceBindings, { guid: options.serviceBindingGuid }); | ||
} | ||
let attempt = 0; | ||
const retryOptions = { | ||
maxRetries: 15, | ||
interval: 3 | ||
}; | ||
function waitForServiceUnbound(serviceBindingGuid, originalResult) { | ||
setTimeout(function() { | ||
api.getServiceBinding({ serviceBindingGuid: serviceBindingGuid }, (newError, result) => { | ||
callback(null, result); | ||
}); | ||
attempt++; | ||
debug(`${attempt}. attempt to check if service was successfully unbound ${options.name || options.serviceBindingGuid}`); | ||
// apparently an undefined result from the api.getServiceBinding means that | ||
// the service binding wasn't found -> we can assume that it was successfully unbound. | ||
if (!result) { | ||
debug(`Service ${options.name || options.serviceBindingGuid} was successfully unbound after ${attempt} retries`); | ||
if (api.actualDeploymentConfig) { | ||
_.remove(api.actualDeploymentConfig.serviceBindings, { guid: options.serviceBindingGuid }); | ||
} | ||
return callback(null, originalResult); | ||
} | ||
if (attempt >= retryOptions.maxRetries) { | ||
return callback(new Error(`Check if service was successfully unbound ${options.name || options.serviceBindingGuid} timed out! Most likely a swisscom issue.`)); | ||
} | ||
waitForServiceUnbound(serviceBindingGuid, originalResult); | ||
}); | ||
}, retryOptions.interval * 1000); | ||
} | ||
}; | ||
}; |
@@ -35,3 +35,3 @@ const debug = require('debug')('push2cloud-cf-adapter:waitForAllInstances'); | ||
if (attempt >= options.maxRetries) { | ||
return callback(new Error(`${options.name || options.appGuid} timeouted!`)); | ||
return callback(new Error(`${options.name || options.appGuid} timed out!`)); | ||
} | ||
@@ -38,0 +38,0 @@ |
@@ -22,3 +22,3 @@ const debug = require('debug')('push2cloud-cf-adapter:waitForServiceInstance'); | ||
if (attempt >= options.maxRetries) { | ||
return callback(new Error(`Waiting for service ${options.name || options.serviceInstanceGuid} timeouted!`)); | ||
return callback(new Error(`Waiting for service ${options.name || options.serviceInstanceGuid} timed out!`)); | ||
} | ||
@@ -25,0 +25,0 @@ |
{ | ||
"name": "push2cloud-cf-adapter", | ||
"version": "1.7.2", | ||
"version": "1.7.3", | ||
"description": "abstracts cloud foundry api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
155644
3129
4