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 flow deactivation ewc 293 #301

Merged
merged 37 commits into from
Nov 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
06aa871
microservice validation refactoring
Oct 25, 2018
064e9f8
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
6734bf1
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
93622c1
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
eef356d
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
0b7d665
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
248d773
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
c0755e4
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
a71671e
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 25, 2018
1fce81b
cli microservice wip
Oct 26, 2018
f491bb3
cli microservice wip
Oct 26, 2018
16d589f
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 26, 2018
e732b3e
microservices cli wip
Oct 26, 2018
8c295bf
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 26, 2018
d32b759
cli microservices final
Oct 26, 2018
24f4c2b
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 26, 2018
ff17ccf
microservice cli refactoring
Oct 29, 2018
e27899f
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
3219642
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
f662aa9
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
dc9621a
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
231b5ff
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
b3b1547
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
17b8688
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 29, 2018
5ce12d8
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 30, 2018
7dc67a3
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 30, 2018
308c83c
Merge branch 'new-fog-controller' of https://github.com/ioFog/FogCont…
Oct 30, 2018
2fb2215
Merge branch 'develop' of https://github.com/ioFog/FogController into…
Oct 30, 2018
0514066
Merge branch 'develop' of https://github.com/ioFog/FogController into…
Oct 30, 2018
7589b11
removed column need_update from microservices
Oct 31, 2018
7726845
merge
Oct 31, 2018
0fddb1b
removed column need_update from microservices
Oct 31, 2018
2a13a0d
Merge branch 'develop' of https://github.com/ioFog/FogController into…
Oct 31, 2018
e53ed70
Merge branch 'develop' of https://github.com/ioFog/FogController into…
Oct 31, 2018
44d805c
EWC-293 flow deactivation
Nov 1, 2018
a555de3
EWC-293 flow deactivation
Nov 1, 2018
491032d
EWC-293 flow deactivation
Nov 1, 2018
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
8 changes: 4 additions & 4 deletions src/cli/microservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,19 +242,19 @@ class Microservice extends BaseCLIHandler {
example: '$ iofog-controller microservice add [other required options] --routes ABC:DEF RFG:HJK'
},
{
desc: '4. Add route (ABC:DEF - source microservice id : dest microservice id)',
desc: '5. Add route (ABC:DEF - source microservice id : dest microservice id)',
example: '$ iofog-controller microservice route-create --route ABC:DEF',
},
{
desc: '5. Delete route (ABC:DEF - source microservice id : dest microservice id)',
desc: '6. Delete route (ABC:DEF - source microservice id : dest microservice id)',
example: '$ iofog-controller microservice route-remove --route ABC:DEF',
},
{
desc: '6. Create port mapping (80:8080:false - internal port : external port : public mode, ABC - microservice)',
desc: '7. Create port mapping (80:8080:false - internal port : external port : public mode, ABC - microservice)',
example: '$ iofog-controller microservice port-mapping-create --mapping 80:8080:false -i ABC'
},
{
desc: '7. Delete port mapping (80 - internal port, ABC - microservice id)',
desc: '8. Delete port mapping (80 - internal port, ABC - microservice id)',
example: '$ iofog-controller microservice port-mapping-remove --internal-port 80 -i ABC'
}
],
Expand Down
2 changes: 1 addition & 1 deletion src/schemas/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const catalogItemCreate = {
"inputType": {"$ref": "/type"},
"outputType": {"$ref": "/type"}
},
"required": ["name"],
"required": ["name", "registryId", "images"],
"additionalProperties": false
};

