Skip to content

Commit dcfb139

Browse files
committed
fix(controller): revert release.check_image_access for now
1 parent 9b71510 commit dcfb139

12 files changed

Lines changed: 2 additions & 84 deletions

File tree

rootfs/api/models/app.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,8 @@ def deploy(self, release, force_deploy=False, rollback_on_failure=True): # noqa
596596
# create the application config in k8s (secret in this case) for all deploy objects
597597
self.set_application_config(release)
598598
# only buildpack apps need access to object storage
599-
# only docker apps need check access to the image, so users can't exploit the k8s
600-
# image cache to gain access to other users' images
601599
if release.build.type == 'buildpack':
602600
self.create_object_store_secret()
603-
else:
604-
release.check_image_access()
605601

606602
# gather all proc types to be deployed
607603
tasks = [

rootfs/api/models/release.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from django.conf import settings
44
from django.db import models
55

6-
from registry import publish_release, get_port as docker_get_port, check_access as docker_check_access, RegistryException # noqa
6+
from registry import publish_release, get_port as docker_get_port, RegistryException # noqa
77
from api.utils import dict_diff
88
from api.models import UuidAuditedModel
99
from api.exceptions import DryccException, AlreadyExists
@@ -136,13 +136,6 @@ def publish(self):
136136
drycc_registry = bool(self.build.source_based)
137137
publish_release(source_image, self.image, drycc_registry, self.get_registry_auth())
138138

139-
def check_image_access(self):
140-
try:
141-
creds = self.get_registry_auth()
142-
docker_check_access(self.image, creds)
143-
except Exception as e:
144-
raise DryccException(str(e)) from e
145-
146139
def get_port(self):
147140
"""
148141
Get application port for a given release. If pulling from private registry

rootfs/api/tests/test_app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ def _mock_run(*args, **kwargs):
3535
@requests_mock.Mocker(real_http=True, adapter=adapter)
3636
@mock.patch('api.models.release.publish_release', lambda *args: None)
3737
@mock.patch('api.models.release.docker_get_port', mock_port)
38-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
3938
class AppTest(DryccTestCase):
4039
"""Tests creation of applications"""
4140

rootfs/api/tests/test_build.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
@requests_mock.Mocker(real_http=True, adapter=adapter)
2424
@mock.patch('api.models.release.publish_release', lambda *args: None)
2525
@mock.patch('api.models.release.docker_get_port', mock_port)
26-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
2726
class BuildTest(DryccTransactionTestCase):
2827

2928
"""Tests build notification from build system"""
@@ -603,44 +602,6 @@ def test_build_image_in_registry_with_auth(self, mock_requests):
603602
response = self.client.post(url, body)
604603
self.assertEqual(response.status_code, 201, response.data)
605604

606-
def test_build_image_no_registry_password(self, mock_requests):
607-
"""build with image from private registry, but no password given"""
608-
app_id = self.create_app()
609-
610-
# post an image as a build
611-
with mock.patch('api.models.release.docker_check_access') as mock_check_access:
612-
mock_check_access.side_effect = Exception('no no no') # let the image access fail
613-
url = "/v2/apps/{app_id}/builds".format(**locals())
614-
image = 'autotest/example'
615-
response = self.client.post(url, {'image': image, 'stack': 'container'})
616-
self.assertEqual(response.status_code, 400, response.data)
617-
618-
def test_build_image_wrong_registry_password(self, mock_requests):
619-
"""build with image from private registry, but wrong password given"""
620-
app_id = self.create_app()
621-
622-
# post an image as a build using registry hostname
623-
url = "/v2/apps/{app_id}/builds".format(**locals())
624-
image = 'autotest/example'
625-
response = self.client.post(url, {'image': image, 'stack': 'container'})
626-
self.assertEqual(response.status_code, 201, response.data)
627-
628-
# add the required PORT information
629-
url = '/v2/apps/{app_id}/config'.format(**locals())
630-
body = {'values': json.dumps({'PORT': '80'})}
631-
response = self.client.post(url, body)
632-
self.assertEqual(response.status_code, 201, response.data)
633-
634-
# set some registry information
635-
with mock.patch('api.models.release.docker_check_access') as mock_check_access:
636-
mock_check_access.side_effect = Exception('no no no') # let the image access fail
637-
url = '/v2/apps/{app_id}/config'.format(**locals())
638-
body = {'registry': json.dumps({'username': 'bob', 'password': 'zoomzoom'})}
639-
response = self.client.post(url, body)
640-
self.assertEqual(response.status_code, 400, response.data)
641-
mock_check_access.assert_called_with(
642-
image, {'username': 'bob', 'password': 'zoomzoom', 'email': 'autotest@drycc.cc'})
643-
644605
def test_build_image_in_registry_with_auth_no_port(self, mock_requests):
645606
"""add authentication to the build but with no PORT config"""
646607
app_id = self.create_app()

rootfs/api/tests/test_config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
@requests_mock.Mocker(real_http=True, adapter=adapter)
2222
@mock.patch('api.models.release.publish_release', lambda *args: None)
2323
@mock.patch('api.models.release.docker_get_port', mock_port)
24-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
2524
class ConfigTest(DryccTransactionTestCase):
2625
"""Tests setting and updating config values"""
2726

rootfs/api/tests/test_healthchecks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
@requests_mock.Mocker(real_http=True, adapter=adapter)
1414
@mock.patch('api.models.release.publish_release', lambda *args: None)
1515
@mock.patch('api.models.release.docker_get_port', mock_port)
16-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
1716
class TestHealthchecks(DryccTransactionTestCase):
1817
"""Tests setting and updating config values"""
1918

rootfs/api/tests/test_hooks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
@requests_mock.Mocker(real_http=True, adapter=adapter)
5151
@mock.patch('api.models.release.publish_release', lambda *args: None)
5252
@mock.patch('api.models.release.docker_get_port', mock_port)
53-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
5453
class HookTest(DryccTransactionTestCase):
5554

5655
"""Tests API hooks used to trigger actions from external components"""

rootfs/api/tests/test_pods.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
@requests_mock.Mocker(real_http=True, adapter=adapter)
2222
@mock.patch('api.models.release.publish_release', lambda *args: None)
2323
@mock.patch('api.models.release.docker_get_port', mock_port)
24-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
2524
class PodTest(DryccTransactionTestCase):
2625
"""Tests creation of pods on nodes"""
2726

rootfs/api/tests/test_registry.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
import requests_mock
3-
from unittest import mock
43

54
from django.core.cache import cache
65
from django.contrib.auth.models import User
@@ -135,13 +134,3 @@ def test_registry_deploy(self, mock_requests):
135134
self.assertIn('password', response.data['registry'])
136135
self.assertEqual(response.data['registry']['username'], 'bob')
137136
self.assertEqual(response.data['registry']['password'], 's3cur3pw1')
138-
139-
# post a new build
140-
with mock.patch('api.models.release.docker_check_access') as mock_check_access:
141-
url = "/v2/apps/{app_id}/builds".format(**locals())
142-
body = {'image': 'autotest/example', 'stack': 'container'}
143-
response = self.client.post(url, body)
144-
self.assertEqual(response.status_code, 201, response.data)
145-
mock_check_access.assert_called_with(
146-
'autotest/example',
147-
{'password': 's3cur3pw1', 'username': 'bob', 'email': 'autotest@drycc.cc'})

rootfs/api/tests/test_release.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
@requests_mock.Mocker(real_http=True, adapter=adapter)
2222
@mock.patch('api.models.release.publish_release', lambda *args: None)
2323
@mock.patch('api.models.release.docker_get_port', mock_port)
24-
@mock.patch('api.models.release.docker_check_access', lambda *args: None)
2524
class ReleaseTest(DryccTransactionTestCase):
2625

2726
"""Tests push notification from build system"""

0 commit comments

Comments
 (0)