{"action":"created","issue":{"url":"https://api.github.com/repos/mesosphere/marathon/issues/1242","labels_url":"https://api.github.com/repos/mesosphere/marathon/issues/1242/labels{/name}","comments_url":"https://api.github.com/repos/mesosphere/marathon/issues/1242/comments","events_url":"https://api.github.com/repos/mesosphere/marathon/issues/1242/events","html_url":"https://github.com/mesosphere/marathon/issues/1242","id":58939952,"number":1242,"title":"Allow instance number to be passed in as an environment variable","user":{"login":"SEJeff","id":4603,"avatar_url":"https://avatars.githubusercontent.com/u/4603?v=3","gravatar_id":"","url":"https://api.github.com/users/SEJeff","html_url":"https://github.com/SEJeff","followers_url":"https://api.github.com/users/SEJeff/followers","following_url":"https://api.github.com/users/SEJeff/following{/other_user}","gists_url":"https://api.github.com/users/SEJeff/gists{/gist_id}","starred_url":"https://api.github.com/users/SEJeff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SEJeff/subscriptions","organizations_url":"https://api.github.com/users/SEJeff/orgs","repos_url":"https://api.github.com/users/SEJeff/repos","events_url":"https://api.github.com/users/SEJeff/events{/privacy}","received_events_url":"https://api.github.com/users/SEJeff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-02-25T17:34:37Z","updated_at":"2015-08-09T19:50:55Z","closed_at":null,"body":"Say I have a docker container ie: `kafka:0.8.2.0` and want to run it under mesos. In marathon terminology, for each app, I want 10 instances. I need an integer that is unique amongst all instances in that app, but only for that app.\r\n\r\nCurrently I've got a start script in python which does terrible black magic along the lines of:\r\n\r\n```python\r\nsha = hashlib.sha1(os.environ.get('HOSTNAME'), str(random.randint(1, 100000)))\r\ndefault_broker_id = 10000 * int(sha.hexdigest()[:5], 16) / int('10000', 16)\r\n```\r\n\r\nThis gives me a unique integer I can pass in as a kafka broker. However, I'm having marathon start up 10 instances of said brokers. It would be super nice if the instance number was passed from marathon to the container. Then that above code could be more like:\r\n\r\n```python\r\ndefault_broker_id = os.environ.get('INSTANCE_NUMBER')\r\n```\r\n\r\nThat way I get a per-app unique integer for each instance of said app. It seems like this wouldn't be super difficult to expose.\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/mesosphere/marathon/issues/comments/129231950","html_url":"https://github.com/mesosphere/marathon/issues/1242#issuecomment-129231950","issue_url":"https://api.github.com/repos/mesosphere/marathon/issues/1242","id":129231950,"user":{"login":"air","id":18724,"avatar_url":"https://avatars.githubusercontent.com/u/18724?v=3","gravatar_id":"","url":"https://api.github.com/users/air","html_url":"https://github.com/air","followers_url":"https://api.github.com/users/air/followers","following_url":"https://api.github.com/users/air/following{/other_user}","gists_url":"https://api.github.com/users/air/gists{/gist_id}","starred_url":"https://api.github.com/users/air/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/air/subscriptions","organizations_url":"https://api.github.com/users/air/orgs","repos_url":"https://api.github.com/users/air/repos","events_url":"https://api.github.com/users/air/events{/privacy}","received_events_url":"https://api.github.com/users/air/received_events","type":"User","site_admin":false},"created_at":"2015-08-09T19:50:55Z","updated_at":"2015-08-09T19:50:55Z","body":"Another use case where having a strong 'I am instance N of M' identity is useful: Cassandra nodes. e.g. instances 1 and 2 know that they are the leaders (their instance numbers are lowest) and configure themselves as seeds.\r\n\r\nI'm not convinced Marathon is the right level to provide this level of guaranteed identity. It seems like something a minority of apps would benefit from - the implementation weight would be wasted on other apps that scale horizontally with true independence.\r\n\r\n Marathon's current guarantee is, 'I'll run N of these for you and uniquely identify them' - but they are cattle, and the sense of 'being instance 5' is not carried over if #5 dies and is replaced. That feels like more of a pet.\r\n\r\nTechnically do we see difficulties? I wonder if - in the event of network partitions, restarts - we might run into issues where e.g. there are two 'instance 5s'."}}