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

Issue:
fix(controller): generate_app_name should re-roll on duplicate name
Lurking through old comments, I found https://github.com/deis/deis/issues/475#issuecomment-32907618. If we find an existing app name when generating a random app name, we should re-roll `generate_app_name()` until we find a new name for the application, otherwise we will hit a 500 error because the application name already exists.



Discussion:

Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -129,6 +129,16 @@ class Meta:
         abstract = True
 
 
+def select_app_name():
+    """Select a unique randomly generated app name"""
+    name = utils.generate_app_name()
+
+    while App.objects.filter(id=name).exists():
+        name = utils.generate_app_name()
+
+    return name
+
+
 class UuidAuditedModel(AuditedModel):
     """Add a UUID primary key to an :class:`AuditedModel`."""
 
@@ -146,7 +156,7 @@ class App(UuidAuditedModel):
     """
 
     owner = models.ForeignKey(settings.AUTH_USER_MODEL)
-    id = models.SlugField(max_length=64, unique=True, default=utils.generate_app_name,
+    id = models.SlugField(max_length=64, unique=True, default=select_app_name,
                           validators=[validate_id_is_docker_compatible,
                                       validate_reserved_names])
     structure = JSONField(default={}, blank=True, validators=[validate_app_structure])


Test patch:
Repository: deis/deis

Issue:
clarify usage of ps:restart
`deis help ps` reads as "restart process types (e.g. web, worker)" which implies that you can only restart a specific process type. The documentation at `deis help ps:restart` also shows "Restarts an application's processes by type" which is untrue. It allows you to restart all containers, a specific process type, or an individual container:

```
deis ps:restart # restarts all processes
deis ps:restart web # restarts all web processes
deis ps:restart web.1 # restarts web.1
```

We should clarify this in the client help.



Discussion:

Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1711,7 +1711,7 @@ def ps(self, args):
         Valid commands for processes:
 
         ps:list        list application processes
-        ps:restart     restart process types (e.g. web, worker)
+        ps:restart     restart an application or its process types
         ps:scale       scale processes (e.g. web=4 worker=2)
 
         Use `deis help [command]` to learn more.
@@ -1751,7 +1751,7 @@ def ps_list(self, args, app=None):
 
     def ps_restart(self, args):
         """
-        Restarts an application's processes by type.
+        Restart an application, a process type or a specific process.
 
         Usage: deis ps:restart [<type>] [options]
 


Test patch:
Repository: deis/deis

Issue:
docker.service needs to depend on the mount.
Ran into some edge cases where the mount would not complete before docker started. This would cause docker run to never work until the docker daemon was restarted. We fixed this on our end by putting an After and Require statement in the docker.service.



Discussion:
Thanks @jwaldrip. Mind PRing what you've got?

Clearing milestone - I thought this was related to the docker-tcp.socket added in Deis 1.6, but I think you seem to be referring to the mount volume.

Seems to be a bigger issue...


Resolving patch:
diff --git a/contrib/ec2/gen-json.py b/contrib/ec2/gen-json.py
--- a/contrib/ec2/gen-json.py
+++ b/contrib/ec2/gen-json.py
@@ -28,6 +28,11 @@
   Where=/var/lib/docker
   Type=ext4
 '''
+DOCKER_DROPIN = '''
+  [Unit]
+  Requires=var-lib-docker.mount
+  After=var-lib-docker.mount
+'''
 FORMAT_ETCD_VOLUME = '''
   [Unit]
   Description=Formats the etcd device
@@ -60,13 +65,20 @@
   RemainAfterExit=yes
   ExecStart=/usr/bin/chown -R etcd:etcd /media/etcd
 '''
+ETCD_DROPIN = '''
+  [Unit]
+  Requires=prepare-etcd-data-directory.service
+  After=prepare-etcd-data-directory.service
+'''
 
 new_units = [
   dict({'name': 'format-docker-volume.service', 'command': 'start', 'content': FORMAT_DOCKER_VOLUME}),
   dict({'name': 'var-lib-docker.mount', 'command': 'start', 'content': MOUNT_DOCKER_VOLUME}),
+  dict({'name': 'docker.service', 'drop-ins': [{'name': '90-after-docker-volume.conf', 'content': DOCKER_DROPIN}]}),
   dict({'name': 'format-etcd-volume.service', 'command': 'start', 'content': FORMAT_ETCD_VOLUME}),
   dict({'name': 'media-etcd.mount', 'command': 'start', 'content': MOUNT_ETCD_VOLUME}),
-  dict({'name': 'prepare-etcd-data-directory.service', 'command': 'start', 'content': PREPARE_ETCD_DATA_DIRECTORY})
+  dict({'name': 'prepare-etcd-data-directory.service', 'command': 'start', 'content': PREPARE_ETCD_DATA_DIRECTORY}),
+  dict({'name': 'etcd.service', 'drop-ins': [{'name': '90-after-etcd-volume.conf', 'content': ETCD_DROPIN}]})
 ]
 
 data = yaml.load(file(os.path.join(CURR_DIR, '..', 'coreos', 'user-data'), 'r'))


Test patch:
Repository: deis/deis

Issue:
Sphinx code autodocs are broken
The build environment at ReadTheDocs.org has changed again, and the python auto-generated docs are blank because `python-ldap` can't be built:

``` console
running build_ext
building '_ldap' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/Modules
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=2.4.19 -IModules -I/opt/openldap-RE24/include -I/usr/include/sasl -I/usr/include -I/usr/include/python2.7 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-2.7/Modules/LDAPObject.o
In file included from Modules/LDAPObject.c:9:0:
Modules/errors.h:8:18: fatal error: lber.h: No such file or directory
 #include "lber.h"
                  ^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
```

I don't see any way to do `apt-get install libldap2-dev` or the equivalent there. I'll post an issue at their GitHub project.

_Update:_ see rtfd/readthedocs.org#1363



Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -14,6 +14,17 @@
 import os
 import sys
 
+from mock import MagicMock
+
+# Mock out modules that can't be installed at ReadTheDocs.org.
+class MockModule(MagicMock):
+    @classmethod
+    def __getattr__(cls, name):
+            return MockModule()
+
+MOCK_MODULES = ['django_auth_ldap', 'django_auth_ldap.config', 'django_auth_ldap.models', 'ldap']
+sys.modules.update((mod_name, MockModule()) for mod_name in MOCK_MODULES)
+
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.


Test patch:
Repository: deis/deis

Issue:
`deis certs:update` doesn't exist
See [here](https://github.com/deis/deis/blob/master/client/deis.py#L1096). There is no code to implement the command.

I'd vote for entirely removing the command, since it presumably was never functional and nobody caught that it was broken yet.



Discussion:
:+1: Given that someone could quite easily `deis certs:remove` and then `deis certs:add`, I think it's reasonable to remove.

:+1: sorry! Forgot to remove that in the docs


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1093,7 +1093,6 @@ def certs(self, args):
 
         certs:list            list SSL certificates for an app
         certs:add             add an SSL certificate to an app
-        certs:update          update an existing certifcate for an app
         certs:remove          remove an SSL certificate from an app
 
         Use `deis help [command]` to learn more.


Test patch:
Repository: deis/deis

Issue:
can't run created linodes
Hi,
I created 3 linodes by:

```
./provision-linode-cluster.py --api-key=LINODE_API_KEY provision
```

And successful!
But can't run..
result:

```
Cannot Direct Disk boot a disk with no MBR: Kernel not found
```

I don't know why.. 
You can try it.

Thank you ..



Discussion:
Is your account hypervisor set to KVM?

@croemmich  yes, is KVM

@croemmich
I got it.
Run this command and result:

```
$HOME/coreos-install -d /dev/sdb -C  beta -V 647.2.0 -c $HOME/cloud-config.yaml -t /dev/shm
/root/coreos-install: coreos-cloudinit not found. Could not validate config. Continuing...
/root/coreos-install: Image URL unavailable: http://beta.release.core-os.net/amd64-usr/647.2.0/coreos_production_image.bin.bz2
```

This coreos version not found...

## Need to change the version to 717.3.0

provision-linode-cluster.py

```
    provision_parser.add_argument('--coreos-version', required=False, default='717.3.0', dest='coreos_version',
                                  help='CoreOS version number to install')
    provision_parser.add_argument('--coreos-channel', required=False, default='stable', dest='coreos_channel',
                                  help='CoreOS channel to install from')
```

@molisoft That CoreOS version will actually cause problems - it comes with Docker 1.6.2, which has a known issue relating to image pulls. We're waiting for Docker 1.7.1 to make its way to the CoreOS stable channel.

If Linode only allows users to use the latest CoreOS image, we're sometimes going to run into issues on that platform. 

I'll give this a look. You should be able run any version of coreos, as this is booting as a direct disk instance.


Resolving patch:
diff --git a/contrib/linode/provision-linode-cluster.py b/contrib/linode/provision-linode-cluster.py
--- a/contrib/linode/provision-linode-cluster.py
+++ b/contrib/linode/provision-linode-cluster.py
@@ -415,7 +415,7 @@ def run(self):
                                   help='CoreOS cloud config user-data file')
     provision_parser.add_argument('--coreos-version', required=False, default='647.2.0', dest='coreos_version',
                                   help='CoreOS version number to install')
-    provision_parser.add_argument('--coreos-channel', required=False, default='beta', dest='coreos_channel',
+    provision_parser.add_argument('--coreos-channel', required=False, default='stable', dest='coreos_channel',
                                   help='CoreOS channel to install from')
     provision_parser.set_defaults(cmd=ProvisionCommand)
 


Test patch:
Repository: deis/deis

Issue:
Better error message when registration is disabled
When `/deis/controller/registrationMode` is `disabled`, attempt to register returns

```
Registration failed: {"detail":"Authentication credentials were not provided."}
```

This message is misleading. It should explicitly say that registration is disabled.



Discussion:
:+1: I agree a better warning would be less confusing.

When I tried this with current master and the new `deis` CLI, I see this instead:

``` console
$ deisctl config controller get registrationMode
disabled
$ deis register http://deis.local3.deisapp.com --username=test2 --password=asdf1234 --email=just@testing.thanks
Registration failed: Error: 
detail: You do not have permission to perform this action.
403 FORBIDDEN
```

That's a slightly more accurate error message, but ideally Deis would specifically state "registration is disabled" in this case.


Resolving patch:
diff --git a/controller/api/permissions.py b/controller/api/permissions.py
--- a/controller/api/permissions.py
+++ b/controller/api/permissions.py
@@ -1,3 +1,5 @@
+
+from rest_framework import exceptions
 from rest_framework import permissions
 from django.conf import settings
 from django.contrib.auth.models import AnonymousUser
@@ -103,7 +105,7 @@ def has_permission(self, request, view):
         """
         try:
             if settings.REGISTRATION_MODE == 'disabled':
-                return False
+                raise exceptions.PermissionDenied('Registration is disabled')
             if settings.REGISTRATION_MODE == 'enabled':
                 return True
             elif settings.REGISTRATION_MODE == 'admin_only':


Test patch:
Repository: deis/deis

Issue:
chore(*): bump etcd to 2.1.3
See https://github.com/coreos/etcd/compare/v2.1.2...v2.1.3 for details of the one bug fix included. (Probably irrelevant to our current testing issues.)



Discussion:
yup, completely irrelevant since it only deals with TLS-backed etcd clusters but still always nice to bump revs.

LGTM

Should we also bump the graceful shutdown script in user-data.example so it checks for etcd 2.1.3?

> Should we also bump the graceful shutdown script in user-data.example so it checks for etcd 2.1.3?

IMO, yes.  In fact, see #4388.  I am wondering if we should just upgrade `etcdctl` in _all_ new clusters (not only when graceful shutdown is enabled).  It adds useful stuff like `cluster-health` and `member list`.


Resolving patch:
diff --git a/contrib/aws/gen-json.py b/contrib/aws/gen-json.py
--- a/contrib/aws/gen-json.py
+++ b/contrib/aws/gen-json.py
@@ -73,7 +73,7 @@
   Description=Prepares the etcd data directory
   Requires=media-etcd.mount
   After=media-etcd.mount
-  Before=etcd.service
+  Before=etcd2.service
   [Service]
   Type=oneshot
   RemainAfterExit=yes
@@ -92,7 +92,7 @@
     dict({'name': 'format-etcd-volume.service', 'command': 'start', 'content': FORMAT_ETCD_VOLUME}),
     dict({'name': 'media-etcd.mount', 'command': 'start', 'content': MOUNT_ETCD_VOLUME}),
     dict({'name': 'prepare-etcd-data-directory.service', 'command': 'start', 'content': PREPARE_ETCD_DATA_DIRECTORY}),
-    dict({'name': 'etcd.service', 'drop-ins': [{'name': '90-after-etcd-volume.conf', 'content': ETCD_DROPIN}]})
+    dict({'name': 'etcd2.service', 'drop-ins': [{'name': '90-after-etcd-volume.conf', 'content': ETCD_DROPIN}]})
 ]
 
 with open(os.path.join(CURR_DIR, '..', 'coreos', 'user-data'), 'r') as f:


Test patch:
Repository: deis/deis

Issue:
Proposal ref(controller): disable swap usage if there is a memory limit
If the app uses `deis limits:set -m type=XXX -a XXX` add the flag `--memory-swap=-1`

```
docker help run
....
  --memory-swap=""           Total memory usage (memory + swap), set '-1' to disable swap (format: <number><optional unit>, where unit = b, k, m or g)
```

without that if the node uses swap it will not use the specified limit



Discussion:
I think disabling swap is reasonable. Is this in Docker 1.4.1 which we're on now?

@carmstrong no, it's available since 1.5.0

> no, it's available since 1.5.0

Let's revisit this once we get that in stable (should be soon).

I think I ran into the side effects of this yesterday...


Resolving patch:
diff --git a/controller/deis/settings.py b/controller/deis/settings.py
--- a/controller/deis/settings.py
+++ b/controller/deis/settings.py
@@ -5,6 +5,7 @@
 from __future__ import unicode_literals
 import os.path
 import random
+import semantic_version as semver
 import string
 import sys
 import tempfile
@@ -372,6 +373,17 @@
     sys.path.append('/templates')
     from confd_settings import *  # noqa
 
+# Disable swap when mem limits are set, unless Docker is too old
+DISABLE_SWAP = '--memory-swap=-1'
+try:
+    version = 'unknown'
+    from registry.dockerclient import DockerClient
+    version = DockerClient().client.version().get('Version')
+    if not semver.validate(version) or semver.Version(version) < semver.Version('1.5.0'):
+        DISABLE_SWAP = ''
+except:
+    print("Not disabling --memory-swap for Docker version {}".format(version))
+
 # LDAP Backend Configuration
 # Should be always after the confd_settings import.
 LDAP_USER_SEARCH = LDAPSearch(
diff --git a/controller/scheduler/fleet.py b/controller/scheduler/fleet.py
--- a/controller/scheduler/fleet.py
+++ b/controller/scheduler/fleet.py
@@ -127,7 +127,7 @@ def _create_container(self, name, image, command, unit, **kwargs):
         # prepare memory limit for the container type
         mem = kwargs.get('memory', {}).get(l['c_type'], None)
         if mem:
-            l.update({'memory': '-m {}'.format(mem.lower())})
+            l.update({'memory': '-m {} {}'.format(mem.lower(), settings.DISABLE_SWAP)})
         else:
             l.update({'memory': ''})
         # prepare memory limit for the container type


Test patch:
Repository: deis/deis

Issue:
disable adding wildcard app certificates
This has burned a few people. We allowed removing them because of https://github.com/deis/deis/issues/3533, but we should disable adding these certificates for the time being until this feature is implemented.



Discussion:

Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -116,6 +116,11 @@ def validate_certificate(value):
         raise ValidationError('Could not load certificate: {}'.format(e))
 
 
+def validate_common_name(value):
+    if '*' in value:
+        raise ValidationError('Wildcard certificates are not supported')
+
+
 def get_etcd_client():
     if not hasattr(get_etcd_client, "client"):
         # wire up etcd publishing if we can connect
@@ -1011,7 +1016,7 @@ class Certificate(AuditedModel):
     certificate = models.TextField(validators=[validate_certificate])
     key = models.TextField()
     # X.509 certificates allow any string of information as the common name.
-    common_name = models.TextField(unique=True)
+    common_name = models.TextField(unique=True, validators=[validate_common_name])
     expires = models.DateTimeField()
 
     def __str__(self):


Test patch:
diff --git a/controller/api/tests/test_certificate.py b/controller/api/tests/test_certificate.py
--- a/controller/api/tests/test_certificate.py
+++ b/controller/api/tests/test_certificate.py
@@ -80,6 +80,17 @@ def test_create_certificate_with_domain(self):
                                     HTTP_AUTHORIZATION='token {}'.format(self.token))
         self.assertEqual(response.status_code, 201)
 
+    def test_create_wildcard_certificate(self):
+        """Tests creating a wildcard certificate, which should be disabled."""
+        body = {'certificate': self.autotest_example_com_cert,
+                'key': self.key,
+                'common_name': '*.example.com'}
+        response = self.client.post(self.url, json.dumps(body), content_type='application/json',
+                                    HTTP_AUTHORIZATION='token {}'.format(self.token))
+        self.assertEqual(response.status_code, 400)
+        self.assertEqual(json.loads(response.content),
+                         {'common_name': ['Wildcard certificates are not supported']})
+
     def test_create_certificate_with_different_common_name(self):
         """
         In some cases such as with SAN certificates, the certificate can cover more
Repository: deis/deis

Issue:
bug(ceph): do not upgrade to 4.3+ linux kernels
This is just a warning in case a stable CoreOS upgrade. 
http://tracker.ceph.com/issues/14360



Discussion:
ping @carmstrong @mboersma 

Yep, I think that's why we haven't seen a new stable release yet: https://github.com/coreos/bugs/issues/1092


Resolving patch:
diff --git a/contrib/linode/provision-linode-cluster.py b/contrib/linode/provision-linode-cluster.py
--- a/contrib/linode/provision-linode-cluster.py
+++ b/contrib/linode/provision-linode-cluster.py
@@ -357,7 +357,7 @@ def main():
                                   help='Node data center id. Use list-data-centers to find the id.')
     provision_parser.add_argument('--cloud-config', required=False, default='linode-user-data.yaml', type=file, dest='cloud_config',
                                   help='CoreOS cloud config user-data file')
-    provision_parser.add_argument('--coreos-version', required=False, default='835.13.0', dest='coreos_version',
+    provision_parser.add_argument('--coreos-version', required=False, default='899.13.0', dest='coreos_version',
                                   help='CoreOS version number to install')
     provision_parser.add_argument('--coreos-channel', required=False, default='stable', dest='coreos_channel',
                                   help='CoreOS channel to install from')


Test patch:
Repository: Azure/azure-cli-extensions

Issue:
Change help for az webapp new
### Extension name (the extension in question)
webapp

### Description of issue (in as much detail as possible)
currently the help information for the command return the 

Command
    az webapp new: Create and deploy a node web app.

Requested changes:

- add the callout for .net core apps
- add explicit mention that the command is in preview

-----




Discussion:

Resolving patch:
diff --git a/src/webapp/azext_webapp/_help.py b/src/webapp/azext_webapp/_help.py
--- a/src/webapp/azext_webapp/_help.py
+++ b/src/webapp/azext_webapp/_help.py
@@ -8,7 +8,8 @@
 
 helps['webapp new'] = """
     type: command
-    short-summary: Create and deploy a node web app
+    short-summary: Experimental command to create and deploy a web app.
+                   Current supports Node on Linux & .NET Core on Windows.
     examples:
         - name: Create a web app with the default configuration.
           text: >
diff --git a/src/webapp/setup.py b/src/webapp/setup.py
--- a/src/webapp/setup.py
+++ b/src/webapp/setup.py
@@ -8,7 +8,7 @@
 from codecs import open
 from setuptools import setup, find_packages
 
-VERSION = "0.1.0"
+VERSION = "0.1.1"
 
 CLASSIFIERS = [
     'Development Status :: 4 - Beta',


Test patch: