Skip to content

Commit

Permalink
Epankou/bug network containers not removed ewc 424 (#450)
Browse files Browse the repository at this point in the history
* EWC-418 added registry email validation

* EWC-421 strace feature bug

* EWC-421 strace feature bug fix

* bug(fix) iofog agent API: core network containers are returned when flow isn't active (EWC-424)

* bug(fix) microservice removal: port mapping removal (EWC-424)

* bug(fix) microservice removal: switched to const (EWC-424)
  • Loading branch information
epankou authored Dec 20, 2018
1 parent 484c4c2 commit 30b9796
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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 (const 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

0 comments on commit 30b9796

Please sign in to comment.