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

Reuse existing executionClusterLabel value during relaunch #minor #873

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"tslib": "^2.4.1"
},
"dependencies": {
"@flyteorg/flyteidl": "^1.10.7",
"@flyteorg/flyteidl": "^1.11.1-b1",
"@protobuf-ts/runtime": "^2.6.0",
"@protobuf-ts/runtime-rpc": "^2.6.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function useRelaunchWorkflowFormState({ execution }: RelaunchExecutionFormProps)
securityContext,
interruptible,
overwriteCache,
executionClusterLabel,
},
} = execution;

Expand All @@ -63,6 +64,7 @@ function useRelaunchWorkflowFormState({ execution }: RelaunchExecutionFormProps)
securityContext,
interruptible,
overwriteCache,
executionClusterLabel,
};
},
},
Expand All @@ -78,7 +80,7 @@ function useRelaunchTaskFormState({ execution }: RelaunchExecutionFormProps) {
defaultValue: {} as TaskInitialLaunchParameters,
doFetch: async (execution) => {
const {
spec: { authRole, launchPlan: taskId, interruptible, overwriteCache },
spec: { authRole, launchPlan: taskId, interruptible, overwriteCache, executionClusterLabel },
} = execution;
const task = await apiContext.getTask(taskId);
const inputDefinitions = getTaskInputs(task);
Expand All @@ -89,7 +91,7 @@ function useRelaunchTaskFormState({ execution }: RelaunchExecutionFormProps) {
},
apiContext,
);
return { authRole, values, taskId, interruptible, overwriteCache };
return { authRole, values, taskId, interruptible, overwriteCache, executionClusterLabel };
},
},
execution,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum ExecutionMetadataLabels {
securityContextDefault = 'default',
interruptible = 'Interruptible override',
overwriteCache = 'Overwrite cached outputs',
executionClusterLabel = 'Execution Cluster Label',
parent = 'Parent',
labels = 'Labels',
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,29 @@ describe('RelaunchExecutionForm', () => {
}),
});
});

it('should have correct execution cluster label', async () => {
execution.spec.executionClusterLabel = {
value: 'label'
};
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
executionClusterLabel: execution.spec.executionClusterLabel,
}),
});
});

it('should have null execution cluster label', async () => {
const { getByText } = renderForm();
await waitFor(() => expect(getByText(mockContentString)));
checkLaunchFormProps({
initialParameters: expect.objectContaining({
executionClusterLabel: undefined,
}),
});
});
});

