This is a basic HyperFlow job executor that uses local directory path to read and write files, and Redis (or RabbitMQ/Redis) for communication with the HyperFlow engine.
- Install Node.js 12.x or higher
- Install the executor package:
- Latest version:
npm install -g @hyperflow/job-executor - Specific version:
npm install -g @hyperflow/job-executor@X.Y.Z - From master branch:
npm install -g https://github.com/hyperflow-wms/hyperflow-job-executor/archive/master.tar.gz
- Latest version:
Jobs can be run with either of the following commands:
hflow-job-execute <taskId> <redisUrl>, wheretaskIdis a unique job identifier, whileredisUrlis an URL to the Redis server where the actual job command is fetched from. Both parameters are available in HyperFlow functions ascontext.taskIdandcontext.redis_url, respectively.hflow-job-execute <redisUrl> -a -- <taskId>...-- to run multiple jobs sequentially (useful for agglomeration of small jobs).
Jobs can be submitted e.g. using the HyperFlow function k8sCommand. See RemoteJobs example to learn more details.
The executor reports each job's exit code to the engine, which treats a non-zero code as a failed task. A job killed by a signal gets exit code 128 plus the signal number, as in a shell. A job whose program cannot be started, for example because it is not found or is not executable, gets exit code 127. A job with a non-zero exit code is run again only if HF_VAR_NUMBER_OF_RETRIES, which counts attempts, is above its default of 1.
The AMQP listener can be run with the following command:
hflow-job-listener.js
Note that in order to run an executor following variables must be set with proper values:
RABBIT_HOSTNAMEQUEUE_NAME
More details about those configuration variables are in Configuration chapter.
Use environmental variables to adjust the configuration of services.
HF_VAR_OPT_URL(eg.collector-gateway): provide name under which collector should be accessible (process should be able to call http://{HF_VAR_OPT_URL}:4318/v1/traces')HF_VAR_ENABLE_TRACING(0or1): emit traces, spans, and metrics
The executor creates log files in directory <work_dir>/logs-hf that contain:
- command used to execute the job
stdoutandstderrof the job- metrics (CPU/memory/IO/network usage)
- events (job start/end)
- system information (e.g. hardware configuration)
- all environment variables starting with
HF_LOG_-- a JSON object is logged following conventions from the read-env package
The following environment variables can be used to adjust the behavior of the job executor:
HF_VAR_PROBE_INTERVAL(default2000): time interval (in ms) at which to probe and log metrics.HF_VAR_NUMBER_OF_RETRIES(default1): how many attempts a job gets. A job that returns a non-zero exit code is run again until it succeeds or has had this many attempts, so the default1means no retry.HF_VAR_BACKOFF_SEED(default10): factor used in calculating the backoff delay between retries.HF_VAR_WAIT_FOR_INPUT_FILES: if set to1, the executor will check if input files exist and wait for them (useful in systems where files are synchronized in an eventually consistent fashion).HF_VAR_FILE_WATCH_NUM_RETRIES(default10): how many times should the executor check for existence of the input files (with backoff waits in between).HF_VAR_WORK_DIR: path to the working directory where the job should be executed. If not set,/work_dirwill be used if exists, otherwise the executor will not change the working directory.HF_VAR_LOG_DIR: path to the directory where log files should be written. If not set,<work dir>/logs-hfwill be used.HF_VAR_LOG_LEVEL(defaultinfo): set logging level (trace,debug,info,warn,error,fatal).HF_VAR_ENABLE_NETHOGS: if set (to any value), logs from nethogs will be written (experimental).HF_VAR_DRY_RUN: (for testing/debugging) if set to1, the executor will immediately return with job exit status0(success).HF_LOG_*: all variables starting withHF_LOG_will be logged in the job log filesRABBIT_HOSTNAME: RabbitMQ instance hostname. Can be supplied with basic auth credentials, for example:username:password@rabbitmq.default. When no username nor password are specified, default RabbitMQ guest:guest credentials are used. Required in AMQP executor modeQUEUE_NAMEthe name of the queue at which executor will wait for task messages. Required in AMQP executor mode
A release is one command on master. CI checks the tag, writes its version
into package.json (which holds 0.0.0-dev otherwise) and publishes to npm:
gh release create v<X.Y.Z> --target master --generate-notesA prerelease needs a - suffix and --prerelease, for example
gh release create v1.4.3-rc.1 --target master --prerelease --generate-notes.
It publishes under the next dist-tag and does not reach the worker images.
A manual run of the CI workflow only runs npm publish --dry-run.
A stable X.Y.Z publishes under latest. Renovate in 1000genome-workflow,
soykb-workflow and montage2-workflow then opens pull requests that bump
HF_JOB_EXECUTOR_VERSION in their worker Makefiles; merging one builds a worker
image tagged <version>-jeX.Y.Z (for example 6.0-je1.4.2), and Renovate in
hyperflow-k8s-deployment picks up new Montage worker images. The chain relies
on stable versions under latest and on an unchanged package name and bin
entries, so test a change to the release workflow with a prerelease first.
If a release fails to publish, re-run its run (gh run rerun <run-id>, possible
for 30 days). A re-run replays the original release, so a release with the
wrong prerelease flag is deleted and created again on its tag:
gh release delete vX.Y.Z --yes, then
gh release create vX.Y.Z --verify-tag --generate-notes, with --prerelease
if needed. For a wrong tag, add --cleanup-tag to the delete and create the
right release. A stable release lower than the newest stable version on npm
fails at npm publish.
Publishing depends on the trusted-publisher entry in the package's settings on
npmjs.com, which names this repository and ci.yml; do not rename the file.