Skip to content

Commit 4fce00d

Browse files
committed
ai suggested fixes
1 parent 76905ef commit 4fce00d

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

operators/openshift-pipelines-operator-rh/operator_update_pipeline.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@
8888
script: |
8989
#!/bin/bash
9090
91-
python ./operator_update.py "{{ [storage_operators[blockStorageBackend]] + operators }}" "$(params.dry-run)" > $(results.status-report.path)
92-
echo -n $? > $(results.exit-code.path)
91+
python ./operator_update.py "{{ [storage_operators[blockStorageBackend]] + operators }}" "$(params.dry-run)" > "$(results.status-report.path)"
92+
rc=$?
93+
echo -n "${rc}" > "$(results.exit-code.path)"
94+
exit "${rc}"
9395
9496
- name: Create Operator Update Pipeline
9597
kubernetes.core.k8s:

scripts/operator_update.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ def wait_for_resource_status(
2929
capture_output=True,
3030
text=True,
3131
)
32+
if result.returncode != 0:
33+
stderr = (result.stderr or "").strip()
34+
if "not found" not in stderr.lower():
35+
raise RuntimeError(
36+
f"Failed to read {kind}/{name} in namespace {namespace}: {stderr}"
37+
)
38+
3239
current_state = parse_jsonpath_value(result.stdout or "")
3340
if current_state == desired_state:
3441
print(
@@ -43,16 +50,17 @@ def wait_for_resource_status(
4350

4451

4552
def semver_key(v_string):
46-
# Separate the numeric part from the tag (e.g., '1.2.0-rc1' -> ['1.2.0', 'rc1'])
47-
parts = v_string.split("-", 1)
48-
main_version = tuple(map(int, parts[0].split(".")))
53+
main, sep, prerelease = v_string.partition("-")
54+
main_version = tuple(map(int, main.split(".")))
55+
56+
if not sep:
57+
# Release versions sort after prerelease versions with same core.
58+
return (main_version, ((2, 0),))
4959

50-
if len(parts) == 1:
51-
# No suffix: Use a high-value marker so 1.2.0 > 1.2.0-rc1
52-
return (main_version, (float("inf"),))
53-
else:
54-
# Has suffix: Return the numeric part and the string tag
55-
return (main_version, (0, parts[1]))
60+
parsed = []
61+
for token in prerelease.split("."):
62+
parsed.append((0, int(token)) if token.isdigit() else (1, token))
63+
return (main_version, tuple(parsed))
5664

5765

5866
def approve_install_plans(
@@ -83,8 +91,14 @@ def approve_install_plans(
8391
continue
8492
version_ok = True
8593
for csv in install_plan_spec_csv_names:
86-
csv_op_name, csv_version = csv.split(".v")
94+
csv_op_name, csv_version = csv.rsplit(".v", 1)
8795
desired_op_version = approved_op_version_map.get(csv_op_name)
96+
if desired_op_version is None:
97+
version_ok = False
98+
print(
99+
f"Install plan {install_plan_name} includes unmanaged CSV {csv_op_name}. Skipping."
100+
)
101+
break
88102
version_ok = semver_key(csv_version) <= semver_key(desired_op_version)
89103
if not version_ok:
90104
print(

0 commit comments

Comments
 (0)