describe('Launch form with full inputs', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface WorkflowLaunchContext extends BaseLaunchContext {
securityContext?: Core.ISecurityContext | null;
interruptible?: Protobuf.IBoolValue | null;
overwriteCache?: boolean | null;
executionClusterLabel?: Admin.IExecutionClusterLabel | null;
}

export interface TaskLaunchContext extends BaseLaunchContext {
Expand All @@ -105,6 +106,7 @@ export interface TaskLaunchContext extends BaseLaunchContext {
taskVersionOptions?: Task[];
interruptible?: Protobuf.IBoolValue | null;
overwriteCache?: boolean | null;
executionClusterLabel?: Admin.IExecutionClusterLabel | null;
}

export interface TaskResumeContext extends BaseLaunchContext {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface WorkflowInitialLaunchParameters extends BaseInitialLaunchParame
annotations?: Admin.IAnnotations | null;
interruptible?: Protobuf.IBoolValue | null;
overwriteCache?: boolean | null;
executionClusterLabel?: Admin.IExecutionClusterLabel | null;
}

export interface LaunchWorkflowFormProps extends BaseLaunchFormProps {
Expand All @@ -82,6 +83,7 @@ export interface TaskInitialLaunchParameters extends BaseInitialLaunchParameters
securityContext?: Core.ISecurityContext;
interruptible?: Protobuf.IBoolValue | null;
overwriteCache?: boolean | null;
executionClusterLabel?: Admin.IExecutionClusterLabel | null;
}
export interface LaunchTaskFormProps extends BaseLaunchFormProps {
taskId: NamedEntityIdentifier;
Expand Down Expand Up @@ -115,6 +117,11 @@ export interface LaunchInterruptibleInputRef {
validate(): boolean;
}

export interface LaunchExecutionClusterLabelInputRef {
getValue(): Admin.IExecutionClusterLabel | null | undefined;
validate(): boolean;
}

export interface LaunchAdvancedOptionsRef {
getValues(): Admin.IExecutionSpec;
validate(): boolean;
Expand Down Expand Up @@ -143,6 +150,7 @@ export interface LaunchWorkflowFormState {
roleInputRef: React.RefObject<LaunchRoleInputRef>;
interruptibleInputRef: React.RefObject<LaunchInterruptibleInputRef>;
overwriteCacheInputRef: React.RefObject<LaunchOverwriteCacheInputRef>;
executionClusterLabelInputRef: React.RefObject<LaunchExecutionClusterLabelInputRef>;
state: State<WorkflowLaunchContext, WorkflowLaunchEvent, any, WorkflowLaunchTypestate>;
service: Interpreter<WorkflowLaunchContext, any, WorkflowLaunchEvent, WorkflowLaunchTypestate>;
workflowSourceSelectorState: WorkflowSourceSelectorState;
Expand All @@ -153,6 +161,7 @@ export interface LaunchTaskFormState {
roleInputRef: React.RefObject<LaunchRoleInputRef>;
interruptibleInputRef: React.RefObject<LaunchInterruptibleInputRef>;
overwriteCacheInputRef: React.RefObject<LaunchOverwriteCacheInputRef>;
executionClusterLabelInputRef: React.RefObject<LaunchExecutionClusterLabelInputRef>;
state: State<TaskLaunchContext, TaskLaunchEvent, any, TaskLaunchTypestate>;
service: Interpreter<TaskLaunchContext, any, TaskLaunchEvent, TaskLaunchTypestate>;
taskSourceSelectorState: TaskSourceSelectorState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from './launchMachine';
import { validate as baseValidate } from './services';
import {
LaunchFormInputsRef,
LaunchExecutionClusterLabelInputRef, LaunchFormInputsRef,
LaunchInterruptibleInputRef,
LaunchOverwriteCacheInputRef,
LaunchRoleInputRef,
Expand Down Expand Up @@ -116,6 +116,7 @@ async function submit(
roleInputRef: RefObject<LaunchRoleInputRef>,
interruptibleInputRef: RefObject<LaunchInterruptibleInputRef>,
overwriteCacheInputRef: RefObject<LaunchOverwriteCacheInputRef>,
executionClusterLabelInputRef: RefObject<LaunchExecutionClusterLabelInputRef>,
{ referenceExecutionId, taskVersion }: TaskLaunchContext,
) {
if (!taskVersion) {
Expand All @@ -132,6 +133,7 @@ async function submit(
const literals = formInputsRef.current.getValues();
const interruptible = interruptibleInputRef.current?.getValue();
const overwriteCache = overwriteCacheInputRef.current?.getValue();
const executionClusterLabel = executionClusterLabelInputRef.current?.getValue();
const launchPlanId = taskVersion;
const { domain, project } = taskVersion;

Expand All @@ -144,6 +146,7 @@ async function submit(
inputs: { literals },
interruptible,
overwriteCache,
executionClusterLabel,
});
const newExecutionId = response.id as WorkflowExecutionIdentifier;
if (!newExecutionId) {
Expand All @@ -159,6 +162,7 @@ function getServices(
roleInputRef: RefObject<LaunchRoleInputRef>,
interruptibleInputRef: RefObject<LaunchInterruptibleInputRef>,
overwriteCacheInputRef: RefObject<LaunchOverwriteCacheInputRef>,
executionClusterLabelInputRef: RefObject<LaunchExecutionClusterLabelInputRef>,
) {
return {
loadTaskVersions: partial(loadTaskVersions, apiContext),
Expand All @@ -170,6 +174,7 @@ function getServices(
roleInputRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
launchContext,
),
validate: partial(
Expand Down Expand Up @@ -198,13 +203,18 @@ export function useLaunchTaskFormState({
values: defaultInputValues,
interruptible,
overwriteCache,
executionClusterLabel,
} = initialParameters;

const apiContext = useAPIContext();
const formInputsRef = useRef<LaunchFormInputsRef>(null);
const roleInputRef = useRef<LaunchRoleInputRef>(null);
const interruptibleInputRef = useRef<LaunchInterruptibleInputRef>(null);
const overwriteCacheInputRef = useRef<LaunchOverwriteCacheInputRef>(null);
const executionClusterLabelInputRef = useRef<LaunchExecutionClusterLabelInputRef>({
getValue: () => executionClusterLabel,
validate: () => true,
});

const services = useMemo(
() =>
Expand All @@ -214,8 +224,9 @@ export function useLaunchTaskFormState({
roleInputRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
),
[apiContext, formInputsRef, roleInputRef, interruptibleInputRef, overwriteCacheInputRef],
[apiContext, formInputsRef, roleInputRef, interruptibleInputRef, overwriteCacheInputRef, executionClusterLabelInputRef],
);

const [state, sendEvent, service] = useMachine<
Expand All @@ -233,6 +244,7 @@ export function useLaunchTaskFormState({
sourceId,
interruptible,
overwriteCache,
executionClusterLabel,
},
});

Expand Down Expand Up @@ -286,6 +298,7 @@ export function useLaunchTaskFormState({
roleInputRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
state,
service,
taskSourceSelectorState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
LaunchRoles,
LaunchInterruptibleInputRef,
LaunchOverwriteCacheInputRef,
LaunchRoleInputRef,
LaunchRoleInputRef, LaunchExecutionClusterLabelInputRef,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: move to separate line.

} from './types';
import { useWorkflowSourceSelectorState } from './useWorkflowSourceSelectorState';
import { getUnsupportedRequiredInputs } from './utils';
Expand Down Expand Up @@ -165,6 +165,7 @@ async function submit(
advancedOptionsRef: RefObject<LaunchAdvancedOptionsRef>,
interruptibleInputRef: RefObject<LaunchInterruptibleInputRef>,
overwriteCacheInputRef: RefObject<LaunchOverwriteCacheInputRef>,
executionClusterLabelInputRef: RefObject<LaunchExecutionClusterLabelInputRef>,
{ launchPlan, referenceExecutionId, workflowVersion }: WorkflowLaunchContext,
) {
if (!launchPlan) {
Expand All @@ -183,6 +184,7 @@ async function submit(
advancedOptionsRef.current?.getValues() || {};
const interruptible = interruptibleInputRef.current?.getValue();
const overwriteCache = overwriteCacheInputRef.current?.getValue();
const executionClusterLabel = executionClusterLabelInputRef.current?.getValue();
const launchPlanId = launchPlan.id;
const { domain, project } = workflowVersion;

Expand All @@ -200,6 +202,7 @@ async function submit(
inputs: { literals },
interruptible,
overwriteCache,
executionClusterLabel,
});
const newExecutionId = response.id as WorkflowExecutionIdentifier;
if (!newExecutionId) {
Expand Down Expand Up @@ -229,6 +232,7 @@ function getServices(
advancedOptionsRef: RefObject<LaunchAdvancedOptionsRef>,
interruptibleInputRef: RefObject<LaunchInterruptibleInputRef>,
overwriteCacheInputRef: RefObject<LaunchOverwriteCacheInputRef>,
executionClusterLabelInputRef: RefObject<LaunchExecutionClusterLabelInputRef>,
) {
return {
loadWorkflowVersions: partial(loadWorkflowVersions, apiContext),
Expand All @@ -245,6 +249,7 @@ function getServices(
advancedOptionsRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
launchContext,
),
validate: () =>
Expand Down Expand Up @@ -281,6 +286,7 @@ export function useLaunchWorkflowFormState({
securityContext,
interruptible,
overwriteCache,
executionClusterLabel,
} = initialParameters;

const apiContext = useAPIContext();
Expand All @@ -289,6 +295,10 @@ export function useLaunchWorkflowFormState({
const advancedOptionsRef = useRef<LaunchAdvancedOptionsRef>(null);
const interruptibleInputRef = useRef<LaunchInterruptibleInputRef>(null);
const overwriteCacheInputRef = useRef<LaunchOverwriteCacheInputRef>(null);
const executionClusterLabelInputRef = useRef<LaunchExecutionClusterLabelInputRef>({
getValue: () => executionClusterLabel,
validate: () => true,
});

const services = useMemo(
() =>
Expand All @@ -299,6 +309,7 @@ export function useLaunchWorkflowFormState({
advancedOptionsRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
),
[
apiContext,
Expand All @@ -307,6 +318,7 @@ export function useLaunchWorkflowFormState({
advancedOptionsRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
],
);

Expand All @@ -332,6 +344,7 @@ export function useLaunchWorkflowFormState({
annotations,
interruptible,
overwriteCache,
executionClusterLabel,
},
});

Expand Down Expand Up @@ -448,6 +461,7 @@ export function useLaunchWorkflowFormState({
roleInputRef,
interruptibleInputRef,
overwriteCacheInputRef,
executionClusterLabelInputRef,
state,
service,
workflowSourceSelectorState,
Expand Down
3 changes: 3 additions & 0 deletions packages/oss-console/src/models/Execution/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export interface CreateWorkflowExecutionArguments {
referenceExecutionId?: WorkflowExecutionIdentifier;
interruptible?: Protobuf.IBoolValue | null;
overwriteCache?: boolean | null;
executionClusterLabel?: Admin.IExecutionClusterLabel | null;
}

/** Submits a request to create a new `WorkflowExecution` using the provided
Expand All @@ -135,6 +136,7 @@ export const createWorkflowExecution = (
referenceExecutionId: referenceExecution,
interruptible,
overwriteCache,
executionClusterLabel,
}: CreateWorkflowExecutionArguments,
config?: RequestConfig,
) => {
Expand All @@ -147,6 +149,7 @@ export const createWorkflowExecution = (
},
labels,
annotations,
executionClusterLabel,
};

if (securityContext?.runAs?.iamRole || securityContext?.runAs?.k8sServiceAccount) {
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2092,7 +2092,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@clients/common@workspace:packages/common"
dependencies:
"@flyteorg/flyteidl": ^1.10.7
"@flyteorg/flyteidl": ^1.11.1-b1
"@protobuf-ts/runtime": ^2.6.0
"@protobuf-ts/runtime-rpc": ^2.6.0
peerDependencies:
Expand Down Expand Up @@ -2941,10 +2941,10 @@ __metadata:
languageName: node
linkType: hard

"@flyteorg/flyteidl@npm:^1.10.7":
version: 1.10.7
resolution: "@flyteorg/flyteidl@npm:1.10.7"
checksum: fa559d1b5fc676a220fdfdad1a689affcc7e34e375e9755153f14f44e41a1637414ccf43b5eeab8b4d8cd3b1f5d36d30ae5d75922e391f45d50e0b3f593fb8bb
"@flyteorg/flyteidl@npm:^1.11.1-b1":
version: 1.11.1-b1
resolution: "@flyteorg/flyteidl@npm:1.11.1-b1"
checksum: 2d0932231b269c6b8d58d69caccf28c5a9222a64a448016cc5cbc0662e6d4d2445a17e403c61a459ec7998c85c4e07d4641c55cb3f1d967c468a7cdcc818f135
languageName: node
linkType: hard

Expand Down
Loading