Skip to content

Commit bed17a7

Browse files
committed
feat(django): upgrade django framework and deps
- upgrading django to 2.2.19 and djangorestframework to 3.12.2 - resolving all failing tests due to above upgrade - upgrade models to default `on_delete=models.CASCADE` if app or user are deleted - upgrade all other dependencies to latest versions - update Makefile to use hephy/shell-dev for tests - update Dockefile to use python3 -m pip commands - upgrade pip, setuptools, wheel using python3 command Signed-off-by: Cryptophobia <aouzounov@gmail.com>
1 parent 0312315 commit bed17a7

7 files changed

Lines changed: 62 additions & 54 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SHORT_NAME ?= $(COMPONENT)
66

77
include versioning.mk
88

9-
SHELLCHECK_PREFIX := docker run -v ${CURDIR}:/workdir -w /workdir quay.io/deis/shell-dev shellcheck
9+
SHELLCHECK_PREFIX := docker run -v ${CURDIR}:/workdir -w /workdir hephy/shell-dev shellcheck
1010
SHELL_SCRIPTS = $(wildcard rootfs/bin/*) $(shell find "rootfs" -name '*.sh') $(wildcard _scripts/*.sh)
1111

1212
# Test processes used in quick unit testing

rootfs/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ RUN buildDeps='gcc libffi-dev libpq-dev libldap2-dev libsasl2-dev python3-dev py
2121
# cryptography package needs pkg_resources
2222
python3-pkg-resources && \
2323
ln -s /usr/bin/python3 /usr/bin/python && \
24+
# use python3 to upgrade pip and tools
25+
python3 -m pip install --upgrade --no-cache-dir \
26+
pip \
27+
setuptools \
28+
wheel && \
2429
mkdir -p /configs && chown -R deis:deis /configs && \
25-
pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt && \
30+
python3 -m pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt && \
2631
# cleanup
2732
apt-get purge -y --auto-remove $buildDeps && \
2833
apt-get autoremove -y && \

rootfs/Dockerfile.test

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ RUN buildDeps='gcc libffi-dev libpq-dev libldap2-dev libsasl2-dev python3-dev py
1818
libpq5 \
1919
libldap-2.4 \
2020
python3-minimal \
21-
# cryptography package needs pkg_resources
22-
python3-pkg-resources && \
21+
python3-distutils \
22+
# cryptography package needs pkg_resources
23+
python3-pkg-resources && \
2324
ln -s /usr/bin/python3 /usr/bin/python && \
25+
# use python3 to upgrade pip and tools
26+
python3 -m pip install --upgrade --no-cache-dir \
27+
pip \
28+
setuptools \
29+
wheel && \
2430
mkdir -p /configs && chown -R deis:deis /configs && \
25-
pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt && \
31+
python3 -m pip install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt && \
2632
# cleanup
2733
apt-get purge -y --auto-remove $buildDeps && \
2834
apt-get autoremove -y && \
@@ -54,10 +60,7 @@ RUN apt-get update && \
5460
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
5561
git \
5662
postgresql \
57-
postgresql-contrib \
58-
python3-pip \
59-
python3-setuptools \
60-
python3-wheel && \
63+
postgresql-contrib && \
6164
pip3 install --disable-pip-version-check --no-cache-dir -r dev_requirements.txt && \
6265
sudo -u postgres -E $PGBIN/initdb
6366

rootfs/api/migrations/0001_initial.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Migration(migrations.Migration):
2222
('updated', models.DateTimeField(auto_now=True)),
2323
('id', models.SlugField(max_length=24, unique=True, null=True, validators=[api.models.validate_app_id, api.models.validate_reserved_names])),
2424
('structure', jsonfield.fields.JSONField(default={}, blank=True, validators=[api.models.validate_app_structure])),
25-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
25+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
2626
],
2727
options={
2828
'permissions': (('use_app', 'Can use app'),),
@@ -39,8 +39,8 @@ class Migration(migrations.Migration):
3939
('sha', models.CharField(max_length=40, blank=True)),
4040
('procfile', jsonfield.fields.JSONField(default={}, blank=True)),
4141
('dockerfile', models.TextField(blank=True)),
42-
('app', models.ForeignKey(to='api.App')),
43-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
42+
('app', models.ForeignKey(to='api.App', on_delete=models.CASCADE)),
43+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
4444
],
4545
options={
4646
'ordering': ['-created'],
@@ -58,7 +58,7 @@ class Migration(migrations.Migration):
5858
('key', models.TextField()),
5959
('common_name', models.TextField(unique=True)),
6060
('expires', models.DateTimeField()),
61-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
61+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
6262
],
6363
options={
6464
'abstract': False,
@@ -75,8 +75,8 @@ class Migration(migrations.Migration):
7575
('memory', jsonfield.fields.JSONField(default={}, blank=True)),
7676
('cpu', jsonfield.fields.JSONField(default={}, blank=True)),
7777
('tags', jsonfield.fields.JSONField(default={}, blank=True)),
78-
('app', models.ForeignKey(to='api.App')),
79-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
78+
('app', models.ForeignKey(to='api.App', on_delete=models.CASCADE)),
79+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
8080
],
8181
options={
8282
'ordering': ['-created'],
@@ -92,8 +92,8 @@ class Migration(migrations.Migration):
9292
('updated', models.DateTimeField(auto_now=True)),
9393
('type', models.CharField(max_length=128)),
9494
('num', models.PositiveIntegerField()),
95-
('app', models.ForeignKey(to='api.App')),
96-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
95+
('app', models.ForeignKey(to='api.App', on_delete=models.CASCADE)),
96+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
9797
],
9898
options={
9999
'ordering': ['created'],
@@ -108,8 +108,8 @@ class Migration(migrations.Migration):
108108
('created', models.DateTimeField(auto_now_add=True)),
109109
('updated', models.DateTimeField(auto_now=True)),
110110
('domain', models.TextField(unique=True)),
111-
('app', models.ForeignKey(to='api.App')),
112-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
111+
('app', models.ForeignKey(to='api.App', on_delete=models.CASCADE)),
112+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
113113
],
114114
options={
115115
'abstract': False,
@@ -125,7 +125,7 @@ class Migration(migrations.Migration):
125125
('id', models.CharField(max_length=128)),
126126
('public', models.TextField(unique=True, validators=[api.models.validate_base64])),
127127
('fingerprint', models.CharField(max_length=128)),
128-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
128+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
129129
],
130130
options={
131131
'verbose_name': 'SSH Key',
@@ -144,8 +144,8 @@ class Migration(migrations.Migration):
144144
('receive_repo', models.CharField(max_length=255)),
145145
('ssh_connection', models.CharField(max_length=255)),
146146
('ssh_original_command', models.CharField(max_length=255)),
147-
('app', models.ForeignKey(to='api.App')),
148-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
147+
('app', models.ForeignKey(to='api.App', on_delete=models.CASCADE)),
148+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
149149
],
150150
options={
151151
'ordering': ['-created'],
@@ -161,10 +161,10 @@ class Migration(migrations.Migration):
161161
('updated', models.DateTimeField(auto_now=True)),
162162
('version', models.PositiveIntegerField()),
163163
('summary', models.TextField(null=True, blank=True)),
164-
('app', models.ForeignKey(to='api.App')),
165-
('build', models.ForeignKey(to='api.Build', null=True)),
166-
('config', models.ForeignKey(to='api.Config')),
167-
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
164+
('app', models.ForeignKey(to='api.App', on_delete=models.CASCADE)),
165+
('build', models.ForeignKey(to='api.Build', null=True, on_delete=models.CASCADE)),
166+
('config', models.ForeignKey(to='api.Config', on_delete=models.CASCADE)),
167+
('owner', models.ForeignKey(to=settings.AUTH_USER_MODEL, on_delete=models.CASCADE)),
168168
],
169169
options={
170170
'ordering': ['-created'],
@@ -187,7 +187,7 @@ class Migration(migrations.Migration):
187187
migrations.AddField(
188188
model_name='container',
189189
name='release',
190-
field=models.ForeignKey(to='api.Release'),
190+
field=models.ForeignKey(to='api.Release', on_delete=models.CASCADE),
191191
preserve_default=True,
192192
),
193193
migrations.AlterUniqueTogether(

rootfs/api/models/certificate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ def save(self, *args, **kwargs):
148148
subject = certificate.get_subject().get_components()
149149
self.subject = '/' + '/'.join('%s=%s' % (key.decode(encoding='UTF-8'), value.decode(encoding='UTF-8')) for key, value in subject) # noqa
150150

151-
# public fingerprint of certificate
152-
self.fingerprint = certificate.digest('sha256')
151+
# public fingerprint of certificate - need to decode to UTF-8 in django 2.2
152+
self.fingerprint = certificate.digest('sha256').decode(encoding='UTF-8')
153153

154154
# SubjectAltName from the certificate - return a list
155155
self.san = get_subj_alt_name(certificate)

rootfs/dev_requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Run "make test-unit" for the % of code exercised during tests
2-
coverage==4.4.1
2+
coverage==4.5.4
33

44
# Run "make test-style" to check python syntax and style
55
flake8==3.4.1
66

7-
# code coverage report at https://codecov.io/github/deis/controller
8-
codecov==2.0.9
7+
# code coverage report at https://codecov.io/github/teamhephy/controller
8+
codecov==2.1.11
99

1010
# mock out python-requests, mostly k8s
1111
# requests-mock==1.3.0
12-
git+https://github.com/deisthree/requests-mock.git@class_adapter#egg=request_mock
12+
git+https://github.com/teamhephy/requests-mock.git@class_adapter#egg=requests_mock
1313

1414
# tail a log and pipe into tbgrep to find all tracebacks
1515
tbgrep==0.3.0

rootfs/requirements.txt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Deis controller requirements
2-
backoff==1.4.3
3-
django==1.11.29
4-
django-auth-ldap==1.2.15
5-
django-cors-middleware==1.3.1
6-
django-guardian==1.4.9
7-
djangorestframework==3.9.4
2+
backoff>=1.8.0
3+
django>=2.2.19,<3.0
4+
django-auth-ldap>=2.3.0,<3.0
5+
django-cors-middleware>=1.5.0
6+
django-guardian>=2.3.0
7+
djangorestframework>=3.12.2,<4.0
88
docker-py==1.10.6
9-
gunicorn==19.7.1
10-
idna==2.6
11-
jmespath==0.9.3
12-
jsonfield==2.0.2
13-
jsonschema==2.6.0
14-
morph==0.1.2
15-
ndg-httpsclient==0.4.2
16-
packaging==16.8
17-
pyasn1==0.3.2
18-
psycopg2-binary==2.7.5
19-
pyldap==2.4.37
20-
pyOpenSSL==17.5.0
21-
pytz==2017.2
22-
requests==2.20.0
23-
requests-toolbelt==0.8.0
9+
gunicorn>=20.0.4
10+
idna>=2.6
11+
jmespath>=0.10.0
12+
jsonfield>=3.1.0
13+
jsonschema>=3.2.0
14+
morph==0.1.4
15+
ndg-httpsclient==0.5.1
16+
packaging==20.0
17+
pyasn1==0.3.7
18+
psycopg2-binary==2.8.6
19+
pyldap==3.0.0
20+
pyOpenSSL>=20.0.1
21+
pytz>=2021.1
22+
requests>=2.25.1
23+
requests-toolbelt>=0.9.1

0 commit comments

Comments
 (0)