Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Add support for run constraints #45

Closed
alexanderdean opened this issue Apr 22, 2016 · 2 comments
Closed

Add support for run constraints #45

alexanderdean opened this issue Apr 22, 2016 · 2 comments
Assignees
Milestone

Comments

@alexanderdean
Copy link
Contributor

alexanderdean commented Apr 22, 2016

This is the idea that Factotum should only execute if a "run constraint" specified on the CLI resolves to true.

This is a powerful feature (taken from Snowplow's internal executor), which lets you have the same Factotum invocation in the cron on multiple boxes, but only one box will execute the job.

Example cronfile:

BOX1=box1.acme.internal
BOX2=box2.acme.internal

/opt/factotum-0.4.0/factotum first-dag.factotum --constraint "host,${BOX1}"
/opt/factotum-0.4.0/factotum secnd-dag.factotum --constraint "host,${BOX2}"

To start with, we only allow one constraint, and the only allowed constraint is host, and the implied check is ==.

@ninjabear
Copy link
Contributor

ninjabear commented Nov 21, 2016

Hey!

This functionality can be reproduced like this:

{
    "schema": "iglu:com.snowplowanalytics.factotum/factfile/jsonschema/1-0-0",
    "data": {
        "name": "constraint demo",
        "tasks": [
            {
                "name": "box check",
                "executor": "shell",
                "command": "if [ \"{{box_name}}\" = \"1\" ]; then exit 1; else exit 0; fi",
                "arguments": [],
                "dependsOn": [],
                "onResult": {
                    "terminateJobWithSuccess": [ 0 ],
                    "continueJob": [ 1 ]
                }
            },
            {
                "name": "execute",
                "executor": "shell",
                "command": "echo",
                "arguments": [ "beta" ],
                "dependsOn": [ "box check" ],
                "onResult": {
                    "terminateJobWithSuccess": [ 3 ],
                    "continueJob": [ 0 ]
                }
            }
        ]
    }
}

and running like this:

factotum run ./noop_constraint.factfile --env '{"box_name": "1"}'

This may not be specific enough for this use-case, but I thought I'd mention it anyway

@alexanderdean
Copy link
Contributor Author

Hey @ninjabear - that's really neat. An emergent property of Factotum!

I think we need to keep this as a feature however, because otherwise we have to mutate all of our factfiles to add this check...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants