Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
78a1201
EWC-373 microservice cli error message for volume mapping fix
mchepelev Nov 29, 2018
019d871
EWC-361 logger not found in microservice service fix
mchepelev Nov 29, 2018
18d8e59
EWC-361 abbility to delete route without closing ports on connector
mchepelev Nov 29, 2018
cdf1b69
EWC-361 recreating routes on update microservice only if necessary
mchepelev Nov 29, 2018
bef6785
EWC-384 connector devMode verification before using certificate
mchepelev Nov 29, 2018
3ffc0ba
EWC-377 cli config add ssl-key message fix
mchepelev Nov 29, 2018
1e21a07
Merge branch 'develop' into maksimchepelev/bugs
mchepelev Nov 30, 2018
7186681
EWC-386 cli connector add devMode is required now
mchepelev Nov 30, 2018
7ddb155
Merge branch 'develop' into maksimchepelev/bugs
mchepelev Dec 3, 2018
f8e8716
EWC-385 cli helps' outputs
mchepelev Dec 3, 2018
0620be0
EWC-395 cli `microservice port-mapping-remove` error message fix
mchepelev Dec 3, 2018
19177a6
EWC-389 cli `diagnostics strace-update` correct parsing of boolean
mchepelev Dec 3, 2018
3aa5960
EWC-390 cli `diagnostics strace-...` correct validation error messages
mchepelev Dec 3, 2018
aaa7e34
EWC-392 cli `diagnostics strace-info` microservice validation
mchepelev Dec 3, 2018
863e7bd
EWC-394 sequelize (deprecated)find -> findOne
mchepelev Dec 3, 2018
e591d1e
EWC-388 validation of flowId in delete flow service
mchepelev Dec 3, 2018
2544642
EWC-393 validation of microserviceUuid in image snapshot services
mchepelev Dec 3, 2018
8a9f2b4
unused var deleted
mchepelev Dec 3, 2018
40122d0
incorrect help message fix
mchepelev Dec 3, 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
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ $ iofog-controller config <*options*>
-a, --email-address string (Email address to send activations from) <br>
-w, --email-password string (Email password to send activations from) <br>
-s, --email-service string (Email service to send activations) <br>
-d, --log-dir string (Log files directory) <br>
-d, --log-dir string (Path to log files directory) <br>
-z, --log-size number (Log files size (MB)) <br>

*list*<br>
Expand Down Expand Up @@ -135,7 +135,7 @@ $ iofog-controller connector <*command*> <*options*>
-n, --name string (Connector name) <br>
-d, --domain string (Connector domain name) <br>
-i, --public-ip string (Connector public IP address) <br>
-c, --cert string (Certificate) <br>
-c, --cert string (Path to certificate file) <br>
-S, --self-signed-on (Switch on self-signed enabled) <br>
-s, --self-signed-off (Switch off self-signed disabled) <br>
-H, --dev-mode-on (Switch on dev mode) <br>
Expand Down Expand Up @@ -215,11 +215,11 @@ tunnel list
-d, --description string (ioFog node description) <br>
-D, --docker-url string (ioFog node docker url) <br>
-M, --disk-limit number (ioFog node disk usage limit (MB)) <br>
-T, --disk-directory string (ioFog node disk directory) <br>
-T, --disk-directory string (Path to ioFog node disk directory) <br>
-m, --memory-limit number (ioFog node memory usage limit (MB)) <br>
-c, --cpu-limit number (ioFog node CPU usage limit (%)) <br>
-G, --log-limit number (ioFog node log size limit (MB)) <br>
-Y, --log-directory string (ioFog node log files directory) <br>
-Y, --log-directory string (Path to ioFog node log files directory) <br>
-C, --log-file-count number (ioFog node log files count) <br>
-s, --status-frequency number (ioFog node status check frequency (seconds)) <br>
-F, --change-frequency number (ioFog node configuration change check frequency (seconds)) <br>
Expand Down Expand Up @@ -702,7 +702,7 @@ $ iofog-controller catalog <*command*> <*options*> <br>

*strace-info -i* <*microservice-id*><br>

-f, --format string (Format of strace data to receive)<br>
-f, --format string (Format of strace data to receive. Possible values: string, file)<br>

*strace-ftp-post -i* <*microservice-id*><br>

Expand Down
2 changes: 1 addition & 1 deletion src/cli/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Config extends BaseCLIHandler {
group: constants.CMD_ADD
},
{
name: 'log-dir', alias: 'd', type: String, description: 'Log files directory',
name: 'log-dir', alias: 'd', type: String, description: 'Path to log files directory',
group: constants.CMD_ADD
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/cli/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Connector extends BaseCLIHandler {
},
{
name: 'cert', alias: 'c', type: String,
description: 'Certificate',
description: 'Path to certificate file',
group: [constants.CMD_ADD, constants.CMD_UPDATE]
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/cli/diagnostics.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Diagnostics extends BaseCLIHandler {
constants.CMD_IMAGE_SNAPSHOT_CREATE, constants.CMD_IMAGE_SNAPSHOT_GET]
},
{
name: 'format', alias: 'f', type: String, description: 'Format of strace data to receive',
name: 'format', alias: 'f', type: String, description: 'Format of strace data to receive. Possible values: string, file',
group: [constants.CMD_STRACE_INFO]
},
{
Expand Down Expand Up @@ -128,7 +128,7 @@ const _executeCase = async function (diagnosticCommand, commandName, f, isUserRe
const _changeMicroserviceStraceState = async function (obj) {
logger.info(JSON.stringify(obj));

const enable = AppHelper.validateBooleanCliOptions(obj.disable, obj.enable);
const enable = AppHelper.validateBooleanCliOptions(obj.enable, obj.disable);
await DiagnosticService.changeMicroserviceStraceState(obj.microserviceId, {enable: enable}, {}, true);
const msg = enable ? 'Microservice strace has been enabled' : 'Microservice strace has been disabled';
logger.info(msg);
Expand Down
4 changes: 2 additions & 2 deletions src/cli/iofog.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class IOFog extends BaseCLIHandler {
},
{
name: 'disk-directory', alias: 'T', type: String,
description: 'ioFog node disk directory',
description: 'Path to ioFog node disk directory',
group: [constants.CMD_UPDATE, constants.CMD_ADD]
},
{
Expand All @@ -119,7 +119,7 @@ class IOFog extends BaseCLIHandler {
},
{
name: 'log-directory', alias: 'Y', type: String,
description: 'ioFog node log files directory',
description: 'Path to ioFog node log files directory',
group: [constants.CMD_UPDATE, constants.CMD_ADD]
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/cli/microservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ const _removePortMapping = async function (obj, user) {
await MicroserviceService.deletePortMapping(obj.microserviceId, internalPort, user, true);
logger.info('Port mapping has been deleted successfully.');
} catch (e) {
logger.error(ErrorMessages.CLI.INVALID_INTERNAL_PORT);
logger.error(e.message);
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/sequelize/managers/email-activation-code-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EmailActivationCodeManager extends BaseManager {
async getByActivationCode(activationCode, transaction) {
AppHelper.checkTransaction(transaction);

return EmailActivationCode.find({
return EmailActivationCode.findOne({
where: {
activationCode: activationCode
}
Expand All @@ -48,7 +48,7 @@ class EmailActivationCodeManager extends BaseManager {
};

async verifyActivationCode(activationCode, transaction) {
return EmailActivationCode.find({
return EmailActivationCode.findOne({
where: {
activationCode: activationCode,
expirationTime: {
Expand Down
2 changes: 1 addition & 1 deletion src/sequelize/managers/iofog-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FogManager extends BaseManager {

// no transaction required here, used by auth decorator
checkToken(token) {
return Fog.find({
return Fog.findOne({
include: [{
model: FogAccessToken,
as: 'accessToken',
Expand Down
10 changes: 5 additions & 5 deletions src/sequelize/managers/user-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class UserManager extends BaseManager {
findByAccessToken(token, transaction) {
AppHelper.checkTransaction(transaction);

return User.find({
return User.findOne({
include: [{
model: AccessToken,
as: 'accessToken',
Expand All @@ -43,7 +43,7 @@ class UserManager extends BaseManager {
}

findByEmail(email) {
return User.find({
return User.findOne({
where: {
email: email
}
Expand All @@ -52,7 +52,7 @@ class UserManager extends BaseManager {

// no transaction required here, used by auth decorator
checkAuthentication(token) {
return User.find({
return User.findOne({
include: [{
model: AccessToken,
as: 'accessToken',
Expand All @@ -65,7 +65,7 @@ class UserManager extends BaseManager {

// no transaction required here, used by cli decorator
findById(id) {
return User.find({where: {id: id}});
return User.findOne({where: {id: id}});
}

updateDetails(user, updateObject, transaction) {
Expand All @@ -92,7 +92,7 @@ class UserManager extends BaseManager {

// no transaction required here, used by cli decorator
findById(id) {
return User.find({where: {id: id}});
return User.findOne({where: {id: id}});
}
}

Expand Down
23 changes: 19 additions & 4 deletions src/services/diagnostic-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const TransactionDecorator = require('../decorators/transaction-decorator');
const AppHelper = require('../helpers/app-helper');
const Errors = require('../helpers/errors');
const ErrorMessages = require('../helpers/error-messages');
const validator = require('../schemas/index');
const Validator = require('../schemas/index');
const MicroserviceService = require('../services/microservices-service');
const StraceDiagnosticManager = require('../sequelize/managers/strace-diagnostics-manager');
const ChangeTrackingService = require('./change-tracking-service');
Expand All @@ -29,7 +29,7 @@ const mime = require('mime');


const changeMicroserviceStraceState = async function (id, data, user, isCLI, transaction) {
validator.validate(data, validator.schemas.straceStateUpdate);
await Validator.validate(data, Validator.schemas.straceStateUpdate);
const microservice = await MicroserviceService.getMicroservice(id, user, isCLI, transaction);
if (microservice.iofogUuid === null) {
throw new Errors.ValidationError(ErrorMessages.STRACE_WITHOUT_FOG);
Expand All @@ -45,7 +45,16 @@ const changeMicroserviceStraceState = async function (id, data, user, isCLI, tra
};

const getMicroserviceStraceData = async function (id, data, user, isCLI, transaction) {
validator.validate(data, validator.schemas.straceGetData);
await Validator.validate(data, Validator.schemas.straceGetData);

const microserviceWhere = isCLI
? {uuid: id}
: {uuid: id, userId: user.id};
const microservice = await MicroserviceManager.findOne(microserviceWhere, transaction);
if (!microservice) {
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_MICROSERVICE_UUID, id))
}

const straceData = await StraceDiagnosticManager.findOne({microserviceUuid: id}, transaction);
const dir = config.get('Diagnostics:DiagnosticDir') || 'diagnostics';
const filePath = dir + '/' + id;
Expand All @@ -65,7 +74,7 @@ const getMicroserviceStraceData = async function (id, data, user, isCLI, transac
};

const postMicroserviceStraceDatatoFtp = async function (id, data, user, isCLI, transaction) {
validator.validate(data, validator.schemas.stracePostToFtp);
await Validator.validate(data, Validator.schemas.stracePostToFtp);
const straceData = await StraceDiagnosticManager.findOne({microserviceUuid: id}, transaction);
const dir = config.get('Diagnostics:DiagnosticDir');
const filePath = dir + '/' + id;
Expand All @@ -90,6 +99,9 @@ const postMicroserviceImageSnapshotCreate = async function (microserviceUuid, us

const microservice = await MicroserviceManager.findOneWithDependencies(where, {}, transaction);

if (!microservice) {
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_MICROSERVICE_UUID, microserviceUuid));
}
if (microservice.iofogUuid === null) {
throw new Errors.ValidationError(ErrorMessages.IMAGE_SNAPSHOT_WITHOUT_FOG);
}
Expand All @@ -113,6 +125,9 @@ const getMicroserviceImageSnapshot = async function (microserviceUuid, user, isC
userId: user.id
};
const microservice = await MicroserviceManager.findOneWithDependencies(where, {}, transaction);
if (!microservice) {
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_MICROSERVICE_UUID, microserviceUuid));
}
if (microservice.iofogUuid === null) {
throw new Errors.ValidationError(ErrorMessages.IMAGE_SNAPSHOT_WITHOUT_FOG);
}
Expand Down
10 changes: 4 additions & 6 deletions src/services/flow-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,14 @@ const _deleteFlow = async function (flowId, user, isCLI, transaction) {

await _updateChangeTrackingsByFlowId(flowId, transaction)

const affectedRows = await FlowManager.delete(where, transaction);

if (affectedRows === 0) {
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_FLOW_ID, flowId));
}

await FlowManager.delete(where, transaction);
};

async function _updateChangeTrackingsByFlowId(flowId, transaction) {
const flowWithMicroservices = await FlowManager.findFlowMicroservices({id: flowId}, transaction);
if (!flowWithMicroservices) {
throw new Errors.NotFoundError(AppHelper.formatMessage(ErrorMessages.INVALID_FLOW_ID, flowId));
}
const onlyUnique = (value, index, self) => self.indexOf(value) === index;
const iofogUuids = flowWithMicroservices.microservices
.map(obj => obj.iofogUuid)
Expand Down