Skip to content

Commit

Permalink
[SkyServe] Fix sky serve up with docker login config (#2983)
Browse files Browse the repository at this point in the history
* fix

* fix

* move to docker utils
  • Loading branch information
cblmemo authored Feb 1, 2024
1 parent b6ccf1c commit 25ad4a3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 5 additions & 1 deletion sky/provision/docker_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def initialize(self) -> str:
f'{docker_login_config.username} '
f'--password {docker_login_config.password} '
f'{docker_login_config.server}')
specific_image = f'{docker_login_config.server}/{specific_image}'
# We automatically add the server prefix to the image name if
# the user did not add it.
server_prefix = f'{docker_login_config.server}/'
if not specific_image.startswith(server_prefix):
specific_image = f'{server_prefix}{specific_image}'

if self.docker_config.get('pull_before_run', True):
assert specific_image, ('Image must be included in config if ' +
Expand Down
1 change: 0 additions & 1 deletion sky/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1269,7 +1269,6 @@ def add_if_not_none(key, value):
if self.disk_tier is not None:
config['disk_tier'] = self.disk_tier.value
add_if_not_none('ports', self.ports)
add_if_not_none('_docker_login_config', self._docker_login_config)
if self._is_image_managed is not None:
config['_is_image_managed'] = self._is_image_managed
return config
Expand Down
5 changes: 5 additions & 0 deletions sky/skylet/providers/command_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ def run_init(self, *, as_head: bool, file_mounts: Dict[str, str],
docker_login_config.password,
docker_login_config.server,
))
# We automatically add the server prefix to the image name if
# the user did not add it.
server_prefix = f'{docker_login_config.server}/'
if not specific_image.startswith(server_prefix):
specific_image = f'{server_prefix}{specific_image}'

if self.docker_config.get('pull_before_run', True):
assert specific_image, ('Image must be included in config if ' +
Expand Down
5 changes: 0 additions & 5 deletions sky/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ def _add_docker_login_config(resources: 'resources_lib.Resources'):
# Already checked in extract_docker_image
assert len(resources.image_id) == 1, resources.image_id
region = list(resources.image_id.keys())[0]
# We automatically add the server prefix to the image name if
# the user did not add it.
server_prefix = f'{docker_login_config.server}/'
if not docker_image.startswith(server_prefix):
docker_image = f'{server_prefix}{docker_image}'
return resources.copy(image_id={region: 'docker:' + docker_image},
_docker_login_config=docker_login_config)

Expand Down

0 comments on commit 25ad4a3

Please sign in to comment.