Skip to content

Commit 86d8625

Browse files
committed
refactor: adjust default image envs
Signed-off-by: thxCode <[email protected]>
1 parent 30f3e75 commit 86d8625

File tree

4 files changed

+68
-49
lines changed

4 files changed

+68
-49
lines changed

gpustack_runtime/deployer/__types__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,11 +1020,11 @@ def validate_and_default(self):
10201020
c.execution.command_script = None
10211021
# Add default registry if needed.
10221022
if (
1023-
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY
1024-
and envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY
1023+
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY
1024+
and envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY
10251025
not in ["docker.io", "index.docker.io"]
10261026
):
1027-
image_registry = envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_NAMESPACE
1027+
image_registry = envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_NAMESPACE
10281028
image_split = c.image.split("/")
10291029
if len(image_split) == 1:
10301030
c.image = f"{image_registry}/library/{c.image}"

gpustack_runtime/deployer/docker.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def validate_and_default(self):
139139
super().validate_and_default()
140140

141141
# Adjust default image namespace if needed.
142-
if namespace := envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_NAMESPACE:
142+
if namespace := envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_NAMESPACE:
143143
self.pause_image = replace_image_with(
144144
image=self.pause_image,
145145
namespace=namespace,
@@ -463,12 +463,12 @@ def _pull_image(self, image: str) -> docker.models.images.Image:
463463
tag = tag or "latest"
464464
auth_config = None
465465
if (
466-
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME
467-
and envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD
466+
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME
467+
and envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD
468468
):
469469
auth_config = {
470-
"username": envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME,
471-
"password": envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD,
470+
"username": envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME,
471+
"password": envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD,
472472
}
473473

474474
logs = self._client.api.pull(

gpustack_runtime/deployer/kuberentes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1206,16 +1206,16 @@ def _prepare_create(self):
12061206

12071207
# Create image pull secrets if default registry credentials are set.
12081208
if not self._image_pull_secret and (
1209-
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME
1210-
and envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD
1209+
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME
1210+
and envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD
12111211
):
12121212
registry = (
1213-
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY or "index.docker.io"
1213+
envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY or "index.docker.io"
12141214
)
12151215
self._image_pull_secret = self._apply_image_pull_secret(
12161216
registry=f"https://{registry}/v1/",
1217-
username=envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME,
1218-
password=envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD,
1217+
username=envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME,
1218+
password=envs.GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD,
12191219
)
12201220

12211221
# Prepare mirrored deployment if enabled.

gpustack_runtime/envs.py

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -62,25 +62,6 @@
6262
"""
6363
Deployer to use (options: Auto, Docker, Kubernetes).
6464
"""
65-
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY: str | None = None
66-
"""
67-
Default container registry for deployer to pull images from.
68-
If not set, it should be "docker.io".
69-
If the image name already contains a registry, this setting will be ignored.
70-
"""
71-
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_NAMESPACE: str | None = None
72-
"""
73-
Namespace for default runner images.
74-
If not set, it should be "gpustack".
75-
"""
76-
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME: str | None = None
77-
"""
78-
Username for the default container registry.
79-
"""
80-
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD: str | None = None
81-
"""
82-
Password for the default container registry.
83-
"""
8465
GPUSTACK_RUNTIME_DEPLOY_API_CALL_ERROR_DETAIL: bool = True
8566
"""
8667
Enable detailing the API call error during deployment.
@@ -138,6 +119,25 @@
138119
"""
139120
Correct the gpustack-runner image by rendering it with the host's detection.
140121
"""
122+
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY: str | None = None
123+
"""
124+
Default container registry for deployer to pull images from.
125+
If not set, it should be "docker.io".
126+
If the image name already contains a registry, this setting will be ignored.
127+
"""
128+
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_NAMESPACE: str | None = None
129+
"""
130+
Namespace for default runner images.
131+
If not set, it should be "gpustack".
132+
"""
133+
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME: str | None = None
134+
"""
135+
Username for the default container registry.
136+
"""
137+
GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD: str | None = None
138+
"""
139+
Password for the default container registry.
140+
"""
141141
GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY: str | None = None
142142
"""
143143
Image pull policy for the deployer (e.g., Always, IfNotPresent, Never).
@@ -299,23 +299,6 @@
299299
"GPUSTACK_RUNTIME_DEPLOY",
300300
"Auto",
301301
),
302-
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY": lambda: trim_str(
303-
getenvs(
304-
keys=[
305-
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY",
306-
"GPUSTACK_SYSTEM_DEFAULT_CONTAINER_REGISTRY", # Compatible with gpustack/gpustack.
307-
],
308-
),
309-
),
310-
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_NAMESPACE": lambda: trim_str(
311-
getenv("GPUSTACK_RUNTIME_DEPLOY_DEFAULT_NAMESPACE"),
312-
),
313-
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME": lambda: trim_str(
314-
getenv("GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME"),
315-
),
316-
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD": lambda: getenv(
317-
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD",
318-
),
319302
"GPUSTACK_RUNTIME_DEPLOY_API_CALL_ERROR_DETAIL": lambda: to_bool(
320303
getenv("GPUSTACK_RUNTIME_DEPLOY_API_CALL_ERROR_DETAIL", "1"),
321304
),
@@ -349,6 +332,42 @@
349332
"GPUSTACK_RUNTIME_DEPLOY_CORRECT_RUNNER_IMAGE": lambda: to_bool(
350333
getenv("GPUSTACK_RUNTIME_DEPLOY_CORRECT_RUNNER_IMAGE", "1"),
351334
),
335+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY": lambda: trim_str(
336+
getenvs(
337+
keys=[
338+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY",
339+
# TODO(thxCode): Backward compatibility, remove in v0.1.45 later.
340+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY",
341+
# Compatible with gpustack/gpustack.
342+
"GPUSTACK_SYSTEM_DEFAULT_CONTAINER_REGISTRY",
343+
],
344+
),
345+
),
346+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_NAMESPACE": lambda: trim_str(
347+
getenvs(
348+
keys=[
349+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_NAMESPACE",
350+
# TODO(thxCode): Backward compatibility, remove in v0.1.45 later.
351+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_NAMESPACE",
352+
],
353+
),
354+
),
355+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME": lambda: trim_str(
356+
getenvs(
357+
keys=[
358+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_USERNAME",
359+
# TODO(thxCode): Backward compatibility, remove in v0.1.45 later.
360+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_USERNAME",
361+
],
362+
),
363+
),
364+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD": lambda: getenvs(
365+
keys=[
366+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_IMAGE_REGISTRY_PASSWORD",
367+
# TODO(thxCode): Backward compatibility, remove in v0.1.45 later.
368+
"GPUSTACK_RUNTIME_DEPLOY_DEFAULT_REGISTRY_PASSWORD",
369+
],
370+
),
352371
"GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY": lambda: choice(
353372
getenv(
354373
"GPUSTACK_RUNTIME_DEPLOY_IMAGE_PULL_POLICY",

0 commit comments

Comments
 (0)