Giter Site home page Giter Site logo

Comments (17)

jschneiderhan avatar jschneiderhan commented on July 21, 2024

What are the main motivations for adding '/bin/sh -c' to the front of commands? I want to make sure I keep them in mind as I brainstorm ideas to propose.

from deimos.

solidsnack avatar solidsnack commented on July 21, 2024

This has to do with the semantics of Mesos's CommandInfo -- the command.value field is meant to be interpreted by the shell and is a single string.

Maybe it would work if the options field were processed in a special way: if // is present, we take all following arguments and move them to the end of the run command. They would be treated as strings not subject to shell interpretation in any way (so $TZ would be treated as the literal string, not expanded to the host's timezone).

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

@solidsnack oh wow - the functionality has been added already! Thank you very much! I'll give the updated code a shot today. This solution will definitely fulfill my use-case.

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

Sorry, just realized the branch hasn't been merged yet.

from deimos.

solidsnack avatar solidsnack commented on July 21, 2024

Please do ping us back and let us know how it goes.

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

@solidsnack it worked great!

I was getting the following error:

Jul  8 13:50:52 vagrant deimos[22122]: deimos.cli() Unhandled failure in launch#012Traceback (most recent call last):#012  File "/home/vagrant/deimos/deimos/__init__.py", line 72, in cli#012    result = deimos.containerizer.stdio(containerizer, *argv[1:])#012  File "/home/vagrant/deimos/deimos/containerizer/__init__.py", line 97, in stdio#012    return method(recordio.read(proto), *args[1:])#012  File "/home/vagrant/deimos/deimos/containerizer/docker.py", line 73, in launch#012    options, trailing_argv = split_on(options, "//")#012  File "/home/vagrant/deimos/deimos/containerizer/docker.py", line 337, in split_on#012    preceding = list(takewhile(lambda _: _ != element, iterable))#012NameError: global name 'takewhile' is not defined

To fix it, I added the following line to the top of deimos/containerizer/docker.py:

from itertools import takewhile, dropwhile

I'm not sure if that is a valid addition to the code base or an environment problem on my end (I know next to nothing about python).

from deimos.

solidsnack avatar solidsnack commented on July 21, 2024

Oops. You did the right thing. Not sure how it got committed this way.

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

Ok good. This solution definitely works for my use case. Thanks for adding the functionality!

from deimos.

solidsnack avatar solidsnack commented on July 21, 2024

If you make a pull request against https://github.com/mesosphere/deimos/tree/argv-in-options containing the itertools change I would be happy to merge it in and credit you.

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

@solidsnack Thanks! PR submitted #33

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

Awesome! I think this is all set, right? I'm assuming I should close the issue since the use case has been satisfied. Thanks for everything @solidsnack!

For anyone who stumbles upon this with a similar need, my REST call to marathon looks like the following and it works like a charm:

{
  "container": {
    "image": "docker:///flynn/slugrunner",
    "options": ["//", "start", "web"]
  },
  "id": "ubuntu",
  "instances": "1",
  "cpus": ".5",
  "mem": "512",
  "cmd": "",
  "env": {
    "SLUG_URL": "https://example.com/myappslug.tgz",
    "PORT": "8080",
    "APPVAR1": "value1",
    "APPVAR2": "value2",
    "APPVAR3": "value3"
  }
}

from deimos.

jplock avatar jplock commented on July 21, 2024

Can we add this to the formal documentation as well? This is very useful and I'd hate to see this get lost in an issue.

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

@jplock I added a few lines as a starting point #35

from deimos.

solidsnack avatar solidsnack commented on July 21, 2024

@jschneiderhan With a small change I can merge that. Please see line notes.

from deimos.

jschneiderhan avatar jschneiderhan commented on July 21, 2024

Cool. I'll let you guys determine if the documentation requirement is fulfilled and close the issue.

Thanks again!

from deimos.

solidsnack avatar solidsnack commented on July 21, 2024

Thanks for your patch.

from deimos.

dangra avatar dangra commented on July 21, 2024

hey guys, just come up with a complete different solution to the same issue a day ago. I didn't know you were after the same problem, sorry for not sharing early, I want to share my solution in case someone else find it useful: scrapinghub@63329ac

The main advantage is that it can be used from frameworks that doesn't support the "container" field yet, like Chronos. The only drawback is adding "json" to the equation, but that is fine in my case.

thanks. great work!

from deimos.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.