Skip to content

Commit 1aa3251

Browse files
committed
Merge pull request #1538 from deis/check-hostname
fix(controller): check image for hostname
2 parents adb90d2 + a882f1f commit 1aa3251

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

controller/api/tasks.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import threading
1212

1313
from celery import task
14+
from docker.utils import utils
1415
from django.conf import settings
1516

1617

@@ -78,10 +79,12 @@ def stop_containers(containers):
7879
@task
7980
def run_command(c, command):
8081
release = c.release
81-
version = release.version
82-
image = '{}:{}/{}'.format(settings.REGISTRY_HOST,
83-
settings.REGISTRY_PORT,
84-
release.image)
82+
image = release.image + ':v' + str(release.version)
83+
# check for backwards compatibility
84+
if not _has_hostname(image):
85+
image = '{}:{}/{}'.format(settings.REGISTRY_HOST,
86+
settings.REGISTRY_PORT,
87+
release.image)
8588
try:
8689
# pull the image first
8790
rc, pull_output = c.run("docker pull {image}".format(**locals()))
@@ -95,3 +98,8 @@ def run_command(c, command):
9598
return c.run(command)
9699
finally:
97100
c.delete()
101+
102+
103+
def _has_hostname(image):
104+
repo, tag = utils.parse_repository_tag(image)
105+
return True if '/' in repo and '.' in repo.split('/')[0] else False

controller/registry/private.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def publish_release(source, config, target):
2828
repo, tag = utils.parse_repository_tag(source)
2929
src_image = repo
3030
src_tag = tag if tag is not None else 'latest'
31-
31+
3232
nameparts = repo.rsplit('/', 1)
3333
if len(nameparts) == 2:
3434
if '/' in nameparts[0]:

0 commit comments

Comments
 (0)