Skip to content

Commit 73a37e6

Browse files
committed
ref(registry): prepend registry url on images up in Release model
Removes the need for Deis registry url being known by the scheduler
1 parent 79d8d81 commit 73a37e6

2 files changed

Lines changed: 15 additions & 20 deletions

File tree

rootfs/api/models/release.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def image(self):
4848
if not self.build.dockerfile:
4949
# Deis Pull
5050
if not self.build.sha:
51-
return '{}:v{}'.format(self.app.id, str(self.version))
51+
return '{}/{}:v{}'.format(settings.REGISTRY_URL, self.app.id, str(self.version))
5252

53-
# Build Pack
53+
# Build Pack - Registry URL not prepended since slugrunner image will download slug
5454
return self.build.image
5555

5656
# DockerFile
57-
return '{}:git-{}'.format(self.app.id, str(self.build.sha))
57+
return '{}/{}:git-{}'.format(settings.REGISTRY_URL, self.app.id, str(self.build.sha))
5858

5959
def new(self, user, config, build, summary=None, source_version='latest'):
6060
"""

rootfs/scheduler/__init__.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@
3232
"containers": [
3333
{
3434
"name": "$id",
35-
"image": "$slugimage",
35+
"image": "$image",
3636
"env": [
3737
{
3838
"name":"PORT",
3939
"value":"5000"
4040
},
4141
{
4242
"name":"SLUG_URL",
43-
"value":"$image"
43+
"value":"$slug_url"
4444
},
4545
{
4646
"name": "BUILDER_STORAGE",
@@ -190,7 +190,7 @@
190190
"containers": [
191191
{
192192
"name": "$containername",
193-
"image": "$slugimage",
193+
"image": "$image",
194194
"imagePullPolicy": "$image_pull_policy",
195195
"env": [
196196
{
@@ -199,7 +199,7 @@
199199
},
200200
{
201201
"name":"SLUG_URL",
202-
"value":"$image"
202+
"value":"$slug_url"
203203
},
204204
{
205205
"name":"DEIS_APP",
@@ -327,7 +327,6 @@ class KubeHTTPClient(object):
327327

328328
def __init__(self):
329329
self.url = settings.SCHEDULER_URL
330-
self.registry = settings.REGISTRY_URL
331330

332331
with open('/var/run/secrets/kubernetes.io/serviceaccount/token') as token_file:
333332
token = token_file.read()
@@ -530,23 +529,21 @@ def run(self, namespace, name, image, entrypoint, command, **kwargs):
530529
name, image, entrypoint, command)
531530
)
532531

533-
imgurl = self.registry + '/' + image
534532
POD = POD_TEMPLATE
535-
536533
l = {
537534
'id': name,
538535
'version': self.apiversion,
539-
'image': imgurl,
536+
'image': image,
540537
'image_pull_policy': settings.DOCKER_BUILDER_IMAGE_PULL_POLICY,
541538
'storagetype': os.getenv("APP_STORAGE"),
542539
'terminationGracePeriodSeconds': settings.KUBERNETES_POD_TERMINATION_GRACE_PERIOD_SECONDS # noqa
543540
}
544541

545542
if entrypoint == '/runner/init':
546543
POD = POD_BTEMPLATE
547-
l["image"] = image
544+
l["slug_url"] = image
548545
l['image_pull_policy'] = settings.SLUG_BUILDER_IMAGE_PULL_POLICY
549-
l["slugimage"] = settings.SLUGRUNNER_IMAGE
546+
l["image"] = settings.SLUGRUNNER_IMAGE
550547
l["mHost"] = os.getenv("DEIS_MINIO_SERVICE_HOST")
551548
l["mPort"] = os.getenv("DEIS_MINIO_SERVICE_PORT")
552549

@@ -704,12 +701,11 @@ def resolve_state(self, pod):
704701
@retry(stop_max_attempt_number=3, wait_fixed=1000)
705702
def _get_port(self, image):
706703
# try thrice to find the port before raising exception as docker-py is flaky
707-
imagepath = self.registry + '/' + image
708-
repo = imagepath.split(":")
704+
repo = image.split(":")
709705
# image already includes the tag, so we split it out here
710706
docker_cli = Client(version="auto")
711707
docker_cli.pull(repo[0]+":"+repo[1], tag=repo[2], insecure_registry=True)
712-
image_info = docker_cli.inspect_image(imagepath)
708+
image_info = docker_cli.inspect_image(image)
713709
if 'ExposedPorts' not in image_info['Config']:
714710
return None
715711
port = int(list(image_info['Config']['ExposedPorts'].keys())[0].split("/")[0])
@@ -995,7 +991,6 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
995991
app_type = kwargs.get('app_type')
996992
container_name = namespace + '-' + app_type
997993
args = command.split()
998-
imgurl = self.registry + "/" + image
999994
storageType = os.getenv("APP_STORAGE")
1000995
TEMPLATE = RCD_TEMPLATE
1001996

@@ -1004,7 +999,7 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
1004999
"id": namespace,
10051000
"appversion": kwargs.get("version"),
10061001
"version": self.apiversion,
1007-
"image": imgurl,
1002+
"image": image,
10081003
'image_pull_policy': settings.DOCKER_BUILDER_IMAGE_PULL_POLICY,
10091004
"replicas": kwargs.get("replicas", 0),
10101005
"containername": container_name,
@@ -1024,9 +1019,9 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
10241019
secret = self._get_secret('deis', 'objectstorage-keyfile').json()
10251020
self._create_secret(namespace, 'objectstorage-keyfile', secret['data'])
10261021

1027-
l["image"] = image
1022+
l["slug_url"] = image
10281023
l['image_pull_policy'] = settings.SLUG_BUILDER_IMAGE_PULL_POLICY
1029-
l["slugimage"] = settings.SLUGRUNNER_IMAGE
1024+
l["image"] = settings.SLUGRUNNER_IMAGE
10301025
TEMPLATE = RCB_TEMPLATE
10311026

10321027
template = json.loads(string.Template(TEMPLATE).substitute(l))

0 commit comments

Comments
 (0)