Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epankou/bug network containers not removed ewc 424 #450

Merged
merged 10 commits into from
Dec 20, 2018
1 change: 1 addition & 0 deletions src/cli/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ const _getMicroserviceStraceData = async function (obj) {

const result = await DiagnosticService.getMicroserviceStraceData(obj.microserviceUuid, {format: obj.format}, {}, true);
logger.info('Strace data:');
logger.info('=============================');
logger.info(result.data);
logger.info('Microservice strace data has been retrieved successfully.');
};
Expand Down
16 changes: 16 additions & 0 deletions src/services/microservices-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ async function _deleteMicroservice(microserviceUuid, microserviceData, user, isC
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_MICROSERVICE_UUID, microserviceUuid));
}

await _deletePortMappings(microservice, user, transaction);

if (microservice.microserviceStatus.status === MicroserviceStates.NOT_RUNNING) {
await _deleteMicroserviceWithRoutes(microserviceUuid, transaction);
} else {
Expand All @@ -258,6 +260,20 @@ async function _deleteMicroservice(microserviceUuid, microserviceData, user, isC
await _updateChangeTracking(false, microservice.iofogUuid, transaction)
}

async function _deletePortMappings(microservice, user, transaction) {
const msPortMappings = await MicroservicePortManager.findAll({
microserviceUuid: microservice.uuid
}, transaction);

for (let msPorts of msPortMappings) {
if (msPorts.isPublic) {
await _deletePortMappingOverConnector(microservice, msPorts, user, transaction)
} else {
await _deleteSimplePortMapping(microservice, msPorts, user, transaction)
}
}
}

async function _deleteNotRunningMicroservices(transaction) {
const microservices = await MicroserviceManager.findAllWithStatuses(transaction);
microservices
Expand Down