Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/utils/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const PIPELINE_TAGS_ANNOTATION = "tags";
export const PIPELINE_CANONICAL_NAME_ANNOTATION = "canonical-pipeline-name";
export const RUN_NAME_TEMPLATE_ANNOTATION = "run-name-template";
export const RUN_SOURCE_ANNOTATION = "source";
export const ORCHESTRATION_TARGET_CLUSTER_ANNOTATION =
"tangleml.com/orchestration/target_cluster";
export const EDITOR_POSITION_ANNOTATION = "editor.position";
export const EDITOR_COLLAPSED_ANNOTATION = "editor.collapsed";
export const EDITOR_FLOW_DIRECTION_ANNOTATION = "editor.flow-direction";
Expand Down
37 changes: 37 additions & 0 deletions src/utils/submitPipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,43 @@ describe("submitPipelineRun", () => {
});
});

describe("targetCluster handling", () => {
const componentSpec: ComponentSpec = {
name: "simple-component",
implementation: {
container: {
image: "test:latest",
},
},
};

it("adds the target_cluster annotation when targetCluster is set", async () => {
await submitPipelineRun(componentSpec, mockBackendUrl, {
targetCluster: "ml-offline-us-ce1-eo9",
});

expect(pipelineRunService.createPipelineRun).toHaveBeenCalledWith(
expect.objectContaining({
annotations: {
source: "web-app",
"tangleml.com/orchestration/target_cluster":
"ml-offline-us-ce1-eo9",
},
}),
mockBackendUrl,
undefined,
);
});

it("leaves run annotations unchanged when targetCluster is unset", async () => {
await submitPipelineRun(componentSpec, mockBackendUrl, {});

const payload = vi.mocked(pipelineRunService.createPipelineRun).mock
.calls[0][0];
expect(payload.annotations).toEqual({ source: "web-app" });
});
});

describe("taskArguments handling", () => {
it("should include taskArguments in payload when provided", async () => {
// Arrange
Expand Down
14 changes: 13 additions & 1 deletion src/utils/submitPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
import type { PipelineRun } from "@/types/pipelineRun";

import { transformAggregatorComponentSpec } from "./aggregatorTransform";
import { RUN_SOURCE_ANNOTATION } from "./annotations";
import {
ORCHESTRATION_TARGET_CLUSTER_ANNOTATION,
RUN_SOURCE_ANNOTATION,
} from "./annotations";
import { buildAnnotationsWithCanonicalName } from "./canonicalPipelineName";
import type {
ArgumentType,
Expand All @@ -30,6 +33,7 @@ export async function submitPipelineRun(
authorizationToken?: string;
runNameOverride?: boolean;
canonicalName?: string;
targetCluster?: string;
onSuccess?: (data: PipelineRun) => void;
onError?: (error: Error) => void;
},
Expand Down Expand Up @@ -91,6 +95,14 @@ export async function submitPipelineRun(
const payload = {
annotations: {
[RUN_SOURCE_ANNOTATION]: "web-app",
// Opt-in override selecting which execution cluster the orchestrator
// routes this run to. Omitted entirely when unset, so the default
// routing (and the run payload) is unchanged.
...(options?.targetCluster
? {
[ORCHESTRATION_TARGET_CLUSTER_ANNOTATION]: options.targetCluster,
}
: {}),
},
root_task: {
componentRef: {
Expand Down
Loading