Skip to content

Commit 2f167e9

Browse files
Matthewmboersma
authored andcommitted
ref(controller): clean up scheduler code
SSH_PRIVATE_KEY was something we relied on for the fleet scheduler. We no longer require an ssh key so we can remove it. The same logic applies for the --disable-swap option flag.
1 parent b683ba9 commit 2f167e9

6 files changed

Lines changed: 8 additions & 50 deletions

File tree

rootfs/api/models.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,9 @@ class Meta:
179179
@property
180180
def _scheduler(self):
181181
mod = importlib.import_module(settings.SCHEDULER_MODULE)
182-
return mod.SchedulerClient(settings.SCHEDULER_TARGET,
182+
return mod.SchedulerClient(settings.SCHEDULER_URL,
183183
settings.SCHEDULER_AUTH,
184-
settings.SCHEDULER_OPTIONS,
185-
settings.SSH_PRIVATE_KEY)
184+
settings.SCHEDULER_OPTIONS)
186185

187186
def __str__(self):
188187
return self.id
@@ -542,10 +541,6 @@ def logs(self, log_lines=str(settings.LOG_LINES)):
542541

543542
def run(self, user, command):
544543
"""Run a one-off command in an ephemeral app container."""
545-
# FIXME: remove the need for SSH private keys by using
546-
# a scheduler that supports one-off admin tasks natively
547-
if not settings.SSH_PRIVATE_KEY:
548-
raise EnvironmentError('Support for admin commands is not configured')
549544
if self.release_set.latest().build is None:
550545
raise EnvironmentError('No build associated with this release to run this command')
551546
# TODO: add support for interactive shell

rootfs/api/tests/test_app.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -245,25 +245,6 @@ def test_admin_can_see_other_apps(self):
245245
response = self.client.get(url, HTTP_AUTHORIZATION='token {}'.format(self.token))
246246
self.assertEqual(response.data['count'], 1)
247247

248-
def test_run_without_auth(self):
249-
"""If the administrator has not provided SSH private key for run commands,
250-
make sure a friendly error message is provided on run"""
251-
settings.SSH_PRIVATE_KEY = ''
252-
url = '/v1/apps'
253-
body = {'id': 'autotest'}
254-
response = self.client.post(url, json.dumps(body), content_type='application/json',
255-
HTTP_AUTHORIZATION='token {}'.format(self.token))
256-
self.assertEqual(response.status_code, 201)
257-
app_id = response.data['id'] # noqa
258-
# test run
259-
url = '/v1/apps/{app_id}/run'.format(**locals())
260-
body = {'command': 'ls -al'}
261-
response = self.client.post(url, json.dumps(body), content_type='application/json',
262-
HTTP_AUTHORIZATION='token {}'.format(self.token))
263-
self.assertEquals(response.status_code, 400)
264-
self.assertEquals(response.data, {'detail': 'Support for admin commands '
265-
'is not configured'})
266-
267248
def test_run_without_release_should_error(self):
268249
"""
269250
A user should not be able to run a one-off command unless a release

rootfs/deis/settings.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from __future__ import unicode_literals
66
import os.path
77
import random
8-
import semantic_version as semver
98
import string
109
import sys
1110
import tempfile
@@ -87,9 +86,6 @@
8786
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
8887
)
8988

90-
# Make this unique, and don't share it with anybody.
91-
SECRET_KEY = None # @UnusedVariable
92-
9389
# List of callables that know how to import templates from various sources.
9490
TEMPLATE_LOADERS = (
9591
'django.template.loaders.filesystem.Loader',
@@ -300,12 +296,11 @@
300296

301297
# default scheduler settings
302298
SCHEDULER_MODULE = 'scheduler.mock'
303-
SCHEDULER_TARGET = '' # path to scheduler endpoint (e.g. /var/run/fleet.sock)
304-
SCHEDULER_AUTH = ''
305-
SCHEDULER_OPTIONS = {}
299+
SCHEDULER_URL = 'localhost'
300+
SCHEDULER_AUTH = None
301+
SCHEDULER_OPTIONS = None
306302

307303
# security keys and auth tokens
308-
SSH_PRIVATE_KEY = '' # used for SSH connections to facilitate "deis run"
309304
SECRET_KEY = os.environ.get('DEIS_SECRET_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi')
310305
BUILDER_KEY = os.environ.get('DEIS_BUILDER_KEY', 'CHANGEME_sapm$s%upvsw5l_zuy_&29rkywd^78ff(qi')
311306

@@ -374,17 +369,6 @@
374369
sys.path.append('/templates')
375370
from confd_settings import * # noqa
376371

377-
# Disable swap when mem limits are set, unless Docker is too old
378-
DISABLE_SWAP = '--memory-swap=-1'
379-
try:
380-
version = 'unknown'
381-
from registry.dockerclient import DockerClient
382-
version = DockerClient().client.version().get('Version')
383-
if not semver.validate(version) or semver.Version(version) < semver.Version('1.5.0'):
384-
DISABLE_SWAP = ''
385-
except:
386-
print("Not disabling --memory-swap for Docker version {}".format(version))
387-
388372
# LDAP Backend Configuration
389373
# Should be always after the confd_settings import.
390374
LDAP_USER_SEARCH = LDAPSearch(

rootfs/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ psycopg2==2.6.1
1616
python-etcd==0.3.2
1717
python-ldap==2.4.19
1818
PyYAML==3.11
19-
semantic_version==2.4.2
2019
simpleflock==0.0.2
2120
South==1.0.2
2221
static==1.1.1

rootfs/scheduler/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ class AbstractSchedulerClient(object):
44
A generic interface to a scheduler backend.
55
"""
66

7-
def __init__(self, target, auth, options, pkey):
7+
def __init__(self, target, auth, options):
88
self.target = target
99
self.auth = auth
1010
self.options = options
11-
self.pkey = pkey
1211

1312
def create(self, name, image, command, **kwargs):
1413
"""Create a new container."""

rootfs/scheduler/k8s.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@
100100

101101
class KubeHTTPClient(AbstractSchedulerClient):
102102

103-
def __init__(self, target, auth, options, pkey):
104-
super(KubeHTTPClient, self).__init__(target, auth, options, pkey)
103+
def __init__(self, target, auth, options):
104+
super(KubeHTTPClient, self).__init__(target, auth, options)
105105
self.url = settings.SCHEDULER_URL
106106
self.registry = settings.REGISTRY_URL
107107
self.apiversion = "v1"

0 commit comments

Comments
 (0)