add initial compileGroup support

This commit is contained in:
Brian Gough
2020-06-11 16:01:44 +01:00
parent 9b92793b89
commit b33734bab6
9 changed files with 183 additions and 18 deletions

View File

@@ -199,7 +199,8 @@ module.exports = CompileManager = {
timeout: request.timeout,
image: request.imageName,
flags: request.flags,
environment: env
environment: env,
compileGroup: request.compileGroup
},
function(error, output, stats, timings) {
// request was for validation only
@@ -536,6 +537,7 @@ module.exports = CompileManager = {
const directory = getCompileDir(project_id, user_id)
const timeout = 60 * 1000 // increased to allow for large projects
const compileName = getCompileName(project_id, user_id)
const compileGroup = 'synctex'
return CommandRunner.run(
compileName,
command,
@@ -543,6 +545,7 @@ module.exports = CompileManager = {
Settings.clsi != null ? Settings.clsi.docker.image : undefined,
timeout,
{},
compileGroup,
function(error, output) {
if (error != null) {
logger.err(
@@ -606,6 +609,7 @@ module.exports = CompileManager = {
const compileDir = getCompileDir(project_id, user_id)
const timeout = 60 * 1000
const compileName = getCompileName(project_id, user_id)
const compileGroup = 'wordcount'
return fse.ensureDir(compileDir, function(error) {
if (error != null) {
logger.err(
@@ -621,6 +625,7 @@ module.exports = CompileManager = {
image,
timeout,
{},
compileGroup,
function(error) {
if (error != null) {
return callback(error)

View File

@@ -45,7 +45,16 @@ module.exports = DockerRunner = {
ERR_EXITED: new Error('exited'),
ERR_TIMED_OUT: new Error('container timed out'),
run(project_id, command, directory, image, timeout, environment, callback) {
run(
project_id,
command,
directory,
image,
timeout,
environment,
compileGroup,
callback
) {
let name
if (callback == null) {
callback = function(error, output) {}
@@ -88,7 +97,8 @@ module.exports = DockerRunner = {
image,
volumes,
timeout,
environment
environment,
compileGroup
)
const fingerprint = DockerRunner._fingerprintContainer(options)
options.name = name = `project-${project_id}-${fingerprint}`
@@ -224,7 +234,14 @@ module.exports = DockerRunner = {
)
},
_getContainerOptions(command, image, volumes, timeout, environment) {
_getContainerOptions(
command,
image,
volumes,
timeout,
environment,
compileGroup
) {
let m, year
let key, value, hostVol, dockerVol
const timeoutInSeconds = timeout / 1000
@@ -311,6 +328,23 @@ module.exports = DockerRunner = {
options.HostConfig.Runtime = Settings.clsi.docker.runtime
}
if (Settings.clsi.docker.Readonly) {
options.HostConfig.ReadonlyRootfs = true
options.HostConfig.Tmpfs = { '/tmp': 'rw,noexec,nosuid,size=65536k' }
}
// Allow per-compile group overriding of individual settings
if (
Settings.clsi.docker.compileGroupConfig &&
Settings.clsi.docker.compileGroupConfig[compileGroup]
) {
const override = Settings.clsi.docker.compileGroupConfig[compileGroup]
let key
for (key in override) {
_.set(options, key, override[key])
}
}
return options
},

View File

@@ -36,7 +36,8 @@ module.exports = LatexRunner = {
timeout,
image,
environment,
flags
flags,
compileGroup
} = options
if (!compiler) {
compiler = 'pdflatex'
@@ -46,7 +47,15 @@ module.exports = LatexRunner = {
} // milliseconds
logger.log(
{ directory, compiler, timeout, mainFile, environment, flags },
{
directory,
compiler,
timeout,
mainFile,
environment,
flags,
compileGroup
},
'starting compile'
)
@@ -79,6 +88,7 @@ module.exports = LatexRunner = {
image,
timeout,
environment,
compileGroup,
function(error, output) {
delete ProcessTable[id]
if (error != null) {

View File

@@ -20,7 +20,16 @@ const logger = require('logger-sharelatex')
logger.info('using standard command runner')
module.exports = CommandRunner = {
run(project_id, command, directory, image, timeout, environment, callback) {
run(
project_id,
command,
directory,
image,
timeout,
environment,
compileGroup,
callback
) {
let key, value
if (callback == null) {
callback = function(error) {}

View File

@@ -74,7 +74,17 @@ module.exports = RequestParser = {
default: [],
type: 'object'
})
if (settings.allowedCompileGroups) {
response.compileGroup = this._parseAttribute(
'compileGroup',
compile.options.compileGroup,
{
validValues: settings.allowedCompileGroups,
default: '',
type: 'string'
}
)
}
// The syncType specifies whether the request contains all
// resources (full) or only those resources to be updated
// in-place (incremental).