Skip to content

Commit 09aad7e

Browse files
authored
[Feature] integrate RayDashboard with apiserver V2 (#4054)
Signed-off-by: Cheyu Wu <[email protected]>
1 parent 97425fa commit 09aad7e

29 files changed

+1226
-216
lines changed

dashboard/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ make install
1919

2020
Now, you should be able to access the KubeRay apiserver at `http://localhost:31888/apis/v1/namespaces/default/jobs`.
2121

22-
Now, to deploy the dashboard, you can run `npm run dev` and go to `localhost:3000/ray/jobs` on your browser. Note that
22+
Now, to deploy the dashboard, you can run `yarn dev` and go to `localhost:3000/ray/jobs` on your browser. Note that
2323
you might need to disable CORS by launching Chrome with
2424

2525
```bash

dashboard/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@emotion/react": "^11.11.4",
1414
"@emotion/styled": "^11.11.0",
15+
"@kubernetes/client-node": "^1.3.0",
1516
"@mui/icons-material": "^5.15.14",
1617
"@mui/joy": "^5.0.0-beta.32",
1718
"@mui/material": "^5.15.14",

dashboard/public/lokiIcon.png

7.63 KB
Loading

dashboard/public/ray.png

10.3 KB
Loading

dashboard/src/app/api/config/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { NextResponse } from "next/server";
2+
import { defaultConfig } from "@/utils/constants";
23

34
export async function GET() {
45
const config = {
56
apiUrl:
67
process.env.NEXT_PUBLIC_API_URL ||
78
process.env.API_URL ||
8-
"http://localhost:31888/apis/v1",
9+
defaultConfig.url,
910
};
1011

1112
return NextResponse.json(config);

dashboard/src/components/ClustersTable/ClusterStatusParser.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@ import AutorenewRoundedIcon from "@mui/icons-material/AutorenewRounded";
55
import BlockIcon from "@mui/icons-material/Block";
66
import CheckRoundedIcon from "@mui/icons-material/CheckRounded";
77
import PendingRoundedIcon from "@mui/icons-material/PendingRounded";
8+
import { ClusterStatus } from "@/types/v2/raycluster";
89

910
// There are two statues: JobStatus and JobDeploymentStatus. According to Ray CRD
1011
// https://github.com/ray-project/kuberay/blob/master/ray-operator/apis/ray/v1/rayjob_types.go
1112
// These are the enums:
1213
/*
1314
JobStatusNew JobStatus = ""
14-
JobStatusPending JobStatus = "PENDING"
15-
JobStatusRunning JobStatus = "RUNNING"
16-
JobStatusStopped JobStatus = "STOPPED"
17-
JobStatusSucceeded JobStatus = "SUCCEEDED"
18-
JobStatusFailed JobStatus = "FAILED"
15+
JobStatusPending JobStatus = "PENDING"
16+
JobStatusRunning JobStatus = "RUNNING"
17+
JobStatusStopped JobStatus = "STOPPED"
18+
JobStatusSucceeded JobStatus = "SUCCEEDED"
19+
JobStatusFailed JobStatus = "FAILED"
1920
2021
JobDeploymentStatusNew JobDeploymentStatus = ""
21-
JobDeploymentStatusInitializing JobDeploymentStatus = "Initializing"
22-
JobDeploymentStatusRunning JobDeploymentStatus = "Running"
23-
JobDeploymentStatusComplete JobDeploymentStatus = "Complete"
24-
JobDeploymentStatusFailed JobDeploymentStatus = "Failed"
25-
JobDeploymentStatusSuspending JobDeploymentStatus = "Suspending"
26-
JobDeploymentStatusSuspended JobDeploymentStatus = "Suspended"
22+
JobDeploymentStatusInitializing JobDeploymentStatus = "Initializing"
23+
JobDeploymentStatusRunning JobDeploymentStatus = "Running"
24+
JobDeploymentStatusComplete JobDeploymentStatus = "Complete"
25+
JobDeploymentStatusFailed JobDeploymentStatus = "Failed"
26+
JobDeploymentStatusSuspending JobDeploymentStatus = "Suspending"
27+
JobDeploymentStatusSuspended JobDeploymentStatus = "Suspended"
2728
*/
2829
// However, it seems like we also have WaitForDashboardReady status... which
2930
// is not in the Kuberay codebase.
@@ -33,14 +34,20 @@ import PendingRoundedIcon from "@mui/icons-material/PendingRounded";
3334
export const capitalize = (status: string) =>
3435
status.charAt(0).toUpperCase() + status.toLowerCase().slice(1);
3536

36-
export const getClusterStatus = (status: string) => {
37+
export const getClusterStatusDisplay = (status: ClusterStatus) => {
3738
return capitalize(status);
3839
};
3940

40-
export const getClusterStatusColor = (status: string) => {
41+
export const getClusterStatusColor = (
42+
status: ClusterStatus,
43+
): ColorPaletteProp => {
4144
return {
42-
PENDING: "warning",
4345
READY: "primary",
46+
PENDING: "warning",
47+
SUSPENDING: "warning",
48+
FAILED: "danger",
49+
SUSPENDED: "neutral",
50+
UNKNOWN: "neutral",
4451
}[status] as ColorPaletteProp;
4552
};
4653

dashboard/src/components/ClustersTable/ClustersTable.tsx

Lines changed: 16 additions & 14 deletions
Large diffs are not rendered by default.

dashboard/src/components/FrontendTable/FrontendTableHead.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22
// Mostly from https://mui.com/joy-ui/react-table/#sort-and-selection
3-
import { JobRow } from "@/types/rayjob";
43
import { Order } from "@/types/table";
54
import ArrowDownwardIcon from "@mui/icons-material/ArrowDownward";
65
import { Checkbox } from "@mui/joy";

dashboard/src/components/JobsTable/JobStatusParser.tsx

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@ import AutorenewRoundedIcon from "@mui/icons-material/AutorenewRounded";
55
import BlockIcon from "@mui/icons-material/Block";
66
import CheckRoundedIcon from "@mui/icons-material/CheckRounded";
77
import PendingRoundedIcon from "@mui/icons-material/PendingRounded";
8+
import { JobStatus } from "@/types/v2/rayjob";
89

910
// There are two statues: JobStatus and JobDeploymentStatus. According to Ray CRD
1011
// https://github.com/ray-project/kuberay/blob/master/ray-operator/apis/ray/v1/rayjob_types.go
1112
// These are the enums:
1213
/*
1314
JobStatusNew JobStatus = ""
14-
JobStatusPending JobStatus = "PENDING"
15-
JobStatusRunning JobStatus = "RUNNING"
16-
JobStatusStopped JobStatus = "STOPPED"
17-
JobStatusSucceeded JobStatus = "SUCCEEDED"
18-
JobStatusFailed JobStatus = "FAILED"
15+
JobStatusPending JobStatus = "PENDING"
16+
JobStatusRunning JobStatus = "RUNNING"
17+
JobStatusStopped JobStatus = "STOPPED"
18+
JobStatusSucceeded JobStatus = "SUCCEEDED"
19+
JobStatusFailed JobStatus = "FAILED"
1920
2021
JobDeploymentStatusNew JobDeploymentStatus = ""
21-
JobDeploymentStatusInitializing JobDeploymentStatus = "Initializing"
22-
JobDeploymentStatusRunning JobDeploymentStatus = "Running"
23-
JobDeploymentStatusComplete JobDeploymentStatus = "Complete"
24-
JobDeploymentStatusFailed JobDeploymentStatus = "Failed"
25-
JobDeploymentStatusSuspending JobDeploymentStatus = "Suspending"
26-
JobDeploymentStatusSuspended JobDeploymentStatus = "Suspended"
22+
JobDeploymentStatusInitializing JobDeploymentStatus = "Initializing"
23+
JobDeploymentStatusRunning JobDeploymentStatus = "Running"
24+
JobDeploymentStatusComplete JobDeploymentStatus = "Complete"
25+
JobDeploymentStatusFailed JobDeploymentStatus = "Failed"
26+
JobDeploymentStatusSuspending JobDeploymentStatus = "Suspending"
27+
JobDeploymentStatusSuspended JobDeploymentStatus = "Suspended"
2728
*/
2829
// However, it seems like we also have WaitForDashboardReady status... which
2930
// is not in the Kuberay codebase.
@@ -34,18 +35,20 @@ const capitalize = (status: string) =>
3435
status.charAt(0) + status.toLowerCase().slice(1);
3536

3637
// Return the jobStatus.
37-
export const getJobStatus = (jobStatus: string) => {
38-
return capitalize(jobStatus);
38+
export const getJobStatusDisplay = (status: JobStatus) => {
39+
return capitalize(status);
3940
};
4041

41-
export const getJobStatusColor = (status: string) => {
42-
return {
42+
export const getJobStatusColor = (status: JobStatus): ColorPaletteProp => {
43+
const statusColorMap: Record<string, ColorPaletteProp> = {
4344
PENDING: "warning",
4445
SUCCEEDED: "success",
4546
FAILED: "danger",
4647
RUNNING: "primary",
4748
STOPPED: "danger",
48-
}[status] as ColorPaletteProp;
49+
WAITING: "warning",
50+
};
51+
return statusColorMap[status] ?? "neutral";
4952
};
5053

5154
export const getJobStatusIcon = (status: string) => {
@@ -59,6 +62,7 @@ export const getJobStatusIcon = (status: string) => {
5962
PENDING: <PendingRoundedIcon />,
6063
STOPPED: <BlockIcon />,
6164
FAILED: <BlockIcon />,
65+
UNKNOWN: <PendingRoundedIcon />,
6266
RUNNING: (
6367
<AutorenewRoundedIcon
6468
sx={{

dashboard/src/components/JobsTable/JobsTable.tsx

Lines changed: 28 additions & 22 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)