Skip to content
Draft
Show file tree
Hide file tree
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
24 changes: 22 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ c.fs.compendium = path.join(c.fs.base, 'compendium');
c.fs.deleted = path.join(c.fs.base, 'deleted');
c.fs.job = path.join(c.fs.base, 'job');
c.fs.cache = path.join(c.fs.base, 'cache');
c.fs.dns = path.join(c.fs.base, 'dns');
c.fs.delete_inc = true;
c.fs.fail_on_no_files = yn(env.MUNCHER_FAIL_ON_NO_FILES || 'false');

Expand Down Expand Up @@ -88,6 +89,8 @@ c.user.level.view_candidates = 500;
c.user.level.view_status = 1000;
c.user.level.delete_compendium = 1000;
c.user.level.manage_links = 500;
c.user.level.manage_publisher = 1000;
c.user.level.manage_journal = 500;

// bagtainer configuration
c.bagtainer = {};
Expand Down Expand Up @@ -148,7 +151,6 @@ c.bagtainer.docker.create_options = {
Env: ['O2R_MUNCHER=true'],
Memory: 4294967296, // 4G
MemorySwap: 8589934592, // double of 4G
NetworkDisabled: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit this does make me a little bit nervous :-)

User: env.MUNCHER_CONTAINER_USER || '1000' // user name depends on image, use id to be save
};
c.bagtainer.rm = yn(env.EXECUTE_CONTAINER_RM || 'true');
Expand All @@ -167,7 +169,7 @@ c.email.sender = env.MUNCHER_EMAIL_SENDER;
// template for sending emails
//if (emailTransporter) {
// let mail = {
// from: config.email.sender, // sender address
// from: config.email.sender, // sender address
// to: config.email.receivers,
// subject: '[o2r platform] something happened',
// text: '...'
Expand Down Expand Up @@ -293,6 +295,24 @@ c.substitution.docker.volume.mode = ":ro";
c.substitution.docker.cmd = 'docker run -it --rm';
c.substitution.docker.imageNamePrefix = 'erc:';

c.dns = {};
c.dns.dnsmasq = {};
c.dns.priority = {};
c.dns.dockerfile = "" +
"FROM alpine:edge\n" +
"RUN apk --no-cache add dnsmasq\n" +
"EXPOSE 53/tcp 53/udp\n" +
"COPY dnsmasq.conf /etc/dnsmasq.conf\n" +
"CMD [\"dnsmasq\", \"--no-daemon\"]";
c.dns.dnsmasq.default = "" +
"log-queries\n" +
"no-hosts\n" +
"no-resolv\n" +
"cache-size=100000\n";
c.dns.dnsmasq.filterDummy = "server=/";
c.dns.priority.publisher = 100;
c.dns.priority.journal = 50;
Comment on lines +311 to +314
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gibt es hier irgendwas das ein Plattformbetreiber Konfigurieren wollen würde, oder ist das ziemlich stabil? Wenn Konfiguration, dann gerne das Muster mit den Umgebungsvariablen nutzen wie an anderen Stellen in dieser Datei.


c.checker = {};
c.checker.diffFileName = 'check.html';

Expand Down
1,443 changes: 767 additions & 676 deletions controllers/compendium.js

Large diffs are not rendered by default.

65 changes: 65 additions & 0 deletions controllers/dns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* (C) Copyright 2017 o2r project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

let Dns = require('../lib/model/dns');
let dnsManager = require('../lib/dns-manager');
const debug = require('debug')('muncher:dns');

exports.startServersOnStartup = function () {
return new Promise((fulfill, reject) => {
debug("Starting DNS servers on startup");
let promiseArray = [];
Dns.find((err, docs) => {
if (err) {
debug("Error searching for DNS Server configurations: %O", err);
reject(err);
} else if (docs.length < 1) {
debug("No DNS Server configurations in database");
reject("No DNS configurations in database");
} else {
for (let dns of docs) {
promiseArray.push(new Promise((fulfill2, reject2) => {
debug("Starting DNS Server: %s", dns.id);
dnsManager
.stopAndRemoveDnsServer(dns.id)
.then(() => {
buildNewDnsServer(dns.id)
.then(dnsManager.startNewDnsServer)
.then(() => {
debug("Successfully started DNS Server: %s", dns.id);
fulfill2();
})
.catch((err) => {
debug("Error starting DNS Server: %O", err);
reject2(err);
});
});
}));
}
}
Promise.all(promiseArray)
.then(() => {
debug("Successfully started all DNS Servers");
fulfill();
})
.catch((error) => {
debug("Error starting DNS Servers: %O", error);
reject(error);
});
});
});
}
17 changes: 9 additions & 8 deletions controllers/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const PublicLink = require('../lib/model/link');
const alwaysStepFields = ["start", "end", "status"];
const allStepsValue = "all";

exports.listJobs = (req, res) => {
exports.listJobs = (req, res) => {
var answer = {};
var filter = {};
var limit = parseInt(req.query.limit || config.list_limit, 10);
Expand Down Expand Up @@ -103,7 +103,7 @@ exports.listJobs = (req, res) => {
let link_ids = links.map((link) => {
return link.id;
});

if (requestedFields.length < 1) {
answer.results = jobs.map((job) => {
if (link_ids.indexOf(job.compendium_id) < 0 || job.compendium_id === req.query.compendium_id)
Expand All @@ -113,19 +113,19 @@ exports.listJobs = (req, res) => {
});
} else {
answer.results = jobs.map((job) => {
if (link_ids.indexOf(job.compendium_id) < 0)
if (link_ids.indexOf(job.compendium_id) < 0)
jobItem = { id: job.id };
requestedFields.forEach((elem) => {
jobItem[elem] = job[elem];
});

return jobItem;
}).filter(elem => {
return elem != null;
});
}
done(answer);

done(answer);
}
});
}
Expand Down Expand Up @@ -252,7 +252,7 @@ exports.createJob = (req, res) => {
req.user = { orcid: 'link.' + ident.link };
} else {
id = ident.compendium;

// check user level
if (!ident.is_link && !req.isAuthenticated()) {
res.status(401).send({ error: 'user is not authenticated' });
Expand All @@ -265,7 +265,7 @@ exports.createJob = (req, res) => {
}

// check compendium existence and load its metadata
Compendium.findOne({ id: ident.compendium }).select('id user candidate metadata bag compendium').exec((err, compendium) => {
Compendium.findOne({ id: ident.compendium }).select('id user journal candidate metadata bag compendium').exec((err, compendium) => {
// eslint-disable-next-line no-eq-null, eqeqeq
if (err || compendium == null) {
debug('[%s] compendium not found, cannot create job: %o', job_id, ident);
Expand All @@ -282,6 +282,7 @@ exports.createJob = (req, res) => {
var executionJob = new Job({
id: job_id,
user: req.user.orcid,
journal: compendium.journal,
compendium_id: id
});

Expand Down
Loading