Skip to content

[BUG]: OpenShift auto-detection crashes on non-OpenShift Kubernetes clusters #254

Description

@Jatinbhardwaj-093

Description

In run_kraken.py, OpenShift availability is checked unconditionally at

https://github.com/krkn-chaos/krkn/blob/f7e674d5ad4c86b3d0e2915cfa44a7e73f0ee91f/run_kraken.py#L168-L180

This invokes ocpcli.is_openshift(), which relies on _get_clusterversion_string() implemented in krkn-lib:

def _get_clusterversion_string(self) -> str:
"""
Return clusterversion status text on OpenShift, empty string
on other distributions
*** IT MUST BE CONSIDERED A PRIVATE METHOD (CANNOT USE
*** DOUBLE UNDERSCORE TO MAINTAIN IT VISIBLE ON SUB-CLASSES)
*** USED IN KrknKubernetes and KrknOpenshift TO AUTODETECT
*** THE CLUSTER TYPE
:return: clusterversion status
"""
try:
cvs = self.custom_object_client.list_cluster_custom_object(
"config.openshift.io",
"v1",
"clusterversions",
)
for cv in cvs["items"]:
for condition in cv["status"]["conditions"]:
if condition["type"] == "Available":
return condition["message"].split(" ")[-1]
return ""
except client.exceptions.ApiException as e:
if e.status == 404:
return ""
else:
raise e

The detection logic assumes non-OpenShift clusters fail with an HTTP 404.
However, in practice the call fails with connection-level errors (ConnectionRefusedError, NewConnectionError, MaxRetryError), which are not caught.

As a result:
• is_openshift() throws instead of returning False
• run_kraken exits early with a misconfiguration error
• Kubernetes-only clusters never reach scenario execution

This appears to be the root cause of the observed failures, though further validation may be needed.

LOGS

krkn-ai ➜ uv run krkn_ai run \
    -r krknhub \
    -c ./krkn-ai.yaml \
    -o ./results \
    -p HOST=$HOST
[INFO] Initialized config: ./krkn-ai.yaml
[INFO] Random seed: None (non-reproducible mode)
[INFO] Elasticsearch indexing is disabled
[INFO] Krkn-AI run UUID: a247bd5d-9d0b-4df3-8e30-aab57be5b4d5
[INFO] Saving config file to config.yaml
[INFO] Creating population of size 2
[INFO] | Population |
[INFO] --------------------------------------------------------
[INFO] container-scenarios(robot-shop, service=ratings, 1, .*, 1, 60), 
[INFO] pod-scenarios(robot-shop, service=user, .*, 1, 60, 60), 
[INFO] --------------------------------------------------------
[INFO] | Generation 1 |
[INFO] --------------------------------------------------------
[INFO] Running scenario: container-scenarios(robot-shop, service=ratings, 1, .*, 1, 60)
[WARNING] Could not find 'Chaos data:' in log
[INFO] Krkn scenario return code: 1
[WARNING] Krkn scenario failed with return code 1 (misconfiguration). Skipping fitness calculation to avoid data pollution.
[ERROR] Command output:
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
10-02-2026T10:53:48 Checking if OpenShift client is installed
/usr/bin/oc
2026-02-10 10:53:51,281 [INFO] Starting kraken
2026-02-10 10:53:51,292 [INFO] Initializing client to talk to the Kubernetes cluster
2026-02-10 10:53:51,293 [INFO] Generated a uuid for the run: f93d082a-2279-425a-83b4-a71975dcab4d
2026-02-10 10:53:51,330 [WARNING] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fffebd14f90>: Failed to establish a new connection: [Errno 111] Connection refused')': /apis/config.openshift.io/v1/clusterversions
2026-02-10 10:53:51,331 [WARNING] Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fffeb7cbdd0>: Failed to establish a new connection: [Errno 111] Connection refused')': /apis/config.openshift.io/v1/clusterversions
2026-02-10 10:53:51,331 [WARNING] Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fffeb7c8f10>: Failed to establish a new connection: [Errno 111] Connection refused')': /apis/config.openshift.io/v1/clusterversions

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleThis issue or PR has been inactive for too long

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions