Skip to content

Commit 726d263

Browse files
author
lijianguo
committed
Merge remote-tracking branch 'upstream/master'
2 parents d51fe43 + fd50adf commit 726d263

9 files changed

Lines changed: 40 additions & 33 deletions

File tree

charts/controller/templates/controller-deployment.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,16 @@ spec:
128128
secretKeyRef:
129129
name: database-creds
130130
key: password
131-
- name: RESERVED_NAMES
132-
value: "drycc, drycc-builder, drycc-monitor-grafana"
133131
- name: WORKFLOW_NAMESPACE
134132
valueFrom:
135133
fieldRef:
136134
fieldPath: metadata.namespace
137135
- name: DRYCC_NSQD_ADDRS
138136
value: "{{range $i := until $nsqdNodeCount}}drycc-nsqd-{{$i}}.drycc-nsqd.{{ $.Release.Namespace }}.svc.cluster.local:{{$.Values.nsqd.tcp_port}}{{if lt (add 1 $i) $nsqdNodeCount}},{{end}}{{end}}"
137+
{{- range $key, $value := .Values.environment }}
138+
- name: {{ $key }}
139+
value: {{ $value | quote }}
140+
{{- end }}
139141
volumeMounts:
140142
- mountPath: /etc/slugrunner
141143
name: slugrunner-config

charts/controller/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ k8s_api_verify_tls: "true"
1919
# Set storageClassName, It is used for application mount.
2020
app_storage_class: ""
2121

22+
# Any custom controller environment variables
23+
# can be specified as key-value pairs under environment
24+
# this is usually a non required setting.
25+
environment:
26+
RESERVED_NAMES: "drycc, drycc-builder, drycc-monitor-grafana"
27+
2228
nsqd:
2329
replicas: 1
2430
tcp_port: 4150

rootfs/api/models/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from api.models.tls import TLS
2727
from api.models.appsettings import AppSettings
2828
from api.models.volume import Volume
29-
from api.utils import generate_app_name, async_run
29+
from api.utils import generate_app_name, apply_tasks
3030
from scheduler import KubeHTTPException, KubeException
3131

3232
logger = logging.getLogger(__name__)
@@ -383,7 +383,7 @@ def restart(self, **kwargs): # noqa
383383
) for pod in self.list_pods(**kwargs)
384384
]
385385

386-
async_run(tasks)
386+
apply_tasks(tasks)
387387
except Exception as e:
388388
err = "warning, some pods failed to stop:\n{}".format(str(e))
389389
self.log(err, logging.WARNING)
@@ -528,7 +528,7 @@ def _scale_pods(self, scale_types):
528528
# create the application config in k8s (secret in this case) for all deploy objects
529529
self.set_application_config(release)
530530

531-
async_run(tasks)
531+
apply_tasks(tasks)
532532
except Exception as e:
533533
err = '(scale): {}'.format(e)
534534
self.log(err, logging.ERROR)
@@ -619,7 +619,7 @@ def deploy(self, release, force_deploy=False, rollback_on_failure=True): # noqa
619619
]
620620

621621
try:
622-
async_run(tasks)
622+
apply_tasks(tasks)
623623
except KubeException as e:
624624
# Don't rollback if the previous release doesn't have a build which means
625625
# this is the first build and all the previous releases are just config changes.

rootfs/api/settings/production.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@
412412
LDAP_USER_FILTER = os.environ.get('LDAP_USER_FILTER', 'username')
413413
LDAP_GROUP_BASEDN = os.environ.get('LDAP_GROUP_BASEDN', '')
414414
LDAP_GROUP_FILTER = os.environ.get('LDAP_GROUP_FILTER', '')
415+
LDAP_ACTIVE_GROUP = os.environ.get('LDAP_ACTIVE_GROUP', '')
416+
LDAP_STAFF_GROUP = os.environ.get('LDAP_STAFF_GROUP', '')
417+
LDAP_SUPERUSER_GROUP = os.environ.get('LDAP_SUPERUSER_GROUP', '')
415418

416419
# Django LDAP backend configuration.
417420
# See https://pythonhosted.org/django-auth-ldap/reference.html
@@ -435,6 +438,11 @@
435438
scope=ldap.SCOPE_SUBTREE,
436439
filterstr="(%s)" % LDAP_GROUP_FILTER
437440
)
441+
AUTH_LDAP_USER_FLAGS_BY_GROUP = {
442+
'is_active': LDAP_ACTIVE_GROUP,
443+
'is_staff': LDAP_STAFF_GROUP,
444+
'is_superuser': LDAP_SUPERUSER_GROUP,
445+
}
438446
AUTH_LDAP_GROUP_TYPE = GroupOfNamesType()
439447
AUTH_LDAP_USER_ATTR_MAP = {
440448
"first_name": "givenName",

rootfs/api/utils.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Helper functions used by the Drycc server.
33
"""
4-
import asyncio
54
import base64
65
import concurrent
76
import hashlib
@@ -145,43 +144,22 @@ def dict_merge(origin, merge):
145144
return result
146145

147146

148-
def async_run(tasks):
147+
def apply_tasks(tasks):
149148
"""
150149
run a group of tasks async
151150
Requires the tasks arg to be a list of functools.partial()
152151
"""
153152
if not tasks:
154153
return
155154

156-
# start a new async event loop
157-
loop = asyncio.get_event_loop()
158-
# https://github.com/python/asyncio/issues/258
159155
executor = concurrent.futures.ThreadPoolExecutor(5)
160-
loop.set_default_executor(executor)
161-
162-
async_tasks = [asyncio.ensure_future(async_task(task, loop)) for task in tasks]
163-
# run tasks in parallel
164-
loop.run_until_complete(asyncio.wait(async_tasks))
165-
# deal with errors (exceptions, etc)
166-
for task in async_tasks:
167-
error = task.exception()
156+
for future in [executor.submit(task) for task in tasks]:
157+
error = future.exception()
168158
if error is not None:
169159
raise error
170-
171160
executor.shutdown(wait=True)
172161

173162

174-
async def async_task(params, loop):
175-
"""
176-
Perform a task asynchronously.
177-
"""
178-
# get the calling function
179-
logger.debug('Running {}'.format(params))
180-
# This executes a task in its own thread (in parallel)
181-
await loop.run_in_executor(None, params)
182-
logger.debug('Finished running {}'.format(params))
183-
184-
185163
if __name__ == "__main__":
186164
import doctest
187165
doctest.testmod()

rootfs/bin/boot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ python /app/manage.py migrate --noinput
3030
# spawn a gunicorn server in the background
3131
echo ""
3232
echo "Starting up Gunicorn"
33-
gunicorn -c /app/drycc/gunicorn/config.py api.wsgi &
33+
gunicorn -c /app/drycc/gunicorn/config.py drycc.gunicorn.wsgi &
3434

3535
echo ""
3636
echo "Loading database information to Kubernetes in the background"

rootfs/drycc/gunicorn/wsgi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from tornado.wsgi import WSGIContainer
2+
3+
4+
from api.wsgi import application as handler
5+
6+
7+
application = WSGIContainer(handler)

rootfs/drycc/wsgi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from tornado.wsgi import WSGIContainer
2+
3+
4+
from api.wsgi import application as handler
5+
6+
7+
application = WSGIContainer(handler)

rootfs/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ morph==0.1.4
1515
ndg-httpsclient==0.5.1
1616
packaging==20.4
1717
pyasn1==0.4.8
18-
tornado==5.1.1
1918
pynsq==0.9.0
2019
psycopg2-binary==2.8.5
2120
pyldap==3.0.0.post1

0 commit comments

Comments
 (0)