-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add autoscaler plugin to Hyperflow docker image, add possibility to specify port and host when runnng as server #63
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ | |
!tests | ||
!utils | ||
!wflib | ||
!hyperflow-autoscaler-plugin |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
FROM node:12-alpine | ||
|
||
#ENV PATH $PATH:/node_modules/.bin | ||
ENV NODE_PATH=/usr/local/lib/node_modules | ||
|
||
COPY . /hyperflow | ||
RUN npm install -g /hyperflow | ||
|
||
RUN mkdir -p /tmp/kubectl && cd /tmp/kubectl && apk add curl && \ | ||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && \ | ||
install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl | ||
|
||
RUN npm install -g @hyperflow/standalone-autoscaler-plugin @hyperflow/autoscaler-plugin /hyperflow |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,9 +72,10 @@ function handle_writes(entries, cb) { | |
** TODO: support external IP address and configurable port number | ||
** | ||
*/ | ||
function hflowStartServer() { | ||
function hflowStartServer(opts) { | ||
var server = require('../server/hyperflow-server.js')(rcl, wflib); | ||
let hostname = '127.0.0.1', port = process.env.PORT; | ||
let hostname = opts['<hyperflow_server_host>'] || '127.0.0.1'; | ||
let port = opts['<hyperflow_server_port>'] || process.env.PORT; | ||
server.listen(port, hostname, () => { | ||
console.log("HyperFlow server started at: http://%s:%d", server.address().address, server.address().port); | ||
}); | ||
|
@@ -101,7 +102,7 @@ function hflowStartServer() { | |
** - wfId: unique workflow identifier | ||
** - wfName: workflow name (from workflow.json) | ||
*/ | ||
function hflowRun(opts, runCb) { | ||
function hflowRun(opts, runCb, runAsServer) { | ||
var dbId = 0, | ||
plugins = [], | ||
recoveryMode = false, | ||
|
@@ -166,6 +167,22 @@ function hflowRun(opts, runCb) { | |
} | ||
}); | ||
|
||
if (wfConfig.containerSpec) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering where these |
||
const spec = wfConfig.containerSpec; | ||
wfConfig.containerSpec = new Map(Array.from(spec).map(entity => { | ||
const jobName = entity.jobName; | ||
const cpu = entity.cpu; | ||
const memory = entity.memory; | ||
const data = { | ||
"cpu": cpu, | ||
"memory": memory | ||
}; | ||
return [jobName, data]; | ||
})); | ||
} else { | ||
wfConfig.containerSpec = new Map(); | ||
} | ||
|
||
var runWf = function(wfId, wfName, wfJson, cb) { | ||
var config = wfConfig; | ||
config["emulate"] = "false"; | ||
|
@@ -184,9 +201,10 @@ function hflowRun(opts, runCb) { | |
// engine.eventServer.on('trace.*', function(exec, args) { | ||
// console.log('Event captured: ' + exec + ' ' + args + ' job done'); | ||
// }); | ||
this.plugins = [...plugins] | ||
|
||
await Promise.all( | ||
plugins.map(function(plugin) { | ||
this.plugins.map(function(plugin) { | ||
let config = {}; | ||
if (plugin.pgType == "scheduler") { | ||
config.wfJson = wfJson; | ||
|
@@ -196,8 +214,10 @@ function hflowRun(opts, runCb) { | |
} | ||
)); | ||
|
||
engine.syncCb = function () { | ||
process.exit(); | ||
if (!runAsServer) { | ||
engine.syncCb = function () { | ||
process.exit(); | ||
} | ||
} | ||
|
||
if (opts['--log-provenance']) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
var fs = require('fs'), | ||
fsm = require('./automata.js'), | ||
async = require('async'), | ||
eventServerFactory = require('../eventlog'); | ||
eventServerFactory = require('../eventlog'), | ||
removeBufferManager = require('../functions/kubernetes/k8sCommand').removeBufferManager; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
|
||
var ProcDataflowFSM = require('./ProcDataflowFSM.js'); | ||
|
@@ -39,6 +40,7 @@ fsm.registerFSM(ProcSplitterFSM); | |
var Engine = function(config, wflib, wfId, cb) { | ||
this.wflib = wflib; | ||
this.config = config; | ||
this.config.wfId = wfId; | ||
this.eventServer = eventServerFactory.createEventServer(); | ||
this.wfId = wfId; | ||
this.tasks = []; // array of task FSMs | ||
|
@@ -51,6 +53,7 @@ var Engine = function(config, wflib, wfId, cb) { | |
this.nTasksLeft = 0; // how many tasks left (not finished)? | ||
this.nWfOutsLeft = 0; // how many workflow outputs are still to be produced? | ||
this.syncCb = null; // callback invoked when wf instance finished execution (passed to runInstanceSync) | ||
this.plugins = []; | ||
|
||
this.logProvenance = false; | ||
|
||
|
@@ -151,6 +154,12 @@ Engine.prototype.taskFinished = function(taskId) { | |
|
||
Engine.prototype.workflowFinished = function() { | ||
console.log("Workflow ["+this.wfId+"] finished. Exec trace:", this.trace+"." ); | ||
removeBufferManager(this.wfId); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This new part should be done outside |
||
this.plugins.forEach((plugin) => { | ||
if (plugin.markWorkflowFinished) { | ||
plugin.markWorkflowFinished(this.wfId); | ||
} | ||
}); | ||
//onsole.log(this.syncCb); | ||
if (this.syncCb) { | ||
this.syncCb(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,10 @@ var RestartCounter = require('./restart_counter.js').RestartCounter; | |
var submitK8sJob = require('./k8sJobSubmit.js').submitK8sJob; | ||
var fs = require('fs'); | ||
|
||
let bufferManager = new BufferManager(); | ||
let bufferManagers = {}; | ||
let restartCounters = {} | ||
|
||
let backoffLimit = process.env.HF_VAR_BACKOFF_LIMIT || 0; | ||
let restartCounter = new RestartCounter(backoffLimit); | ||
|
||
// Function k8sCommandGroup | ||
// | ||
|
@@ -19,14 +19,16 @@ let restartCounter = new RestartCounter(backoffLimit); | |
// * outs | ||
// * context | ||
// * cb | ||
async function k8sCommandGroup(bufferItems) { | ||
async function k8sCommandGroup(wfId, bufferItems) { | ||
|
||
// No action needed when buffer is empty | ||
if (bufferItems.length == 0) { | ||
return; | ||
} | ||
|
||
let startTime = Date.now(); | ||
let startTime = Date.now() | ||
const bufferManager = bufferManagers[wfId]; | ||
const restartCounter = restartCounters[wfId]; | ||
console.log("k8sCommandGroup started, time:", startTime); | ||
|
||
// Function for rebuffering items | ||
|
@@ -165,10 +167,27 @@ async function k8sCommandGroup(bufferItems) { | |
return; | ||
} | ||
|
||
bufferManager.setCallback((items) => k8sCommandGroup(items)); | ||
function removeBufferManager(wfId) { | ||
if (bufferManagers[wfId] !== undefined) { | ||
delete bufferManagers[wfId]; | ||
} | ||
if (restartCounters[wfId] !== undefined) { | ||
delete restartCounters[wfId]; | ||
} | ||
} | ||
|
||
async function k8sCommand(ins, outs, context, cb) { | ||
/** Buffer Manager configuration. */ | ||
const wfId = context.appConfig.wfId; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
let bufferManager = bufferManagers[wfId]; | ||
if (bufferManager === undefined) { | ||
bufferManager = new BufferManager(); | ||
bufferManager.setCallback((items) => k8sCommandGroup(wfId, items)); | ||
bufferManagers[wfId] = bufferManager; | ||
} | ||
if (restartCounters[wfId] === undefined) { | ||
restartCounters[wfId] = new RestartCounter(backoffLimit); | ||
} | ||
buffersConf = context.appConfig.jobAgglomerations; | ||
let alreadyConfigured = bufferManager.isConfigured(); | ||
if (alreadyConfigured == false && buffersConf != undefined) { | ||
|
@@ -191,4 +210,5 @@ async function k8sCommand(ins, outs, context, cb) { | |
return; | ||
} | ||
|
||
exports.removeBufferManager = removeBufferManager; | ||
exports.k8sCommand = k8sCommand; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this?