Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RayJob] Transition to Complete if the JobStatus is STOPPED #1855

Merged
merged 3 commits into from
Jan 24, 2024

Conversation

kevin85421
Copy link
Member

@kevin85421 kevin85421 commented Jan 19, 2024

Why are these changes needed?

The definition of terminal status for a Ray job is defined here. SUCCEEDED, FAILED, and STOPPED belong to terminal status which means that the Ray job can't transition to any other. Note that we don't stop the job for the suspend operation since #1798.

Without this PR, if you stop a running job, the RayJob will not enter Complete forever. Because the status will not transition to Complete, the TTL will not be triggered.

# Command to stop the Ray job
curl -X POST $RAY_DASHBOARD_URL/api/jobs/$YOUR_JOB_ID/stop

Related issue number

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(
# Create a long-running RayJob with this gist: https://gist.github.com/kevin85421/9cfa33c0c866dbf143e33651561e5719
# Important parts:
# (1) shutdownAfterJobFinishes: true
# (2) ttlSecondsAfterFinished: 10
# (3) 
# apiVersion: v1
# kind: ConfigMap
# metadata:
#   name: ray-job-code-sample
# data:
#   sample_code.py: |
#     import time
#     for i in range(10000):
#       print(i)
#       time.sleep(1)


# Port-forwarding
export HEAD_POD=$(kubectl get pods --selector=ray.io/node-type=head -o custom-columns=POD:metadata.name --no-headers)
kubectl port-forward $HEAD_POD 8265 

# Get Job ID
kubectl get rayjobs.ray.io rayjob-sample -o jsonpath='{.status.jobId}'
# [Example output]: rayjob-sample-hls2j

# Stop the job
curl -X POST 127.0.0.1:8265/api/jobs/rayjob-sample-hls2j/stop

# The Kubernetes Job will be complete, and the RayJob will become `Complete`.
# Wait for $ttlSecondsAfterFinished seconds. The RayCluster will be cleaned up.

@kevin85421 kevin85421 changed the title WIP [RayJob] Transition to Complete if the JobStatus is STOPPED Jan 20, 2024
Copy link
Contributor

@architkulkarni architkulkarni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Ideally we would have a test for this behavior, we can leave it as a followup issue if you don't have bandwidth right now.

@kevin85421
Copy link
Member Author

Ideally we would have a test for this behavior, we can leave it as a followup issue if you don't have bandwidth right now.

I will add a test in a follow-up PR. It may involve significant changes because it needs to execute a command in the head Pod, a process not currently used in the existing RayJob e2e tests.

@kevin85421 kevin85421 merged commit c78c75b into ray-project:master Jan 24, 2024
23 of 24 checks passed
@kevin85421 kevin85421 mentioned this pull request Jan 24, 2024
2 tasks
@kevin85421
Copy link
Member Author

Open an issue to track the progress #1866.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants