internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: deis/deis

Issue:
Unit file - Refactoring X- Prefix in X-Fleet segment
fleet 8.0 Deprecated X- prefix

for the following matching conditions

X-ConditionMachineID    Deprecated in v0.8.0 in favor of MachineID
X-ConditionMachineOf    Deprecated in v0.8.0 in favor of MachineOf
X-ConditionMachineMetadata  Deprecated in v0.8.0 in favor of MachineMetadata
X-Conflicts     Deprecated in v0.8.0 in favor of Conflicts

pushing forward to 435 its probably something to consider



Discussion:
Yep! We should do this as well in deisctl: https://github.com/deis/deisctl/pull/40


Resolving patch:
diff --git a/controller/scheduler/coreos.py b/controller/scheduler/coreos.py
--- a/controller/scheduler/coreos.py
+++ b/controller/scheduler/coreos.py
@@ -135,7 +135,7 @@ def _create_container(self, name, image, command, unit, **kwargs):
         tags = kwargs.get('tags', {})
         if tags:
             tagset = ' '.join(['"{}={}"'.format(k, v) for k, v in tags.items()])
-            unit.append({"section": "X-Fleet", "name": "X-ConditionMachineMetadata",
+            unit.append({"section": "X-Fleet", "name": "MachineMetadata",
                          "value": tagset})
         # post unit to fleet
         self._put_unit(name, {"desiredState": "launched", "options": unit})
@@ -325,7 +325,7 @@ def attach(self, name):
     {"section": "Service", "name": "ExecStartPre", "value": '''/bin/sh -c "until docker inspect {name} >/dev/null 2>&1; do sleep 1; done"'''},  # noqa
     {"section": "Service", "name": "ExecStart", "value": '''/bin/sh -c "docker logs -f {name} 2>&1 | logger -p local0.info -t {app}[{c_type}.{c_num}] --udp --server $(etcdctl get /deis/logs/host) --port $(etcdctl get /deis/logs/port)"'''},  # noqa
     {"section": "Service", "name": "TimeoutStartSec", "value": "20m"},
-    {"section": "X-Fleet", "name": "X-ConditionMachineOf", "value": "{name}.service"},
+    {"section": "X-Fleet", "name": "MachineOf", "value": "{name}.service"},
 ]
 
 
@@ -337,7 +337,7 @@ def attach(self, name):
     {"section": "Service", "name": "ExecStart", "value": '''/bin/sh -c "port=$(docker inspect -f '{{{{range $i, $e := .NetworkSettings.Ports }}}}{{{{$p := index $e 0}}}}{{{{$p.HostPort}}}}{{{{end}}}}' {name}); echo Connected to $COREOS_PRIVATE_IPV4:$port/tcp, publishing to etcd...; while netstat -lnt | grep :$port >/dev/null; do etcdctl set /deis/services/{app}/{name} $COREOS_PRIVATE_IPV4:$port --ttl 60 >/dev/null; sleep 45; done"'''},  # noqa
     {"section": "Service", "name": "ExecStop", "value": "/usr/bin/etcdctl rm --recursive /deis/services/{app}/{name}"},  # noqa
     {"section": "Service", "name": "TimeoutStartSec", "value": "20m"},
-    {"section": "X-Fleet", "name": "X-ConditionMachineOf", "value": "{name}.service"},
+    {"section": "X-Fleet", "name": "MachineOf", "value": "{name}.service"},
 ]
 
 


Test patch:
Repository: deis/deis

Issue:
deis destroy doesn't remove domains
not sure if this is intended or not. at the moment running a `deis destroy -a $NAME` does not remove any attached domains.

if you then try to use a previously attached domain, you cannot as it is still registered. At this point if you dont know what $NAME was, then the cli does not have a way to remove the domain name.

Could a domain check be added to the destroy stage?



Discussion:
Looks like we manually destroy the containers associated with the app. I'm surprised that Django doesn't handle this already. https://github.com/deis/deis/blob/fd6bd50657ef119316064932127f8cfbf2af147b/controller/api/models.py#L174-L175

hmm, maybe its leaving them as an orphaned foreign key, so clears the join but doesnt remove the data?


Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -790,8 +790,11 @@ def _etcd_publish_domains(**kwargs):
     if app_domains:
         _etcd_client.write('/deis/domains/{}'.format(app),
                            ' '.join(str(d.domain) for d in app_domains))
-    else:
-        _etcd_client.delete('/deis/domains/{}'.format(app))
+
+
+def _etcd_purge_domains(**kwargs):
+    app = kwargs['instance'].app
+    _etcd_client.delete('/deis/domains/{}'.format(app))
 
 
 # Log significant app-related events
@@ -825,6 +828,6 @@ def _save_transition(**kwargs):
     post_delete.connect(_etcd_purge_key, sender=Key, dispatch_uid='api.models')
     post_delete.connect(_etcd_purge_user, sender=User, dispatch_uid='api.models')
     post_save.connect(_etcd_publish_domains, sender=Domain, dispatch_uid='api.models')
-    post_delete.connect(_etcd_publish_domains, sender=Domain, dispatch_uid='api.models')
+    post_delete.connect(_etcd_purge_domains, sender=Domain, dispatch_uid='api.models')
     post_save.connect(_etcd_create_app, sender=App, dispatch_uid='api.models')
     post_delete.connect(_etcd_purge_app, sender=App, dispatch_uid='api.models')


Test patch:
Repository: deis/deis

Issue:
chore(*): bump CoreOS to 459.0.0
Only the rackspace image is missing (I don't know if this could be merged without that)

Change to controller scheduler for fleet v0.8.3
Since v0.8.2 fleet return the proper http status code.
In the line https://github.com/deis/deis/blob/master/controller/scheduler/coreos.py#L58 must change 204 to 201.

(founded using the logspout PR in v257.0.0 with fleet v0.8.3)



Discussion:

Without this change any attempt to create an app will return 
`(create): Failed to create unit: 201 Created -` in the controller and the client  `503 SERVICE UNAVAILABLE` but the app is running.

Thank you for the heads up, @aledbf. We'll patch it up when we update to a version of CoreOS with fleet v0.8.3+ :)


Resolving patch:
diff --git a/controller/scheduler/coreos.py b/controller/scheduler/coreos.py
--- a/controller/scheduler/coreos.py
+++ b/controller/scheduler/coreos.py
@@ -54,7 +54,7 @@ def _put_unit(self, name, body):
                           headers=headers, body=json.dumps(body))
         resp = self.conn.getresponse()
         data = resp.read()
-        if resp.status != 204:
+        if not 200 <= resp.status <= 299:
             errmsg = "Failed to create unit: {} {} - {}".format(
                 resp.status, resp.reason, data)
             raise RuntimeError(errmsg)


Test patch:
Repository: deis/deis

Issue:
`deis run` should print out a "loading..." response
Pulling docker containers for applications can take a long time. We should add a responsive client feedback to `deis run` to show that we are pulling the container down instead of displaying a blank screen.

current iteration (took around 4 minutes to start):

```
><> deis run env
HOSTNAME=c58c2c309938
DEIS_APP=go
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/bin
PWD=/app
HOME=/app
SHLVL=1
PORT=5000
DEIS_RELEASE=v2
_=/usr/bin/env
```

should be:

```
><> deis run env
Please wait, this may take a while...
HOSTNAME=c58c2c309938
DEIS_APP=go
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app/bin
PWD=/app
HOME=/app
SHLVL=1
PORT=5000
DEIS_RELEASE=v2
_=/usr/bin/env
```



Discussion:

Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -658,10 +658,13 @@ def apps_run(self, args):
           -a --app=<app>
             the uniquely identifiable name for the application.
         """
+        command = ' '.join(args.get('<command>'))
+        self._logger.info('Running `{}`...'.format(command))
+
         app = args.get('--app')
         if not app:
             app = self._session.app
-        body = {'command': ' '.join(args.get('<command>'))}
+        body = {'command': command}
         response = self._dispatch('post',
                                   "/api/apps/{}/run".format(app),
                                   json.dumps(body))


Test patch:
Repository: deis/deis

Issue:
bug(controller): deis domains:remove deletes the key in etcd
Added two alias

```
$ deis domains:add example.com
$ deis domains:add www.example.com
```

Ok!

```
$ etcdctl get /deis/domains/test
example.com www.example.com
```

Remove one alias

```
$ deis domains:remove www.example.com
Removing www.example.com from test... done
```

remove all domain alias in etcd (www.example.com, example.com), and remove example.com from config nginx(router). DB record example.com present.

```
$ etcdctl get /deis/domains/test
Error:  100: Key not found (/deis/domains/test) [3509029]
```

```
$ deis domains:remove example.com
Removing example.com from test... 500 INTERNAL SERVER ERROR
<h1>Server Error (500)</h1>
```



Discussion:
@grengojbo Thanks for the detailed report! This is tracked in #2181 and is something we'll need to fix ASAP.


Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -863,7 +863,12 @@ def _etcd_publish_domains(**kwargs):
 
 def _etcd_purge_domains(**kwargs):
     app = kwargs['instance'].app
-    _etcd_client.delete('/deis/domains/{}'.format(app))
+    app_domains = app.domain_set.all()
+    if app_domains:
+        _etcd_client.write('/deis/domains/{}'.format(app),
+                           ' '.join(str(d.domain) for d in app_domains))
+    else:
+        _etcd_client.delete('/deis/domains/{}'.format(app))
 
 
 # Log significant app-related events


Test patch:
Repository: deis/deis

Issue:
client: Exception.message is deprecated for >= python2.7
While working on the `deis` client in a python3 environment I discovered that [`Exception.message`](https://github.com/deis/deis/blob/master/client/deis.py#L2001) has been [deprecated](http://legacy.python.org/dev/peps/pep-0352/) for python2.7 and greater (python3). [`Exception.args`](https://docs.python.org/2/tutorial/errors.html) should be used instead.



Discussion:

Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1995,10 +1995,10 @@ def _dispatch_cmd(method, args):
 correct and the server is running.")
         sys.exit(1)
     except EnvironmentError as err:
-        logger.error(err.message)
+        logger.error(err.args[0])
         sys.exit(1)
     except ResponseError as err:
-        resp = err.message
+        resp = err.args[0]
         logger.error('{} {}'.format(resp.status_code, resp.reason))
         try:
             msg = resp.json()


Test patch:
Repository: deis/deis

Issue:
deis logs error
I often get this error when I run `deis logs`. I'm using 0.15.0. I tried with two apps: rails and nodejs.

```
Traceback (most recent call last):
  File "/usr/local/bin/deis", line 9, in <module>
    load_entry_point('deis==0.15.0', 'console_scripts', 'deis')()
  File "/Library/Python/2.7/site-packages/deis.py", line 2049, in main
    _dispatch_cmd(method, args)
  File "/Library/Python/2.7/site-packages/deis.py", line 1992, in _dispatch_cmd
    method(args)
  File "/Library/Python/2.7/site-packages/deis.py", line 608, in apps_logs
    log_tag = line.split(': ')[0].split(' ')[1]
```



Discussion:
@gahissy what's the output of:

`curl -s deis.example.com/v1/apps/<appname>/logs -h "Authorization: <token>"`

You can retrieve your token by looking at `~/.deis/client.json`.

to note, this issue only occurs when upgrading from a previous version of Deis, due to how log timestamps are formatted. A safety net for this would be to default to uncoloured logs, should the parsing logic fail.

> A safety net for this would be to default to uncoloured logs, should the parsing logic fail.

I think that's totally reasonable, if it's an easy fix.

should be as easy as a try/catch block :)


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -610,19 +610,22 @@ def apps_logs(self, args):
             # strip the last newline character
             for line in response.json().split('\n')[:-1]:
                 # get the tag from the log
-                log_tag = line.split(': ')[0].split(' ')[1]
-                # colorize the log based on the tag
-                color = sum([ord(ch) for ch in log_tag]) % 6
-                def f(x):
-                    return {
-                        0: 'green',
-                        1: 'cyan',
-                        2: 'red',
-                        3: 'yellow',
-                        4: 'blue',
-                        5: 'magenta',
-                    }.get(x, 'magenta')
-                self._logger.info(colored(line, f(color)))
+                try:
+                    log_tag = line.split(': ')[0].split(' ')[1]
+                    # colorize the log based on the tag
+                    color = sum([ord(ch) for ch in log_tag]) % 6
+                    def f(x):
+                        return {
+                            0: 'green',
+                            1: 'cyan',
+                            2: 'red',
+                            3: 'yellow',
+                            4: 'blue',
+                            5: 'magenta',
+                        }.get(x, 'magenta')
+                    self._logger.info(colored(line, f(color)))
+                except IndexError:
+                    self._logger.info(line)
         else:
             raise ResponseError(response)
 


Test patch:
Repository: deis/deis

Issue:
`deis logs` output confusing due to the change in timezone
Example `deis logs` output - note that the logger uses UTC but the controller defaults to MST. They should all just be UTC:

```
2014-11-11T04:37:10UTC truthy-unicycle[web.2]: [2014-11-11 04:37:10] INFO  WEBrick 1.3.1
2014-11-11T04:37:10UTC truthy-unicycle[web.2]: [2014-11-11 04:37:10] INFO  ruby 1.9.3 (2014-10-27) [x86_64-linux]
2014-11-11T04:37:10UTC truthy-unicycle[web.2]: == Sinatra/1.4.2 has taken the stage on 5000 for production with backup from WEBrick
2014-11-11T04:37:10UTC truthy-unicycle[web.2]: [2014-11-11 04:37:10] INFO  WEBrick::HTTPServer#start: pid=1 port=5000
2014-11-10T21:38:43MST deis[api]: truthy-unicycle: test scaled containers web=0
2014-11-10T21:38:48MST deis[api]: truthy-unicycle: test scaled containers web=5
2014-11-11T04:38:55UTC truthy-unicycle[web.2]: [2014-11-11 04:38:55] INFO  WEBrick 1.3.1
2014-11-11T04:38:55UTC truthy-unicycle[web.2]: [2014-11-11 04:38:55] INFO  ruby 1.9.3 (2014-10-27) [x86_64-linux]
2014-11-11T04:38:55UTC truthy-unicycle[web.2]: == Sinatra/1.4.2 has taken the stage on 5000 for production with backup from WEBrick
2014-11-11T04:38:55UTC truthy-unicycle[web.2]: [2014-11-11 04:38:55] INFO  WEBrick::HTTPServer#start: pid=1 port=5000
```



Discussion:

Resolving patch:
diff --git a/controller/deis/settings.py b/controller/deis/settings.py
--- a/controller/deis/settings.py
+++ b/controller/deis/settings.py
@@ -28,7 +28,7 @@
 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
 # although not all choices may be available on all operating systems.
 # In a Windows environment this must be set to your system time zone.
-TIME_ZONE = 'America/Denver'
+TIME_ZONE = 'UTC'
 
 # Language code for this installation. All choices can be found here:
 # http://www.i18nguy.com/unicode/language-identifiers.html


Test patch:
Repository: deis/deis

Issue:
make discovery-url is doesn't work .
shows no rule to create discovery-url .stop!
i have search the old issues,it didn't solve the problem.



Discussion:
Have you cloned the Deis codebase locally? Are you running `make discovery-url` from the project root?

No .the doc didn't let me do this.

Get it.

@zyxia we mention you must run `make discovery-url` in the [Quick Start](http://docs.deis.io/en/latest/installing_deis/quick-start/#generate-a-new-discovery-url), in the [Vagrant install](http://docs.deis.io/en/latest/installing_deis/vagrant/#generate-a-new-discovery-url) docs, and in all the other provider-specific install docs.

It's not clear whether you ran `make discovery-url` and it somehow failed, or if you're saying the documentation didn't tell you to run `make discovery-url`.

I means documentation didn't tell me download deis/deis project. And I have solve this problem by copy it from github.

Ok, gotcha. I will fix that in the documentation when I fix #2509 soon.


Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -84,7 +84,7 @@
 
 # List of patterns, relative to source directory, that match files and
 # directories to ignore when looking for source files.
-exclude_patterns = ['_build', 'venv']
+exclude_patterns = ['_build', 'venv', '**/_*.rst']
 
 # The reST default role (used for this markup: `text`) to use for all documents.
 #default_role = None


Test patch:
Repository: deis/deis

Issue:
LICENSE needs updating for 2014
It still says 2013



Discussion:
IANAL, but I don't think it's necessary to sync up the dates in the LICENSE files, or to keep them current. They represent an initial assertion of copyright, so having > 1 copy that disagrees by a year or two could be a minor problem in the far future...like 95 years I think. But the debate would be about whether copyright expires in 2109 or 2110, which seems of little consequence.

We had a similar question a while back, ran it by our lawyers and were told not to worry about it. ping @JoshuaSchnell.


Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -59,7 +59,7 @@
 
 # General information about the project.
 project = u'deis'
-copyright = u'2013, OpDemand LLC'
+copyright = u'2013, 2014 OpDemand LLC'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the


Test patch:
Repository: deis/deis

Issue:
fix(2650): config:set runs as the app owner instead of issuing user
Trivial fix to have config:set run as the issuing user. See #2650 for details.



Discussion:

Resolving patch:
diff --git a/controller/api/views.py b/controller/api/views.py
--- a/controller/api/views.py
+++ b/controller/api/views.py
@@ -289,7 +289,6 @@ def pre_save(self, config):
         previous_config = config.app.config_set.latest()
         config.owner = self.request.user
         if previous_config:
-            config.owner = previous_config.owner
             for attr in ['cpu', 'memory', 'tags', 'values']:
                 # Guard against migrations from older apps without fixes to
                 # JSONField encoding.


Test patch:
diff --git a/controller/api/tests/test_config.py b/controller/api/tests/test_config.py
--- a/controller/api/tests/test_config.py
+++ b/controller/api/tests/test_config.py
@@ -187,6 +187,7 @@ def test_admin_can_create_config_on_other_apps(self):
                                     HTTP_AUTHORIZATION='token {}'.format(self.token))
         self.assertEqual(response.status_code, 201)
         self.assertIn('PORT', response.data['values'])
+        return response
 
     @mock.patch('requests.post', mock_import_repository_task)
     def test_limit_memory(self):
@@ -423,3 +424,11 @@ def test_tags(self):
         self.assertEqual(response.status_code, 405)
         response = self.client.delete(url, HTTP_AUTHORIZATION='token {}'.format(self.token))
         self.assertEqual(response.status_code, 405)
+
+    def test_config_owner_is_requesting_user(self):
+        """
+        Ensure that setting the config value is owned by the requesting user
+        See https://github.com/deis/deis/issues/2650
+        """
+        response = self.test_admin_can_create_config_on_other_apps()
+        self.assertEqual(response.data['owner'], self.user.username)
Repository: deis/deis

Issue:
`deis run` hangs on failed container
If you do a `deis run` and the container `fail`s, the command just hangs with no response, and never cleans up the scheduled admin container in fleet.

for example, before PR'ing https://github.com/deis/deis/pull/2642, I was testing with https://github.com/deis/example-dockerfile-http which does not have `bash` present in the image (we use that as the entrypoint for run commands):

```
><> deis run echo hi
running 'echo hi'...
^C
><> fleetctl list-units | grep dock_v2.run.1
dock_v2.run.1.service       2280c10f.../10.21.12.2  failed      failed
```

This is not a regression that was recently introduced, just a bug that's been there for a while.



Discussion:

Resolving patch:
diff --git a/controller/scheduler/fleet.py b/controller/scheduler/fleet.py
--- a/controller/scheduler/fleet.py
+++ b/controller/scheduler/fleet.py
@@ -256,14 +256,27 @@ def _do_ssh(cmd):
             rc, output = chan.recv_exit_status(), out.read()
             return rc, output
 
-        # wait for container to start
-        for _ in range(1200):
+        # wait for container to launch
+        for _ in range(60):
             rc, _ = _do_ssh('docker inspect {name}'.format(**locals()))
             if rc == 0:
                 break
             time.sleep(1)
         else:
-            raise RuntimeError('container failed to start on host')
+            raise RuntimeError('failed to create container')
+
+        # wait for container to start
+        for _ in range(2):
+            _rc, _output = _do_ssh('docker inspect {name}'.format(**locals()))
+            if _rc != 0:
+                raise RuntimeError('failed to inspect container')
+            _container = json.loads(_output)
+            started_at = _container[0]["State"]["StartedAt"]
+            if not started_at.startswith('0001'):
+                break
+            time.sleep(1)
+        else:
+            raise RuntimeError('container failed to start')
 
         # wait for container to complete
         for _ in range(1200):


Test patch:
Repository: deis/deis

Issue:
"deis destroy" doesn't show the 40x error for an unauthorized user
While an unauthorized user cannot actually destroy the app, the `deis` CLI doesn't report that fact currently. Cosmetic, but annoying:

``` console
$ deis destroy -a wilder-zeppelin

 !    WARNING: Potentially Destructive Action
 !    This command will destroy the application: wilder-zeppelin
 !    To proceed, type "wilder-zeppelin" or re-run this command with --confirm=wilder-zeppelin

> wilder-zeppelin
Destroying wilder-zeppelin... 
done in 0s
```



Discussion:
The problem child:

https://github.com/deis/deis/blob/b8058d8950a5883414f7d5cfd37f9109b9bff0a8/client/deis.py#L542

Really this should be returning a 403 (see discussion in #2856), but we should remove this check.

Marking as easy-fix for newer developers since this is a quickie :)


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -538,8 +538,7 @@ def apps_destroy(self, args):
         finally:
             progress.cancel()
             progress.join()
-        if response.status_code in (requests.codes.no_content,
-                                    requests.codes.not_found):
+        if response.status_code == requests.codes.no_content:
             self._logger.info('done in {}s'.format(int(time.time() - before)))
             try:
                 # If the requested app is a heroku app and the app


Test patch: