Skip to content

fix(cluster): map all CodeFlareClusterStatus values to RayClusterStatus in _copy_to_ray()#1063

Merged
openshift-merge-bot[bot] merged 1 commit into
project-codeflare:mainfrom
kryanbeane:RHOAIENG-54700
Apr 22, 2026
Merged

fix(cluster): map all CodeFlareClusterStatus values to RayClusterStatus in _copy_to_ray()#1063
openshift-merge-bot[bot] merged 1 commit into
project-codeflare:mainfrom
kryanbeane:RHOAIENG-54700

Conversation

@kryanbeane

@kryanbeane kryanbeane commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Description

_copy_to_ray() only mapped CodeFlareClusterStatus.READY to RayClusterStatus.READY. All other statuses were passed through as CodeFlareClusterStatus enum values, so downstream comparisons against RayClusterStatus silently failed.

Replaced the single-case if with an explicit _CODEFLARE_TO_RAY_STATUS mapping dict that covers every CodeFlareClusterStatus member. States with a direct RayClusterStatus equivalent (READY, FAILED, SUSPENDED, UNKNOWN) map 1:1. CodeFlare-only states (STARTING, QUEUED, QUEUEING) map to RayClusterStatus.UNKNOWN.

Added a parametrized unit test covering all 7 enum values.

Verification steps

Prerequisites

  • An OpenShift or kind cluster with the KubeRay operator installed

2. Verification

Create a suspended RayCluster:

cat <<'EOF' | kubectl apply -f -
apiVersion: ray.io/v1
kind: RayCluster
metadata:
  name: test-54700-suspended
  namespace: default
spec:
  suspend: true
  rayVersion: "2.53.0"
  headGroupSpec:
    rayStartParams: { dashboard-host: "0.0.0.0" }
    template:
      spec:
        containers:
        - name: ray-head
          image: rayproject/ray:2.53.0
          resources:
            requests: { cpu: "500m", memory: "512Mi" }
            limits:   { cpu: "1",    memory: "1Gi"   }
  workerGroupSpecs:
  - groupName: small-group
    replicas: 1
    template:
      spec:
        containers:
        - name: ray-worker
          image: rayproject/ray:2.53.0
          resources:
            requests: { cpu: "500m", memory: "512Mi" }
            limits:   { cpu: "1",    memory: "1Gi"   }
EOF

Verify details() returns the correct type and value:

from kubernetes import client, config
from codeflare_sdk import set_api_client
from codeflare_sdk.ray.cluster.cluster import get_cluster
from codeflare_sdk.ray.cluster.status import RayClusterStatus

config.load_kube_config()
set_api_client(client.ApiClient())

cluster = get_cluster("test-54700-suspended", namespace="default")
ray = cluster.details(print_to_console=False)
print(type(ray.status))                          # <enum 'RayClusterStatus'>
print(ray.status == RayClusterStatus.SUSPENDED)   # True

To also check the failed state, patch the same cluster:

kubectl patch raycluster test-54700-suspended -n default \
  --type=merge --subresource=status -p '{"status":{"state":"failed"}}' \
  && kubectl patch raycluster test-54700-suspended -n default \
  --type=merge -p '{"spec":{"suspend":false}}'
cluster = get_cluster("test-54700-suspended", namespace="default")
ray = cluster.details(print_to_console=False)
print(type(ray.status))                        # <enum 'RayClusterStatus'>
print(ray.status == RayClusterStatus.FAILED)    # True

Cleanup

kubectl delete raycluster test-54700-suspended -n default

Resolves: RHOAIENG-54700

…us in _copy_to_ray()

_copy_to_ray() only converted READY, leaving every other status as a
CodeFlareClusterStatus enum.  Downstream comparisons against
RayClusterStatus silently failed.

Add an explicit mapping dict covering all CodeFlareClusterStatus members
and a parametrized unit test for every variant.

Resolves: RHOAIENG-54700
Made-with: Cursor
@openshift-ci
openshift-ci Bot requested review from chipspeak and pawelpaszki April 22, 2026 10:59
@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.56%. Comparing base (8ddddf7) to head (350203d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1063      +/-   ##
==========================================
+ Coverage   96.52%   96.56%   +0.04%     
==========================================
  Files          23       23              
  Lines        2271     2270       -1     
==========================================
  Hits         2192     2192              
+ Misses         79       78       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 22, 2026
@openshift-ci

openshift-ci Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chipspeak

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 22, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit e5cdf08 into project-codeflare:main Apr 22, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants