@@ -165,44 +165,12 @@ def _env_flag_disabled(name):
165165 return os .environ .get (name , "" ).strip ().lower () in ("0" , "false" , "no" , "off" )
166166
167167
168- def _has_registry_mirror_configured ():
169- """
170- Detect mirror-only registry layout typical of disconnected OpenShift installs.
171-
172- Checks ImageDigestMirrorSet (OCP 4.14+) and ImageContentSourcePolicy (legacy).
173- """
174- try :
175- from kubernetes import client as k8s_client
176-
177- custom_api = k8s_client .CustomObjectsApi ()
178- mirror_types = [
179- ("config.openshift.io" , "v1" , "imagedigestmirrorsets" ),
180- ("operator.openshift.io" , "v1alpha1" , "imagecontentsourcepolicies" ),
181- ]
182- for group , version , plural in mirror_types :
183- try :
184- result = custom_api .list_cluster_custom_object (
185- group = group ,
186- version = version ,
187- plural = plural ,
188- )
189- if result .get ("items" ):
190- return True
191- except Exception :
192- continue
193- except Exception :
194- pass
195- return False
196-
197-
198168def _disconnected_cluster_signals ():
199169 """Return True when the cluster is likely disconnected / air-gapped."""
200170 if _env_flag_enabled ("DISCONNECTED_CLUSTER" ) or _env_flag_enabled (
201171 "IS_DISCONNECTED_CLUSTER"
202172 ):
203173 return True
204- if _has_registry_mirror_configured ():
205- return True
206174 try :
207175 server = (run_oc_command (["whoami" , "--show-server=true" ]) or "" ).lower ()
208176 if "-dis-" in server or "disconnected" in server :
@@ -212,7 +180,7 @@ def _disconnected_cluster_signals():
212180 return False
213181
214182
215- def _upgrade_mnist_prerequisites_met ():
183+ def _mnist_prerequisites_met ():
216184 """
217185 Return True when full MNIST can run (pip packages + dataset reachable).
218186
@@ -229,49 +197,42 @@ def _upgrade_mnist_prerequisites_met():
229197 if pip_ok and aws_ok :
230198 print (
231199 "Disconnected cluster with PIP mirror and S3 endpoint configured; "
232- "using full MNIST upgrade job"
200+ "using full MNIST job"
233201 )
234202 return True
235203 return False
236204
237205
238- def use_upgrade_smoke_job ():
206+ def use_smoke_job ():
239207 """
240- Use a lightweight Ray job for upgrade tests when full MNIST is not viable.
241-
242- Full MNIST pulls torch/pytorch via pip and may download datasets from the
243- public internet — both fail on disconnected clusters without mirrors.
208+ Use a lightweight Ray job when full MNIST is not viable.
244209
245210 Detection order (first match wins):
246- 1. UPGRADE_USE_SMOKE_JOB=true|false (explicit override)
211+ 1. USE_SMOKE_JOB / UPGRADE_USE_SMOKE_JOB=true|false (explicit override)
247212 2. Full MNIST prerequisites met (connected, or disconnected with mirrors)
248213 3. DISCONNECTED_CLUSTER / IS_DISCONNECTED_CLUSTER env (Jenkins)
249- 4. ImageDigestMirrorSet / ImageContentSourcePolicy on cluster
250- 5. API server URL heuristic (-dis- / disconnected), last resort
214+ 4. API server URL heuristic (-dis- / disconnected), last resort
215+
216+ ImageDigestMirrorSet / ICSP are intentionally not used: many connected
217+ OpenShift clusters mirror container registries without blocking pip/PyPI.
251218 """
252- if _env_flag_enabled ("UPGRADE_USE_SMOKE_JOB" ):
253- print ("UPGRADE_USE_SMOKE_JOB enabled; using upgrade smoke job" )
254- return True
255- if _env_flag_disabled ("UPGRADE_USE_SMOKE_JOB" ):
256- print ("UPGRADE_USE_SMOKE_JOB disabled; using full MNIST upgrade job" )
257- return False
219+ for name in ("USE_SMOKE_JOB" , "UPGRADE_USE_SMOKE_JOB" ):
220+ if _env_flag_enabled (name ):
221+ print (f"{ name } enabled; using smoke job (no pip install)" )
222+ return True
223+ if _env_flag_disabled (name ):
224+ print (f"{ name } disabled; using full MNIST job" )
225+ return False
258226
259- if _upgrade_mnist_prerequisites_met ():
227+ if _mnist_prerequisites_met ():
260228 return False
261229
262230 if _env_flag_enabled ("DISCONNECTED_CLUSTER" ) or _env_flag_enabled (
263231 "IS_DISCONNECTED_CLUSTER"
264232 ):
265233 print (
266234 "Disconnected cluster env set without PIP/S3 mirrors; "
267- "using upgrade smoke job (no pip install)"
268- )
269- return True
270-
271- if _has_registry_mirror_configured ():
272- print (
273- "Registry mirror detected (ImageDigestMirrorSet/ICSP) without "
274- "PIP/S3 mirrors; using upgrade smoke job (no pip install)"
235+ "using smoke job (no pip install)"
275236 )
276237 return True
277238
@@ -280,7 +241,7 @@ def use_upgrade_smoke_job():
280241 if "-dis-" in server or "disconnected" in server :
281242 print (
282243 "Detected disconnected cluster from API server URL; "
283- "using upgrade smoke job (no pip install)"
244+ "using smoke job (no pip install)"
284245 )
285246 return True
286247 except Exception :
@@ -289,28 +250,37 @@ def use_upgrade_smoke_job():
289250 return False
290251
291252
292- def get_upgrade_job_submission_spec ():
293- """
294- Return entrypoint and runtime_env for post-upgrade job submission tests.
295- """
296- if use_upgrade_smoke_job ():
253+ def use_upgrade_smoke_job ():
254+ """Backward-compatible alias for upgrade tests."""
255+ return use_smoke_job ()
256+
257+
258+ def get_mnist_job_submission_spec (** kwargs ):
259+ """Return entrypoint and runtime_env for tier1 / upgrade MNIST job submission tests."""
260+ env_vars = get_setup_env_variables (** kwargs )
261+ if use_smoke_job ():
297262 return {
298263 "entrypoint" : "python upgrade_job_smoke.py" ,
299264 "runtime_env" : {
300265 "working_dir" : "./tests/e2e/" ,
301- "env_vars" : get_setup_env_variables () ,
266+ "env_vars" : env_vars ,
302267 },
303268 }
304269 return {
305270 "entrypoint" : "python mnist.py" ,
306271 "runtime_env" : {
307272 "working_dir" : "./tests/e2e/" ,
308273 "pip" : "./tests/e2e/mnist_pip_requirements.txt" ,
309- "env_vars" : get_setup_env_variables () ,
274+ "env_vars" : env_vars ,
310275 },
311276 }
312277
313278
279+ def get_upgrade_job_submission_spec (** kwargs ):
280+ """Backward-compatible alias for post-upgrade job submission tests."""
281+ return get_mnist_job_submission_spec (** kwargs )
282+
283+
314284def random_choice ():
315285 alphabet = string .ascii_lowercase + string .digits
316286 return "" .join (random .choices (alphabet , k = 5 ))
@@ -831,18 +801,12 @@ def assert_get_cluster_and_jobsubmit(
831801 client = cluster .job_client
832802
833803 # Submit a job and get the submission ID
834- env_vars = (
835- get_setup_env_variables (ACCELERATOR = accelerator )
836- if accelerator
837- else get_setup_env_variables ()
838- )
804+ spec_kwargs = {"ACCELERATOR" : accelerator } if accelerator else {}
805+ job_spec = get_mnist_job_submission_spec (** spec_kwargs )
806+ print (f"Submitting job: { job_spec ['entrypoint' ]} " )
839807 submission_id = client .submit_job (
840- entrypoint = "python mnist.py" ,
841- runtime_env = {
842- "working_dir" : "./tests/e2e/" ,
843- "pip" : "./tests/e2e/mnist_pip_requirements.txt" ,
844- "env_vars" : env_vars ,
845- },
808+ entrypoint = job_spec ["entrypoint" ],
809+ runtime_env = job_spec ["runtime_env" ],
846810 entrypoint_num_cpus = 1 if number_of_gpus is None else None ,
847811 entrypoint_num_gpus = number_of_gpus ,
848812 )
0 commit comments