Skip to content
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

Proposal: "Context"-aware resources #73

Open
dnephin opened this issue Jan 11, 2017 · 4 comments
Open

Proposal: "Context"-aware resources #73

dnephin opened this issue Jan 11, 2017 · 4 comments

Comments

@dnephin
Copy link
Owner

dnephin commented Jan 11, 2017

There are two conditions which result in sub-optimal behaviour:

  • an env resource can modify the behaviour of a task, which requires all subsequent tasks be marked as "required" (they can't be skipped)
  • compose resources (and the proposed service and job:serve resources) create long running processes, so they must always run. There's no way to skip these tasks without doing some kind of look-ahead, but there isn't current enough information in the config format to determine how far to look ahead. It's not clear which of the following steps use the service.

I think both of these issues could be addressed by adding some form of a "context" (inspired by python context managers).

This config construct would provide a scope for the above resources, making it possible to skip long-running tasks (if all the tasks inside the scope are fresh), and only "require" tasks within the environment scope.

@dnephin
Copy link
Owner Author

dnephin commented Jan 11, 2017

I don't have any good ideas for how to model this in the config just yet.

@cescoferraro
Copy link
Contributor

cescoferraro commented Jan 26, 2017

What if a job could take multiple commands? Analogous to a kubernetes pod, that aggregate multiple containers. The same job could take multiple commands that would share the same environment variables. Plus the image resource would not need to depend on env resources. Then deprecate the env resource and rename job to env

env=dev:
    net-mode: host
    user: "{user.uid}"
    use: dev-image
    mounts: [source]
    commands: 
        - name: webpack
          command: webpack --config build/prod.js
        - name: watch
          interactive: true 
          command: node src/hot.js
          depends: [webpack]
    vars:
      - "NODE_ENV=development"

Then call it like

$ dobi dev:go
$ dobi dev:webpack
$ dobi dev:hot

@dnephin
Copy link
Owner Author

dnephin commented Jan 26, 2017

What if a job could take multiple commands?

A container can only run one process (unless you exec). Would each command be an exec, or would they be different containers? Are they sequential or parallel?

Instead of answering all of those questions, why not just add a bash script to run the commands the way you want to? Or separate jobs of they are meant to be independent.

The same job could take multiple commands that would share the same environment variables.

I think the problem is more with the non-job resources. You may want to share a captured environment variable with an image:build or image:tag. That doesn't work as a multiple-command job.

Then deprecate the env resource and rename job to env

Not sure how this would work. They are very different right now. env populates environment variables, and job runs containers. Merging them seems like it would be overloading the concepts.

@dnephin
Copy link
Owner Author

dnephin commented Feb 2, 2017

I'm thinking something like this:

A new field requires available on most resources that only allows "context-like" tasks (currently job:capture, compose:run, and job:serve). These "context-like" tasks would not be allowed in depends any more.

job=export-db:
  ...
  requires: [empty-db]

When the tasks run, any of these "context-like" tasks are skipped until they are actually required.

The ExecContext will need to track which tasks have been required to it can defer their running.

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

No branches or pull requests

2 participants