Expand Down
2 changes: 1 addition & 1 deletion src/sequelize/managers/flow-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FlowManager extends BaseManager {
include: [
{
model: Microservice,
as: 'microservice',
as: 'microservices',
required: false,
attributes: ['iofogUuid']
}
Expand Down
52 changes: 51 additions & 1 deletion src/sequelize/managers/microservice-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Fog = models.Fog;
const Flow = models.Flow;
const User = models.User;
const Routing = models.Routing;
const Registry = models.Registry;

class MicroserviceManager extends BaseManager {
getEntity() {
Expand Down Expand Up @@ -53,7 +54,7 @@ class MicroserviceManager extends BaseManager {
{
model: CatalogItem,
as: 'catalogItem',
required: false,
required: true,
include: [{
model: CatalogItemImage,
as: 'images',
Expand Down Expand Up @@ -86,6 +87,55 @@ class MicroserviceManager extends BaseManager {
}, {transaction: transaction})
}

findAllActiveFlowMicroservices(iofogUuid, transaction) {
return Microservice.findAll({
include: [
{
model: MicroservicePort,
as: 'ports',
required: false,
attributes: ['portInternal', 'portExternal']
},
{
model: VolumeMapping,
as: 'volumeMappings',
required: false,
attributes: ['hostDestination', 'containerDestination', 'accessMode']
},
{
model: CatalogItem,
as: 'catalogItem',
required: true,
include: [
{
model: CatalogItemImage,
as: 'images',
required: true,
attributes: ['containerImage', 'fogTypeId']
},
{
model: Registry,
as: 'registry',
required: true,
attributes: ['url']
}
],
attributes: ['picture']
},
{
model: Flow,
as: 'flow',
required: true,
attributes: ['isActivated']
}
],
where: {
iofogUuid: iofogUuid,
'$flow.is_activated$': true
}
}, {transaction: transaction})
}

findOneWithDependencies(where, attributes, transaction) {
return Microservice.findOne({
include: [
Expand Down
2 changes: 1 addition & 1 deletion src/sequelize/models/flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = (sequelize, DataTypes) => {
name: 'flowId',
field: 'flow_id'
},
as: 'microservice'
as: 'microservices'
})
};
return Flow;
Expand Down
25 changes: 6 additions & 19 deletions src/services/agent-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,28 +207,15 @@ const updateAgentStatus = async function (agentStatus, fog, transaction) {
};

const getAgentMicroservices = async function (fog, transaction) {
const microservices = await MicroserviceManager.findAllWithDependencies({
iofogUuid: fog.uuid
}, {}, transaction);
const microservices = await MicroserviceManager.findAllActiveFlowMicroservices(fog.uuid, transaction);

const fogTypeId = fog.fogTypeId;

const response = [];
for (const microservice of microservices) {
let imageId = '';
for (let microservice of microservices) {
const images = microservice.catalogItem.images;
for (const image of images) {
if (image.fogTypeId === fogTypeId) {
imageId = image.containerImage;
break;
}
}

const registry = await RegistryManager.findOne({
id: microservice.catalogItem.registryId
}, transaction);

const registryUrl = registry.url;
const image = images.find(image => image.fogTypeId === fogTypeId);
const imageId = image ? image.containerImage : '';

const routes = await MicroserviceService.getPhysicalConections(microservice, transaction);

Expand All @@ -239,7 +226,7 @@ const getAgentMicroservices = async function (fog, transaction) {
rebuild: microservice.rebuild,
rootHostAccess: microservice.rootHostAccess,
logSize: microservice.logSize,
registryUrl: registryUrl,
registryUrl: microservice.catalogItem.registry.url,
portMappings: microservice.ports,
volumeMappings: microservice.volumeMappings,
imageSnapshot: microservice.imageSnapshot,
Expand Down Expand Up @@ -418,7 +405,7 @@ async function _checkMicroservicesFogType(fog, fogTypeId, transaction) {

for (const microservice of microservices) {
let exists = false;
for (const image of microservice.catalogItem.images) {
for (let image of microservice.catalogItem.images) {
if (image.fogTypeId === fogTypeId) {
exists = true;
break;
Expand Down
3 changes: 1 addition & 2 deletions src/services/flow-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const ChangeTrackingManager = require('../sequelize/managers/change-tracking-man
const _createFlow = async function (flowData, user, isCLI, transaction) {
await Validation.validate(flowData, Validation.schemas.flowCreate);

await isFlowExist(flowData.name, transaction);
await _checkForDuplicateName(flowData.name, {}, transaction);

const flowToCreate = {
Expand Down Expand Up @@ -84,7 +83,7 @@ const _updateFlow = async function (flowData, flowId, user, isCLI, transaction)
if (oldFlow.isActivated !== flowData.isActivated) {
const flowWithMicroservices = await FlowManager.findFlowMicroservices({id: flowId}, transaction);
const onlyUnique = (value, index, self) => self.indexOf(value) === index;
const iofogUuids = flowWithMicroservices.microservice
const iofogUuids = flowWithMicroservices.microservices
.map(obj => obj.iofogUuid)
.filter(onlyUnique)
.filter(val => val !== null);
Expand Down