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

Issue:
fix(controller): Disable web UI for Deis controller
We should completely disable the [web module](https://github.com/deis/deis/tree/master/controller/web) for the controller, including the django-admin. This is because you can create entries in the database, but nothing changes (e.g. if you create a Release object, no image is pushed to the registry). Setting an etcd key (`/deis/controller/webUI`) to enable/disable the web UI should be configurable so that users can still display it if they wish, but ultimately the web module needs more work. This is a stopgap so users cannot shoot themselves in the :shoe:.



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
@@ -283,6 +283,9 @@
 # check if we can register users with `deis register`
 REGISTRATION_ENABLED = True
 
+# check if we should enable the web UI module
+WEB_ENABLED = False
+
 # default to sqlite3, but allow postgresql config through envvars
 DATABASES = {
     'default': {
diff --git a/controller/deis/urls.py b/controller/deis/urls.py
--- a/controller/deis/urls.py
+++ b/controller/deis/urls.py
@@ -7,6 +7,7 @@
 
 from __future__ import unicode_literals
 
+from django.conf import settings
 from django.conf.urls import patterns, include, url
 from django.contrib import admin
 
@@ -17,7 +18,12 @@
 urlpatterns = patterns(
     '',
     url(r'^accounts/', include('allauth.urls')),
-    url(r'^admin/', include(admin.site.urls)),
     url(r'^api/', include('api.urls')),
-    url(r'^', include('web.urls')),
 )
+
+if settings.WEB_ENABLED:
+    urlpatterns += patterns(
+        '',
+        url(r'^', include('web.urls')),
+        url(r'^admin/', include(admin.site.urls)),
+    )
diff --git a/controller/templates/confd_settings.py b/controller/templates/confd_settings.py
--- a/controller/templates/confd_settings.py
+++ b/controller/templates/confd_settings.py
@@ -28,3 +28,7 @@
 {{ if .deis_controller_registrationEnabled }}
 REGISTRATION_ENABLED = bool({{ .deis_controller_registrationEnabled }})
 {{ end }}
+
+{{ if .deis_controller_webEnabled }}
+WEB_ENABLED = bool({{ .deis_controller_webEnabled }})
+{{ end }}


Test patch:
Repository: deis/deis

Issue:
deis client can't login to https controller
Can't login to controller if using https (in my case SSL is terminated on a rackspace loadbalancer).

The `deis login https://url-of-my-controller.com` command just returns `Login failed`. Digging down into the source, I found the following to be returned by the server:

``` html
  <h1>Forbidden <span>(403)</span></h1>
  <p>CSRF verification failed. Request aborted.</p>

  <p>You are seeing this message because this HTTPS site requires a 'Referer
   header' to be sent by your Web browser, but none was sent. This header is
   required for security reasons, to ensure that your browser is not being
   hijacked by third parties.</p>

  <p>If you have configured your browser to disable 'Referer' headers, please
   re-enable them, at least for this site, or for HTTPS connections, or for
   'same-origin' requests.</p>
```

This might be a configuration problem on my side. Does the SSL terminator need to add any special headers or such?

Sidenote: to make debugging easier a `--traceback` option, similar to the one in django, would be cool for the `deis` command.



Discussion:
- logging in with a normal browser using **https** and **http** works
- logging in with the deis client with **http** works


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -147,6 +147,11 @@ def request(self, *args, **kwargs):
                 else:
                     kwargs['headers'] = {'X-CSRFToken': cookie.value}
                 break
+        url = args[1]
+        if 'headers' in kwargs:
+            kwargs['headers']['Referer'] = url
+        else:
+            kwargs['headers'] = {'Referer': url}
         response = super(Session, self).request(*args, **kwargs)
         self.cookies.save()
         return response


Test patch:
Repository: deis/deis

Issue:
contrib/ec2: directions for launching cluster into VPC
Trying to figure this out right now



Discussion:

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
@@ -10,4 +10,28 @@
 template['Resources']['CoreOSServerLaunchConfig']['Properties']['UserData']['Fn::Base64']['Fn::Join'] = [ '', lines ]
 template['Parameters']['ClusterSize']['Default'] = str(os.getenv('DEIS_NUM_INSTANCES', 3))
 
+VPC_ID = os.getenv('VPC_ID', None)
+VPC_SUBNETS = os.getenv('VPC_SUBNETS', None)
+VPC_ZONES = os.getenv('VPC_ZONES', None)
+
+if VPC_ID and VPC_SUBNETS and VPC_ZONES:
+  for resource in template['Resources'].keys():
+    resource_type = template['Resources'][resource]['Type']
+    if resource_type == 'AWS::EC2::SecurityGroup':
+      template['Resources'][resource]['Properties']['VpcId'] = VPC_ID
+    elif resource_type == 'AWS::EC2::SecurityGroupIngress':
+      template['Resources'][resource]['Properties']['GroupId'] = template['Resources'][resource]['Properties']['GroupName']
+      del template['Resources'][resource]['Properties']['GroupName']
+      template['Resources'][resource]['Properties']['SourceSecurityGroupId'] = {
+        'Ref': template['Resources'][resource]['Properties']['SourceSecurityGroupId']['Fn::GetAtt'][0]
+      }
+    elif resource_type == 'AWS::AutoScaling::LaunchConfiguration':
+      template['Resources'][resource]['Properties']['AssociatePublicIpAddress'] = False
+    elif resource_type == 'AWS::ElasticLoadBalancing::LoadBalancer':
+      del template['Resources'][resource]['Properties']['AvailabilityZones']
+      template['Resources'][resource]['Properties']['Subnets'] = VPC_SUBNETS.split(',')
+    elif resource_type == 'AWS::AutoScaling::AutoScalingGroup':
+      template['Resources'][resource]['Properties']['VPCZoneIdentifier'] = VPC_SUBNETS.split(',')
+      template['Resources'][resource]['Properties']['AvailabilityZones'] = VPC_ZONES.split(',')
+
 print json.dumps(template)


Test patch:
Repository: deis/deis

Issue:
`--cluster=dev` no longer the default in CLI
After docstring refactorings, the behavior of `deis create` changed so that `--cluster=dev` is no longer the default if not provided. See http://ci.deis.io/view/pull-requests/job/test-smoke/124/console for an example of this failure caught by the test-smoke job (after I updated the client, which I just regressed to keep the PR pipeline flowing.)



Discussion:

Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -415,7 +415,7 @@ def apps_create(self, args):
 
         Options:
           --cluster=<cluster>
-            target cluster to host application (default: dev).
+            target cluster to host application [default: dev].
           --no-remote
             do not create a `deis` git remote.
         """


Test patch:
Repository: deis/deis

Issue:
deis auth:logout fails when the controller can't be reached
Logout should never really fail - if the controller is inaccessible, we should make sure we're deleting the cookies and then return.

``` console
$ deis auth:logout
Couldn't connect to the Deis Controller. Make sure that the Controller URI is correct and the server is running.
```



Discussion:
We are hitting this error [here](https://github.com/deis/deis/blob/master/client/deis.py#L1539), which is due to [this call](https://github.com/deis/deis/blob/master/client/deis.py#L712). For that to occur, we should remove the `sys.exit(1)` call, and just re-raise the exception so the calling methods can handle the exception.


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -773,7 +773,10 @@ def auth_logout(self, args):
         """
         controller = self._settings.get('controller')
         if controller:
-            self._dispatch('get', '/api/auth/logout/')
+            try:
+                self._dispatch('get', '/api/auth/logout/')
+            except requests.exceptions.ConnectionError:
+                pass
         self._session.cookies.clear()
         self._session.cookies.save()
         self._settings['controller'] = None


Test patch:
Repository: deis/deis

Issue:
deis cluster id rename
Should be good to have this as a functionality eitherwise we need to destroy the cluster and re-create it



Discussion:
For posterity:

```
13:08 < eggmayo> @bacongobbler: is there  any way to rename a cluster id after creation ?
13:28 <@bacongobbler> eggmayo: I don't think so, since it's the primary key in the database.
13:29 <@bacongobbler> we can always refactor that if it needs to be changed
13:29 < eggmayo> ok....i am destroying....maybe a feature to add
13:29 <@bacongobbler> owait, it isn't
13:29 <@carmstrong> shouldn't be an issue at all with renaming a primary key in postgres
13:29 <@carmstrong> unless it confuses django or something
13:29 <@bacongobbler> https://github.com/deis/deis/blob/master/controller/api/models.py#L75
13:29 <@carmstrong> as long as the referential integrity constraints are in tact
13:29 < eggmayo> oh
13:29 <@bacongobbler> Cluster.uuid is the primary key. Looks like we just need to expose it in clusters:update
13:30 < eggmayo> yeah
13:30 < eggmayo> should i open an issue ?
13:30 <@bacongobbler> sure! If you can't update the name through clusters:update then go right ahead :)
13:31 <@bacongobbler> should be a one-liner
13:31 < eggmayo> no you can't
13:31 <@bacongobbler> carmstrong: the constraints will stay intact because they reference the cluster by its UUID. the name is just a placeholder for the user
```

might be more useful to expose an endpoint like `deis cluster:rename <newname> --cluster=<oldname>`

@developerinlondon that's the idea behind this issue

is this due in any of the upcoming releases?

tentatively setting to v0.11.0 to confirm this bug


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1017,11 +1017,13 @@ def clusters_update(self, args):
             a local file path to a SSH private key used to connect to cluster members.
           --type=<type>
             cluster type (default: coreos).
+          --id=<id>
+            the (new) uniquely identifiable name for the cluster.
         """
         cluster = args['<id>']
         body = {}
         for k, arg in (('domain', '--domain'), ('hosts', '--hosts'),
-                       ('auth', '--auth'), ('type', '--type')):
+                       ('auth', '--auth'), ('type', '--type'), ('id', '--id')):
             if k == 'auth' and args.get('--auth') is not None:
                 auth_path = os.path.expanduser(args['--auth'])
                 if not os.path.exists(auth_path):


Test patch:
Repository: deis/deis

Issue:
fix(client): new clusters:update code borked
Testing a fix for #1209 when I ran into this. Looks like if `--auth` is not supplied, the method fails:

```
><> deis clusters:update dev --id=qwerty
Traceback (most recent call last):
  File "/Users/bacongobbler/bin/deis", line 1884, in <module>
    main()
  File "/Users/bacongobbler/bin/deis", line 1880, in main
    _dispatch_cmd(method, args)
  File "/Users/bacongobbler/bin/deis", line 1834, in _dispatch_cmd
    method(args)
  File "/Users/bacongobbler/bin/deis", line 1025, in clusters_update
    auth_path = os.path.expanduser(args['--auth'])
  File "/Users/bacongobbler/venv/bin/../lib/python2.7/posixpath.py", line 261, in expanduser
    if not path.startswith('~'):
AttributeError: 'NoneType' object has no attribute 'startswith'
```

ping @smothiki



Discussion:

Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -1019,7 +1019,7 @@ def clusters_update(self, args):
         body = {}
         for k, arg in (('domain', '--domain'), ('hosts', '--hosts'),
                        ('auth', '--auth'), ('type', '--type')):
-            if k == 'auth' :
+            if k == 'auth' and args.get('--auth') is not None:
                 auth_path = os.path.expanduser(args['--auth'])
                 if not os.path.exists(auth_path):
                     print('Path to authentication credentials does not exist: {}'.format(auth_path))


Test patch:
Repository: deis/deis

Issue:
feat(registry): allow pulling from a specific tag
registry-to-registry transfers currently pull any and all images/tags from the source registry. For bigger repositories such as `registry` [on Dockerhub](https://registry.hub.docker.com/v1/repositories/library/registry/images), there are a _lot_ of images. We should be able to optionally pull from a specific tag to speed up download times.



Discussion:
This and #1404 seem pretty important to developer UX.

https://github.com/deis/docker-registry/pull/1


Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -482,6 +482,11 @@ def new(self, user, config=None, build=None, summary=None, source_version='lates
             tasks.import_repository.delay(build.image, self.app.id).get()
             # update the source image to the repository we just imported
             source_image = self.app.id
+            # if the image imported had a tag specified, use that tag as the source
+            if ':' in build.image:
+                if '/' not in build.image[build.image.rfind(':') + 1:]:
+                    source_image += build.image[build.image.rfind(':'):]
+
         publish_release(source_image,
                         config.values,
                         release_image,)
diff --git a/controller/registry/private.py b/controller/registry/private.py
--- a/controller/registry/private.py
+++ b/controller/registry/private.py
@@ -23,9 +23,11 @@ def publish_release(source, config, target):
     contains the new configuration as ENV entries.
     """
     try:
-        if source.count(':') == 2:
-            src_image = source.rsplit(':', 1)[0].split('/', 1)[1]
-            src_tag = source.split(':')[2]
+        # parse for the tag and the repository
+        if ':' in source:
+            if '/' not in source[source.rfind(':') + 1:]:
+                src_tag = source[source.rfind(':') + 1:]
+                src_image = source[:source.rfind(':')]
         else:
             src_image = source
             src_tag = 'latest'


Test patch:
Repository: deis/deis

Issue:
deis apps:destroy not destroying the app logs 
Steps to reproduce 

```
1) Create an App using deis create 
2) deis apps:logs --app=<appName>
```

the above command should show 204 no content available as we haven't launched the app yet 

```
3) git push deis master
4) deis apps:destroy --app=<appName> 
```

Follow 1 and 2 again , this time deis apps:logs will show some logs from previous push . This is not the expected behavior 



Discussion:
Let's try and address this issue with https://github.com/deis/deis/issues/985

to clarify: this is because we read/write the logs to file inside deis-logger. The controller then reads these files which are mounted into the container whenever you run `apps:logs`.


Resolving patch:
diff --git a/controller/api/models.py b/controller/api/models.py
--- a/controller/api/models.py
+++ b/controller/api/models.py
@@ -139,6 +139,10 @@ def create(self, *args, **kwargs):
     def delete(self, *args, **kwargs):
         for c in self.container_set.all():
             c.destroy()
+        # delete application logs stored by deis/logger
+        path = os.path.join(settings.DEIS_LOG_DIR, self.id + '.log')
+        if os.path.exists(path):
+            os.remove(path)
         return super(App, self).delete(*args, **kwargs)
 
     def deploy(self, release, initial=False):


Test patch:
Repository: deis/deis

Issue:
Cookies permission
Currently `cookies.txt` contains the session ID and CSRF token for communication with the controller. This file is world readable, but should probably only be readable by the current user.



Discussion:
Good point:

``` console
Rhialto:deis matt$ ls -al ~/.deis/cookies.txt 
-rw-r--r--  1 matt  staff   308B Aug 16 04:22 /Users/matt/.deis/cookies.txt
```

It doesn't need to be group- or world-readable.


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -164,6 +164,8 @@ def request(self, *args, **kwargs):
             kwargs['headers'] = {'Referer': url}
         response = super(Session, self).request(*args, **kwargs)
         self.cookies.save()
+        # set ~/.deis/cookies.txt readable only by its owner
+        os.chmod(self.cookies.filename, 0600)
         return response
 
 
@@ -176,8 +178,9 @@ class Settings(dict):
 
     def __init__(self):
         path = os.path.expanduser('~/.deis')
-        if not os.path.exists(path):
-            os.mkdir(path)
+        # Create the $HOME/.deis dir if it doesn't exist
+        if not os.path.isdir(path):
+            os.mkdir(path, 0700)
         self._path = os.path.join(path, 'client.yaml')
         if not os.path.exists(self._path):
             with open(self._path, 'w') as f:


Test patch:
diff --git a/tests/integration_test.go b/tests/integration_test.go
--- a/tests/integration_test.go
+++ b/tests/integration_test.go
@@ -3,6 +3,8 @@
 package tests
 
 import (
+	"os"
+	"os/user"
 	"testing"
 
 	"github.com/deis/deis/tests/utils"
@@ -27,10 +29,25 @@ func TestGlobal(t *testing.T) {
 func cookieTest(t *testing.T, params *utils.DeisTestConfig) {
 	// Regression test for https://github.com/deis/deis/pull/1136
 	// Ensure that cookies are cleared on auth:register and auth:cancel
+	user, err := user.Current()
+	if err != nil {
+		t.Fatal(err)
+	}
+	cookieJar := user.HomeDir + "/.deis/cookies.txt"
 	utils.Execute(t, authRegisterCmd, params, false, "")
-	cmd := "cat ~/.deis/cookies.txt"
+	cmd := "cat " + cookieJar
 	utils.CheckList(t, cmd, params, "csrftoken", false)
 	utils.CheckList(t, cmd, params, "sessionid", false)
+	info, err := os.Stat(cookieJar)
+	if err != nil {
+		t.Fatal(err)
+	}
+	mode := info.Mode().String()
+	expected := "-rw-------"
+	if mode != expected {
+		t.Fatalf("%s has wrong mode:\n   current: %s\n  expected: %s",
+			cookieJar, mode, expected)
+	}
 	utils.AuthCancel(t, params)
 	utils.CheckList(t, cmd, params, "csrftoken", true)
 	utils.CheckList(t, cmd, params, "sessionid", true)
Repository: deis/deis

Issue:
Deis Client doesn't work behind a proxy
The Deis client does not appear to work behind a corporate proxy. I've have set the typical command-line proxy settings and Deis still fails to login. When I try to connect behind the proxy I receive the following error "Couldn't connect to the Deis Controller. Make sure that the Controller URI is correct and the server is running."

Related Information:
- OS: Mac OS X (10.9.4)
- Deis CLI 0.9.0
- proxy variables set: http_proxy; https_proxy; HTTP_PROXY; HTTPS_PROXY



Discussion:
is fleetctl working ?

Yes, I can use fleetctl if I set the FLEETCTL_TUNNEL variable.

Where are you running deis?

I am running Deis on AWS EC2 and accessing it from a corporate network with the Deis CLI.

> I've have set the typical command-line proxy settings and Deis still fails to login.

Where are you setting these? I don't recall the client having any flags or settings to use a proxy. We may need to add proxy logic to `client/deis.py`.

I'm setting the environmental variables above in the terminal. Specifically "export http_proxy=http://proxyurl:80" 


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -84,6 +84,10 @@ def __init__(self):
         cookie_file = os.path.expanduser('~/.deis/cookies.txt')
         cookie_dir = os.path.dirname(cookie_file)
         self.cookies = MozillaCookieJar(cookie_file)
+        self.proxies = {
+            "http": os.getenv("http_proxy"),
+            "https": os.getenv("https_proxy")
+        }
         # Create the $HOME/.deis dir if it doesn't exist
         if not os.path.isdir(cookie_dir):
             os.mkdir(cookie_dir, 0700)


Test patch:
Repository: deis/deis

Issue:
scheduler should bail out when container fails to come up
Right now when a container is booting up, we are waiting for the announcer to come up. however, if the app container fails to come up, the announce container does not. Instead, we should be listening for the app container to come up, and if it fails, bail out appropriately. #1534 is affected by this issue where if the application container fails to come up, the user has to wait for the full timeout before it bails.



Discussion:
Related: #1529 


Resolving patch:
diff --git a/controller/scheduler/coreos.py b/controller/scheduler/coreos.py
--- a/controller/scheduler/coreos.py
+++ b/controller/scheduler/coreos.py
@@ -126,7 +126,7 @@ def start(self, name, use_announcer=True):
 
         if use_announcer:
             self._start_announcer(name, env)
-            self._wait_for_announcer(name, env)
+            self._wait_for_container(name, env)
         else:
             self._log_skipped_announcer('start', name)
 
@@ -145,10 +145,20 @@ def _start_announcer(self, name, env):
             'fleetctl.sh start -no-block {name}-announce.service'.format(**locals()),
             shell=True, env=env)
 
-    def _wait_for_announcer(self, name, env):
+    def _wait_for_container(self, name, env):
         status = None
         # we bump to 20 minutes here to match the timeout on the router and in the app unit files
         for _ in range(1200):
+            # check if the main container's running
+            status = subprocess.check_output(
+                "fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}.service | awk '{{print $2}}'".format(**locals()),  # noqa
+                shell=True, env=env).strip('\n')
+            if status == 'failed':
+                raise RuntimeError('Container failed to start')
+            elif status != 'running':
+                time.sleep(1)
+                continue
+            # wait for the announce service to come up as well
             status = subprocess.check_output(
                 "fleetctl.sh list-units --no-legend --fields unit,sub | grep {name}-announce.service | awk '{{print $2}}'".format(**locals()),  # noqa
                 shell=True, env=env).strip('\n')


Test patch:
Repository: deis/deis

Issue:
`deis open` prepends the app name twice
Running `deis open` in my app took me to `http://folksy-valkyrie.folksy-valkyrie.local.deisapp.com/` (note the double subdomain).

It still rendered, but isn't right.



Discussion:
@carmstrong can you please post a `deis info -a folksy-valkyrie` for me? We might be adding the app name as a subdomain to the `url` field in the client (which ends in the behaviour you describe), but I want to confirm that the `url` field is correct.

@bacongobbler This cluster has long since been destroyed, but it should be easy to recreate - I just created an app and deployed.

@gabrtv saw this issue as well.

can confirm:

```
><> deis open -a uuid
```

> opens browser to http://uuid.uuid.fishworks.io/

```
><> deis info -a uuid
=== uuid Application
{
  "updated": "2014-08-28T05:06:48.660Z", 
  "uuid": "a0ec193b-7597-4e20-983c-357adc117c22", 
  "created": "2014-08-28T05:04:37.341Z", 
  "url": "uuid.fishworks.io", 
  "cluster": "dev", 
  "owner": "bacongobbler", 
  "id": "uuid", 
  "structure": "{\"web\": 1}"
}

=== uuid Processes

--- web: 
web.1 up (v3)
web.2 up (v3)
web.3 up (v3)

=== uuid Domains
No domains
```

Shenanigans, I tell you.

Dang, me too: `http://kingly-daffodil.kingly-daffodil.local.deisapp.com/`

We should `git bisect` and terminate this one with extreme prejudice.


Resolving patch:
diff --git a/client/deis.py b/client/deis.py
--- a/client/deis.py
+++ b/client/deis.py
@@ -582,7 +582,7 @@ def apps_open(self, args):
         if response.status_code == requests.codes.ok:  # @UndefinedVariable
             url = response.json()['url']
             # use the OS's default handler to open this URL
-            webbrowser.open('http://{}.{}/'.format(app, url))
+            webbrowser.open('http://{}/'.format(url))
             return url
         else:
             raise ResponseError(response)


Test patch: