{"action":"created","comment":{"url":"https://api.github.com/repos/deis/deis/pulls/comments/34596036","id":34596036,"diff_hunk":"@@ -0,0 +1,111 @@\n+import re\n+import time\n+from django.conf import settings\n+from marathon import MarathonClient\n+from marathon.models import MarathonApp\n+from .states import JobState\n+from docker import Client\n+from .fleet import FleetHTTPClient\n+\n+# turn down standard marathon logging\n+\n+MATCH = re.compile(\n+    '(?P<app>[a-z0-9-]+)_?(?P<version>v[0-9]+)?\\.?(?P<c_type>[a-z-_]+)?.(?P<c_num>[0-9]+)')\n+RETRIES = 3\n+\n+\n+class MarathonHTTPClient(object):\n+\n+    def __init__(self, target, auth, options, pkey):\n+        self.target = settings.MARATHON_HOST\n+        self.auth = auth\n+        self.options = options\n+        self.pkey = pkey\n+        self.registry = settings.REGISTRY_HOST + ':' + settings.REGISTRY_PORT\n+        self.client = MarathonClient('http://'+self.target+':8180')\n+        self.fleet = FleetHTTPClient('/var/run/fleet.sock', auth, options, pkey)\n+\n+    # helpers\n+    def _app_id(self, name):\n+        return name.replace('_', '.')\n+\n+    # container api\n+    def create(self, name, image, command='', **kwargs):\n+        \"\"\"Create a container\"\"\"\n+        app_id = self._app_id(name)\n+        l = locals().copy()\n+        l.update(re.match(MATCH, name).groupdict())\n+        image = self.registry + '/' + image\n+        mems = kwargs.get('memory', {}).get(l['c_type'])\n+        m = 0\n+        if mems:\n+            mems = mems.lower()\n+            if mems[-2:-1].isalpha() and mems[-1].isalpha():\n+                mems = mems[:-1]\n+            m = int(mems[:-1])\n+        c = 0.5\n+        cpu = kwargs.get('cpu', {}).get(l['c_type'])\n+        if cpu:\n+            c = cpu\n+        cpu = kwargs.get('cpu', {}).get(l['c_type'])","path":"controller/scheduler/mesos_marathon.py","position":50,"original_position":50,"commit_id":"bcd7c8958f5338e7fac9edf7f6ce57d562b91fd4","original_commit_id":"bcd7c8958f5338e7fac9edf7f6ce57d562b91fd4","user":{"login":"mboersma","id":73019,"avatar_url":"https://avatars.githubusercontent.com/u/73019?v=3","gravatar_id":"","url":"https://api.github.com/users/mboersma","html_url":"https://github.com/mboersma","followers_url":"https://api.github.com/users/mboersma/followers","following_url":"https://api.github.com/users/mboersma/following{/other_user}","gists_url":"https://api.github.com/users/mboersma/gists{/gist_id}","starred_url":"https://api.github.com/users/mboersma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mboersma/subscriptions","organizations_url":"https://api.github.com/users/mboersma/orgs","repos_url":"https://api.github.com/users/mboersma/repos","events_url":"https://api.github.com/users/mboersma/events{/privacy}","received_events_url":"https://api.github.com/users/mboersma/received_events","type":"User","site_admin":false},"body":"This line is the same as line 47 and appears to be a no-op.","created_at":"2015-07-14T17:39:09Z","updated_at":"2015-07-14T17:39:09Z","html_url":"https://github.com/deis/deis/pull/3857#discussion_r34596036","pull_request_url":"https://api.github.com/repos/deis/deis/pulls/3857","_links":{"self":{"href":"https://api.github.com/repos/deis/deis/pulls/comments/34596036"},"html":{"href":"https://github.com/deis/deis/pull/3857#discussion_r34596036"},"pull_request":{"href":"https://api.github.com/repos/deis/deis/pulls/3857"}}},"pull_request":{"url":"https://api.github.com/repos/deis/deis/pulls/3857","id":37511466,"html_url":"https://github.com/deis/deis/pull/3857","diff_url":"https://github.com/deis/deis/pull/3857.diff","patch_url":"https://github.com/deis/deis/pull/3857.patch","issue_url":"https://api.github.com/repos/deis/deis/issues/3857","number":3857,"state":"open","locked":false,"title":"feat(mesos-marathon): add marathon framework support for deis","user":{"login":"smothiki","id":7416231,"avatar_url":"https://avatars.githubusercontent.com/u/7416231?v=3","gravatar_id":"","url":"https://api.github.com/users/smothiki","html_url":"https://github.com/smothiki","followers_url":"https://api.github.com/users/smothiki/followers","following_url":"https://api.github.com/users/smothiki/following{/other_user}","gists_url":"https://api.github.com/users/smothiki/gists{/gist_id}","starred_url":"https://api.github.com/users/smothiki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smothiki/subscriptions","organizations_url":"https://api.github.com/users/smothiki/orgs","repos_url":"https://api.github.com/users/smothiki/repos","events_url":"https://api.github.com/users/smothiki/events{/privacy}","received_events_url":"https://api.github.com/users/smothiki/received_events","type":"User","site_admin":false},"body":"Marathon framework integration with deis.\r\n1. Install [deis](http://docs.deis.io/en/latest/) platform .\r\n2. Follow the instructions to launch [controller]( http://docs.deis.io/en/latest/contributing/hacking/?highlight=hacking%20deis)\r\n3. Build  deisctl \r\n4. ```deisctl install mesos``` and ```deisctl install marathon```\r\n5. ```deisctl config controller set schedulerModule=mesos_marathon```\r\n\r\n**Note :** \r\n*1. Right now deis is not using Marathon docker containerizers option. Executing a bash command to run docker containers.\r\n2. If you are using Marathon deis limits CPU should be integer value of CPUs rather than CPU-Shares . By default  0.5 CPU is allocated to each APP.\r\n3. Mesos Cluster is not HA*\r\n**Future work:**\r\n1. Move to Marathon docker containerizer and change publisher and logger logic accordingly to identify containers that are launched while creating an APP\r\n2. Keep watching issue https://github.com/deis/deis/issues/3850 for design changes in deis to integrate schedulers.\r\n3. Setup HA Mesos cluster using deisctl \r\n\r\nRefer: https://github.com/deis/deis/issues/3809\r\nRequires #3692  ","created_at":"2015-06-11T21:36:46Z","updated_at":"2015-07-14T17:39:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b56b4d8842b316c2b5f92e0505ec07b9d0501d37","assignee":{"login":"smothiki","id":7416231,"avatar_url":"https://avatars.githubusercontent.com/u/7416231?v=3","gravatar_id":"","url":"https://api.github.com/users/smothiki","html_url":"https://github.com/smothiki","followers_url":"https://api.github.com/users/smothiki/followers","following_url":"https://api.github.com/users/smothiki/following{/other_user}","gists_url":"https://api.github.com/users/smothiki/gists{/gist_id}","starred_url":"https://api.github.com/users/smothiki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smothiki/subscriptions","organizations_url":"https://api.github.com/users/smothiki/orgs","repos_url":"https://api.github.com/users/smothiki/repos","events_url":"https://api.github.com/users/smothiki/events{/privacy}","received_events_url":"https://api.github.com/users/smothiki/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/deis/deis/milestones/42","html_url":"https://github.com/deis/deis/milestones/v1.9","labels_url":"https://api.github.com/repos/deis/deis/milestones/42/labels","id":1140369,"number":42,"title":"v1.9","description":"","creator":{"login":"mboersma","id":73019,"avatar_url":"https://avatars.githubusercontent.com/u/73019?v=3","gravatar_id":"","url":"https://api.github.com/users/mboersma","html_url":"https://github.com/mboersma","followers_url":"https://api.github.com/users/mboersma/followers","following_url":"https://api.github.com/users/mboersma/following{/other_user}","gists_url":"https://api.github.com/users/mboersma/gists{/gist_id}","starred_url":"https://api.github.com/users/mboersma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mboersma/subscriptions","organizations_url":"https://api.github.com/users/mboersma/orgs","repos_url":"https://api.github.com/users/mboersma/repos","events_url":"https://api.github.com/users/mboersma/events{/privacy}","received_events_url":"https://api.github.com/users/mboersma/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":4,"state":"open","created_at":"2015-05-29T16:50:34Z","updated_at":"2015-07-14T16:54:39Z","due_on":"2015-08-04T06:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/deis/deis/pulls/3857/commits","review_comments_url":"https://api.github.com/repos/deis/deis/pulls/3857/comments","review_comment_url":"https://api.github.com/repos/deis/deis/pulls/comments{/number}","comments_url":"https://api.github.com/repos/deis/deis/issues/3857/comments","statuses_url":"https://api.github.com/repos/deis/deis/statuses/bcd7c8958f5338e7fac9edf7f6ce57d562b91fd4","head":{"label":"smothiki:marathon","ref":"marathon","sha":"bcd7c8958f5338e7fac9edf7f6ce57d562b91fd4","user":{"login":"smothiki","id":7416231,"avatar_url":"https://avatars.githubusercontent.com/u/7416231?v=3","gravatar_id":"","url":"https://api.github.com/users/smothiki","html_url":"https://github.com/smothiki","followers_url":"https://api.github.com/users/smothiki/followers","following_url":"https://api.github.com/users/smothiki/following{/other_user}","gists_url":"https://api.github.com/users/smothiki/gists{/gist_id}","starred_url":"https://api.github.com/users/smothiki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smothiki/subscriptions","organizations_url":"https://api.github.com/users/smothiki/orgs","repos_url":"https://api.github.com/users/smothiki/repos","events_url":"https://api.github.com/users/smothiki/events{/privacy}","received_events_url":"https://api.github.com/users/smothiki/received_events","type":"User","site_admin":false},"repo":{"id":20275511,"name":"deis","full_name":"smothiki/deis","owner":{"login":"smothiki","id":7416231,"avatar_url":"https://avatars.githubusercontent.com/u/7416231?v=3","gravatar_id":"","url":"https://api.github.com/users/smothiki","html_url":"https://github.com/smothiki","followers_url":"https://api.github.com/users/smothiki/followers","following_url":"https://api.github.com/users/smothiki/following{/other_user}","gists_url":"https://api.github.com/users/smothiki/gists{/gist_id}","starred_url":"https://api.github.com/users/smothiki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smothiki/subscriptions","organizations_url":"https://api.github.com/users/smothiki/orgs","repos_url":"https://api.github.com/users/smothiki/repos","events_url":"https://api.github.com/users/smothiki/events{/privacy}","received_events_url":"https://api.github.com/users/smothiki/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smothiki/deis","description":"Your PaaS. Your Rules. ","fork":true,"url":"https://api.github.com/repos/smothiki/deis","forks_url":"https://api.github.com/repos/smothiki/deis/forks","keys_url":"https://api.github.com/repos/smothiki/deis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smothiki/deis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smothiki/deis/teams","hooks_url":"https://api.github.com/repos/smothiki/deis/hooks","issue_events_url":"https://api.github.com/repos/smothiki/deis/issues/events{/number}","events_url":"https://api.github.com/repos/smothiki/deis/events","assignees_url":"https://api.github.com/repos/smothiki/deis/assignees{/user}","branches_url":"https://api.github.com/repos/smothiki/deis/branches{/branch}","tags_url":"https://api.github.com/repos/smothiki/deis/tags","blobs_url":"https://api.github.com/repos/smothiki/deis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smothiki/deis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smothiki/deis/git/refs{/sha}","trees_url":"https://api.github.com/repos/smothiki/deis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smothiki/deis/statuses/{sha}","languages_url":"https://api.github.com/repos/smothiki/deis/languages","stargazers_url":"https://api.github.com/repos/smothiki/deis/stargazers","contributors_url":"https://api.github.com/repos/smothiki/deis/contributors","subscribers_url":"https://api.github.com/repos/smothiki/deis/subscribers","subscription_url":"https://api.github.com/repos/smothiki/deis/subscription","commits_url":"https://api.github.com/repos/smothiki/deis/commits{/sha}","git_commits_url":"https://api.github.com/repos/smothiki/deis/git/commits{/sha}","comments_url":"https://api.github.com/repos/smothiki/deis/comments{/number}","issue_comment_url":"https://api.github.com/repos/smothiki/deis/issues/comments{/number}","contents_url":"https://api.github.com/repos/smothiki/deis/contents/{+path}","compare_url":"https://api.github.com/repos/smothiki/deis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smothiki/deis/merges","archive_url":"https://api.github.com/repos/smothiki/deis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smothiki/deis/downloads","issues_url":"https://api.github.com/repos/smothiki/deis/issues{/number}","pulls_url":"https://api.github.com/repos/smothiki/deis/pulls{/number}","milestones_url":"https://api.github.com/repos/smothiki/deis/milestones{/number}","notifications_url":"https://api.github.com/repos/smothiki/deis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smothiki/deis/labels{/name}","releases_url":"https://api.github.com/repos/smothiki/deis/releases{/id}","created_at":"2014-05-28T23:17:04Z","updated_at":"2015-05-05T19:06:57Z","pushed_at":"2015-07-14T17:02:37Z","git_url":"git://github.com/smothiki/deis.git","ssh_url":"git@github.com:smothiki/deis.git","clone_url":"https://github.com/smothiki/deis.git","svn_url":"https://github.com/smothiki/deis","homepage":"http://deis.io","size":17731,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"deis:master","ref":"master","sha":"74e92d38c94a3026d38caf4f3b47e4190704eafa","user":{"login":"deis","id":6117407,"avatar_url":"https://avatars.githubusercontent.com/u/6117407?v=3","gravatar_id":"","url":"https://api.github.com/users/deis","html_url":"https://github.com/deis","followers_url":"https://api.github.com/users/deis/followers","following_url":"https://api.github.com/users/deis/following{/other_user}","gists_url":"https://api.github.com/users/deis/gists{/gist_id}","starred_url":"https://api.github.com/users/deis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deis/subscriptions","organizations_url":"https://api.github.com/users/deis/orgs","repos_url":"https://api.github.com/users/deis/repos","events_url":"https://api.github.com/users/deis/events{/privacy}","received_events_url":"https://api.github.com/users/deis/received_events","type":"Organization","site_admin":false},"repo":{"id":11589713,"name":"deis","full_name":"deis/deis","owner":{"login":"deis","id":6117407,"avatar_url":"https://avatars.githubusercontent.com/u/6117407?v=3","gravatar_id":"","url":"https://api.github.com/users/deis","html_url":"https://github.com/deis","followers_url":"https://api.github.com/users/deis/followers","following_url":"https://api.github.com/users/deis/following{/other_user}","gists_url":"https://api.github.com/users/deis/gists{/gist_id}","starred_url":"https://api.github.com/users/deis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deis/subscriptions","organizations_url":"https://api.github.com/users/deis/orgs","repos_url":"https://api.github.com/users/deis/repos","events_url":"https://api.github.com/users/deis/events{/privacy}","received_events_url":"https://api.github.com/users/deis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/deis/deis","description":"Your PaaS. Your Rules. ","fork":false,"url":"https://api.github.com/repos/deis/deis","forks_url":"https://api.github.com/repos/deis/deis/forks","keys_url":"https://api.github.com/repos/deis/deis/keys{/key_id}","collaborators_url":"https://api.github.com/repos/deis/deis/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/deis/deis/teams","hooks_url":"https://api.github.com/repos/deis/deis/hooks","issue_events_url":"https://api.github.com/repos/deis/deis/issues/events{/number}","events_url":"https://api.github.com/repos/deis/deis/events","assignees_url":"https://api.github.com/repos/deis/deis/assignees{/user}","branches_url":"https://api.github.com/repos/deis/deis/branches{/branch}","tags_url":"https://api.github.com/repos/deis/deis/tags","blobs_url":"https://api.github.com/repos/deis/deis/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/deis/deis/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/deis/deis/git/refs{/sha}","trees_url":"https://api.github.com/repos/deis/deis/git/trees{/sha}","statuses_url":"https://api.github.com/repos/deis/deis/statuses/{sha}","languages_url":"https://api.github.com/repos/deis/deis/languages","stargazers_url":"https://api.github.com/repos/deis/deis/stargazers","contributors_url":"https://api.github.com/repos/deis/deis/contributors","subscribers_url":"https://api.github.com/repos/deis/deis/subscribers","subscription_url":"https://api.github.com/repos/deis/deis/subscription","commits_url":"https://api.github.com/repos/deis/deis/commits{/sha}","git_commits_url":"https://api.github.com/repos/deis/deis/git/commits{/sha}","comments_url":"https://api.github.com/repos/deis/deis/comments{/number}","issue_comment_url":"https://api.github.com/repos/deis/deis/issues/comments{/number}","contents_url":"https://api.github.com/repos/deis/deis/contents/{+path}","compare_url":"https://api.github.com/repos/deis/deis/compare/{base}...{head}","merges_url":"https://api.github.com/repos/deis/deis/merges","archive_url":"https://api.github.com/repos/deis/deis/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/deis/deis/downloads","issues_url":"https://api.github.com/repos/deis/deis/issues{/number}","pulls_url":"https://api.github.com/repos/deis/deis/pulls{/number}","milestones_url":"https://api.github.com/repos/deis/deis/milestones{/number}","notifications_url":"https://api.github.com/repos/deis/deis/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/deis/deis/labels{/name}","releases_url":"https://api.github.com/repos/deis/deis/releases{/id}","created_at":"2013-07-22T19:02:40Z","updated_at":"2015-07-14T14:06:02Z","pushed_at":"2015-07-14T17:38:39Z","git_url":"git://github.com/deis/deis.git","ssh_url":"git@github.com:deis/deis.git","clone_url":"https://github.com/deis/deis.git","svn_url":"https://github.com/deis/deis","homepage":"http://deis.io","size":40465,"stargazers_count":4485,"watchers_count":4485,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":699,"mirror_url":null,"open_issues_count":219,"forks":699,"open_issues":219,"watchers":4485,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/deis/deis/pulls/3857"},"html":{"href":"https://github.com/deis/deis/pull/3857"},"issue":{"href":"https://api.github.com/repos/deis/deis/issues/3857"},"comments":{"href":"https://api.github.com/repos/deis/deis/issues/3857/comments"},"review_comments":{"href":"https://api.github.com/repos/deis/deis/pulls/3857/comments"},"review_comment":{"href":"https://api.github.com/repos/deis/deis/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/deis/deis/pulls/3857/commits"},"statuses":{"href":"https://api.github.com/repos/deis/deis/statuses/bcd7c8958f5338e7fac9edf7f6ce57d562b91fd4"}}}}