Skip to content

Commit a77f7e3

Browse files
committed
RHOAIENG-63111: address PR comments
1 parent ce493a3 commit a77f7e3

3 files changed

Lines changed: 27 additions & 25 deletions

File tree

scripts/migration/ray_cluster_migration.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -961,14 +961,20 @@ def _get_cluster_route(
961961
print(f" [DEBUG] Cluster-wide search failed: {e}")
962962
pass # Will fall through to namespace search
963963

964-
# If cluster-wide search didn't find anything, try namespace-specific search
964+
# If cluster-wide search didn't find anything, try namespace-specific search.
965+
# HTTPRoutes are created in the RayCluster namespace; search it first when known.
965966
if not httproute:
966-
search_namespaces = [
967-
"redhat-ods-applications",
968-
"opendatahub",
969-
"default",
970-
"ray-system",
971-
]
967+
search_namespaces = list(
968+
dict.fromkeys(
969+
([namespace] if namespace else [])
970+
+ [
971+
"redhat-ods-applications",
972+
"opendatahub",
973+
"default",
974+
"ray-system",
975+
]
976+
)
977+
)
972978

973979
for ns in search_namespaces:
974980
try:
@@ -1008,7 +1014,9 @@ def _get_cluster_route(
10081014

10091015
gateway_ref = parent_refs[0]
10101016
gateway_name = gateway_ref.get("name")
1011-
gateway_namespace = gateway_ref.get("namespace")
1017+
# parentRefs[].namespace is optional; defaults to the HTTPRoute's namespace.
1018+
route_namespace = (httproute.get("metadata") or {}).get("namespace")
1019+
gateway_namespace = gateway_ref.get("namespace") or route_namespace
10121020

10131021
if not gateway_name or not gateway_namespace:
10141022
return None
@@ -1757,7 +1765,7 @@ def pre_upgrade(
17571765
print(
17581766
"may result in your Ray infrastructure becoming unavailable or unrecoverable."
17591767
)
1760-
return []
1768+
sys.exit(1)
17611769
elif all_passed:
17621770
print("All pre-upgrade checks passed.\n")
17631771
else:
@@ -1827,7 +1835,7 @@ def pre_upgrade(
18271835
print(
18281836
"Please check that you have write permissions to the parent directory."
18291837
)
1830-
return []
1838+
sys.exit(1)
18311839

18321840
# Create subdirectories for RHOAI 2.x and 3.x compatible backups
18331841
rhoai_2x_dir = os.path.join(output_dir, "rhoai-2.x")
@@ -1839,7 +1847,7 @@ def pre_upgrade(
18391847
os.makedirs(subdir)
18401848
except OSError as e:
18411849
print(f"ERROR: Failed to create backup subdirectory '{subdir}': {e}")
1842-
return []
1850+
sys.exit(1)
18431851

18441852
saved_files = []
18451853

tests/upgrade/03_ray_migration_pre_upgrade_finalize_test.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ def test_ray_migration_pre_upgrade_finalize(self):
2929
cluster_name=CLUSTER_NAME,
3030
)
3131

32-
if result.returncode != 0:
33-
# Script may return non-zero on check failures after setting codeflare;
34-
# still verify the critical DSC state.
35-
print(
36-
f"Migration pre-upgrade exited with code {result.returncode}; "
37-
"verifying codeflare Removed anyway."
38-
)
32+
assert result.returncode == 0, (
33+
f"Migration pre-upgrade exited with code {result.returncode}; "
34+
"required pre-flight checks or backup steps failed."
35+
)
3936

4037
assert_codeflare_removed()
4138
assert_raycluster_pre_upgrade_artifacts_if_present()

tests/upgrade/conftest.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,8 @@ def ensure_migration_pre_upgrade_finalize(request):
5454
)
5555
result = run_migration_pre_upgrade()
5656
if result.returncode != 0:
57-
print(
58-
f"Warning: migration pre-upgrade exited with code {result.returncode} "
59-
"in session finalizer."
57+
pytest.fail(
58+
f"Migration pre-upgrade exited with code {result.returncode} "
59+
"in session finalizer; required pre-flight checks or backup steps failed."
6060
)
61-
try:
62-
assert_codeflare_removed()
63-
except AssertionError as e:
64-
pytest.fail(str(e))
61+
assert_codeflare_removed()

0 commit comments

Comments
 (0)