Skip to content

Commit

Permalink
fix: replicas derived in UI from mvtx status instead of spec (#1965)
Browse files Browse the repository at this point in the history
Signed-off-by: veds-g <[email protected]>
  • Loading branch information
veds-g authored Aug 19, 2024
1 parent b54a4cd commit 4267113
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion ui/src/types/declarations/pipeline.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export interface MonoVertex {
}

export interface MonoVertexSpec {
replicas: number;
source: any;
sink: any;
scale: any;
Expand Down
12 changes: 9 additions & 3 deletions ui/src/utils/fetcherHooks/monoVertexViewFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const useMonoVertexViewFetch = (
const [requestKey, setRequestKey] = useState("");
const [pipeline, setPipeline] = useState<MonoVertex | undefined>(undefined);
const [spec, setSpec] = useState<MonoVertexSpec | undefined>(undefined);
const [replicas, setReplicas] = useState<number | undefined>(undefined);
const [monoVertexPods, setMonoVertexPods] = useState<Map<string, number>>(
new Map()
);
Expand Down Expand Up @@ -45,7 +46,12 @@ export const useMonoVertexViewFetch = (
// Update pipeline state with data from the response
setPipeline(json.data?.monoVertex);
// Update spec state if it is not equal to the spec from the response
if (!isEqual(spec, json.data)) setSpec(json.data?.monoVertex?.spec);
if (!isEqual(spec, json.data?.monoVertex?.spec)) {
setSpec(json.data.monoVertex.spec);
}
if (replicas !== json.data?.monoVertex?.status?.replicas) {
setReplicas(json.data.monoVertex.status.replicas);
}
setPipelineErr(undefined);
} else if (json?.errMsg) {
// pipeline API call returns an error message
Expand Down Expand Up @@ -245,7 +251,7 @@ export const useMonoVertexViewFetch = (
const name = pipelineId ?? "";
newNode.id = name;
newNode.data = { name: name };
newNode.data.podnum = spec?.replicas ? spec.replicas : 0;
newNode.data.podnum = replicas ? replicas : 0;
newNode.position = { x: 0, y: 0 };
// change this in the future if you would like to make it draggable
newNode.draggable = false;
Expand All @@ -266,7 +272,7 @@ export const useMonoVertexViewFetch = (
if (pipeline && vertices?.length > 0) {
setLoading(false);
}
}, [pipeline, vertices]);
}, [pipeline, vertices, replicas]);

return {
pipeline,
Expand Down
4 changes: 3 additions & 1 deletion ui/src/utils/fetcherHooks/pipelineViewFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ export const usePipelineViewFetch = (
`${json.data?.pipeline?.metadata?.namespace}-${json.data.pipeline?.metadata?.name}-`
);
// Update spec state if it is not equal to the spec from the response
if (!isEqual(spec, json.data)) setSpec(json.data?.pipeline?.spec);
if (!isEqual(spec, json.data?.pipeline?.spec)) {
setSpec(json.data.pipeline.spec);
}
setPipelineErr(undefined);
} else if (json?.errMsg) {
// pipeline API call returns an error message
Expand Down

0 comments on commit 4267113

Please sign in to comment.