|
17 | 17 | from utilities import constants |
18 | 18 | from utilities.constants import INTERNAL_IMAGE_REGISTRY_PATH |
19 | 19 | from utilities.infra import check_internal_image_registry_available |
| 20 | +from utilities.general import collect_pod_information |
20 | 21 |
|
21 | 22 | LOGGER = get_logger(name=__name__) |
22 | 23 |
|
@@ -67,16 +68,21 @@ def notebook_image( |
67 | 68 | if not custom_image: |
68 | 69 | raise ValueError("custom_image cannot be empty or whitespace") |
69 | 70 |
|
70 | | - # Validation Logic (Moved from default_notebook) |
| 71 | + # Validation Logic: Only digest references are accepted |
71 | 72 | _ERR_INVALID_CUSTOM_IMAGE = ( |
72 | | - "custom_image must be a valid OCI image reference with either a tag (:tag) or digest (@sha256:digest), " |
73 | | - "e.g., 'quay.io/org/image:tag' or 'quay.io/org/image@sha256:digest', " |
| 73 | + "custom_image must be a valid OCI image reference with a digest (@sha256:digest), " |
| 74 | + "e.g., 'quay.io/org/image@sha256:abc123...', " |
74 | 75 | "got: '{custom_image}'" |
75 | 76 | ) |
76 | | - has_digest = "@sha256:" in custom_image |
77 | | - has_tag = ":" in custom_image and custom_image.rfind(":") > custom_image.rfind("/") |
78 | | - |
79 | | - if not (has_digest or has_tag): |
| 77 | + # Check for valid digest: @sha256: must be followed by non-empty content |
| 78 | + digest_marker = "@sha256:" |
| 79 | + has_valid_digest = False |
| 80 | + if digest_marker in custom_image: |
| 81 | + digest_index = custom_image.rfind(digest_marker) |
| 82 | + digest_end = digest_index + len(digest_marker) |
| 83 | + has_valid_digest = digest_end < len(custom_image) |
| 84 | + |
| 85 | + if not has_valid_digest: |
80 | 86 | raise ValueError(_ERR_INVALID_CUSTOM_IMAGE.format(custom_image=custom_image)) |
81 | 87 |
|
82 | 88 | LOGGER.info(f"Using custom workbench image: {custom_image}") |
@@ -261,6 +267,8 @@ def notebook_pod( |
261 | 267 | ) |
262 | 268 | except (TimeoutError, RuntimeError) as e: |
263 | 269 | if notebook_pod.exists: |
| 270 | + # Collect pod information for debugging purposes |
| 271 | + collect_pod_information(notebook_pod) |
264 | 272 | pod_status = notebook_pod.instance.status |
265 | 273 | pod_phase = pod_status.phase |
266 | 274 | error_details = get_pod_failure_details(notebook_pod) |
|
0 commit comments