Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions src/services/microservices-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,24 @@ const _updateMicroservice = async function (microserviceUuid, microserviceData,
await _updateVolumeMappings(microserviceDataUpdate.volumeMappings, microserviceUuid, transaction);
}

if (microserviceDataUpdate.iofogUuid) {
await _deleteRoutes(microserviceData.routes, microserviceUuid, transaction);
await _createRoutes(microserviceData.routes, microserviceUuid, user, transaction);
await _updateChangeTracking(false, microserviceDataUpdate.iofogUuid, transaction)
if (microserviceDataUpdate.iofogUuid !== microservice.iofogUuid) {
const routes = await _getLogicalNetworkRoutesByFog(microservice.iofogUuid, transaction);
for (let route of routes) {
await _deleteRoute(route.sourceMicroserviceUuid, route.destMicroserviceUuid, user, isCLI, transaction);
await _createRoute(route.sourceMicroserviceUuid, route.destMicroserviceUuid, user, isCLI, transaction);
//update change tracking for another fog in route
if (microservice.iofogUuid === route.sourceIofogUuid) {
await _updateChangeTracking(false, route.destIofogUuid, transaction);
} else if (microservice.iofogUuid === route.destIofogUuid) {
await _updateChangeTracking(false, route.sourceIofogUuid, transaction);
}
}
//update change tracking for old fog
await _updateChangeTracking(false, microservice.iofogUuid, transaction);
}

await _updateChangeTracking(microserviceData.config ? true : false, microservice.iofogUuid, transaction);
//update change tracking for new fog
await _updateChangeTracking(microserviceData.config ? true : false, microserviceDataUpdate.iofogUuid, transaction);
};

const _updateVolumeMappings = async function (volumeMappings, microserviceUuid, transaction) {
Expand Down Expand Up @@ -769,7 +780,7 @@ async function getPhysicalConections(microservice, transaction) {
const sourceRoutes = await RoutingManager.findAll({sourceMicroserviceUuid: microservice.uuid}, transaction)
for (const sr of sourceRoutes) {
if (!sr.sourceIofogUuid || !sr.destIofogUuid) {
break;
continue;
} else if (sr.sourceIofogUuid === sr.destIofogUuid) {
res.push(sr.destMicroserviceUuid)
} else if (sr.sourceIofogUuid !== sr.destIofogUuid) {
Expand All @@ -785,6 +796,28 @@ async function getPhysicalConections(microservice, transaction) {
return res
}

async function _getLogicalNetworkRoutesByFog(iofogUuid, transaction) {
let res = [];
const query = {
[Op.or]:
[
{
sourceIofogUuid: iofogUuid
},
{
destIofogUuid: iofogUuid
}
]
};
const routes = await RoutingManager.findAll(query, transaction)
for (let route of routes) {
if (route.sourceIofogUuid && route.destIofogUuid && route.isNetworkConnection) {
res.push(route);
}
}
return res;
}

async function _buildLink(protocol, ip, port) {
return `${protocol}://${ip}:${port}`
}
Expand Down