Skip to content

Commit

Permalink
Unbreak stopping unloadable schedules/sensors (#7446)
Browse files Browse the repository at this point in the history
Summary:
The new stop mutations assume that the ExternalSensor can be loaded, which is not the case for unloadable schedules and sensors. Getting this right requires threading the selector ID all the way through into the mutation path (at least in the unloadable path, but might as well do it everywhere for consistency)

Will add a test at the graphql python level as well.
  • Loading branch information
gibsondan committed Apr 14, 2022
1 parent bb27b2d commit 0bc57e9
Show file tree
Hide file tree
Showing 40 changed files with 235 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def test_execute_schedule_on_celery_k8s( # pylint: disable=redefined-outer-name

finally:
dagster_instance_for_daemon.stop_schedule(
reoriginated_schedule.get_external_origin_id(), reoriginated_schedule
reoriginated_schedule.get_external_origin_id(),
reoriginated_schedule.selector_id,
reoriginated_schedule,
)

last_run = schedule_runs[0]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js_modules/dagit/packages/core/src/assets/types/AssetQuery.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions js_modules/dagit/packages/core/src/graphql/schema.graphql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const RUN_STATUS_FRAGMENT = gql`
export const INSTIGATION_STATE_FRAGMENT = gql`
fragment InstigationStateFragment on InstigationState {
id
selectorId
name
instigationType
status
Expand Down
8 changes: 4 additions & 4 deletions js_modules/dagit/packages/core/src/instigation/Unloadable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ const UnloadableScheduleInfo = () => (
);

const SensorStateRow = ({sensorState}: {sensorState: InstigationStateFragment}) => {
const {id, name, status, repositoryOrigin, ticks} = sensorState;
const {id, selectorId, name, status, repositoryOrigin, ticks} = sensorState;

const [stopSensor, {loading: toggleOffInFlight}] = useMutation<StopSensor>(STOP_SENSOR_MUTATION, {
onCompleted: displaySensorMutationErrors,
Expand All @@ -150,7 +150,7 @@ const SensorStateRow = ({sensorState}: {sensorState: InstigationStateFragment})
'If you turn it off, you will not be able to turn it back on from ' +
'the currently loaded workspace.',
});
stopSensor({variables: {jobOriginId: id}});
stopSensor({variables: {jobOriginId: id, jobSelectorId: selectorId}});
}
};

Expand Down Expand Up @@ -206,7 +206,7 @@ const ScheduleStateRow: React.FC<{
);
const [showRepositoryOrigin, setShowRepositoryOrigin] = React.useState(false);
const confirm = useConfirmation();
const {id, name, ticks, status, repositoryOrigin, typeSpecificData} = scheduleState;
const {id, selectorId, name, ticks, status, repositoryOrigin, typeSpecificData} = scheduleState;
const latestTick = ticks.length > 0 ? ticks[0] : null;
const cronSchedule =
typeSpecificData && typeSpecificData.__typename === 'ScheduleData'
Expand All @@ -221,7 +221,7 @@ const ScheduleStateRow: React.FC<{
'If you turn it off, you will not be able to turn it back on from ' +
'the currently loaded workspace.',
});
stopSchedule({variables: {scheduleOriginId: id}});
stopSchedule({variables: {scheduleOriginId: id, scheduleSelectorId: selectorId}});
}
};

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ export const START_SCHEDULE_MUTATION = gql`
`;

export const STOP_SCHEDULE_MUTATION = gql`
mutation StopSchedule($scheduleOriginId: String!) {
stopRunningSchedule(scheduleOriginId: $scheduleOriginId) {
mutation StopSchedule($scheduleOriginId: String!, $scheduleSelectorId: String!) {
stopRunningSchedule(
scheduleOriginId: $scheduleOriginId
scheduleSelectorId: $scheduleSelectorId
) {
__typename
... on ScheduleStateResult {
scheduleState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface Props {
export const ScheduleSwitch: React.FC<Props> = (props) => {
const {repoAddress, schedule, size = 'large'} = props;
const {name, scheduleState} = schedule;
const {status, id} = scheduleState;
const {status, id, selectorId} = scheduleState;

const {canStartSchedule, canStopRunningSchedule} = usePermissions();

Expand All @@ -50,7 +50,7 @@ export const ScheduleSwitch: React.FC<Props> = (props) => {
const onStatusChange = () => {
if (status === InstigationStatus.RUNNING) {
stopSchedule({
variables: {scheduleOriginId: id},
variables: {scheduleOriginId: id, scheduleSelectorId: selectorId},
});
} else {
startSchedule({
Expand Down Expand Up @@ -102,6 +102,7 @@ export const SCHEDULE_SWITCH_FRAGMENT = gql`
cronSchedule
scheduleState {
id
selectorId
status
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const START_SENSOR_MUTATION = gql`
`;

export const STOP_SENSOR_MUTATION = gql`
mutation StopSensor($jobOriginId: String!) {
stopSensor(jobOriginId: $jobOriginId) {
mutation StopSensor($jobOriginId: String!, $jobSelectorId: String!) {
stopSensor(jobOriginId: $jobOriginId, jobSelectorId: $jobSelectorId) {
__typename
... on StopSensorMutationResult {
instigationState {
Expand Down
5 changes: 3 additions & 2 deletions js_modules/dagit/packages/core/src/sensors/SensorSwitch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const SensorSwitch: React.FC<Props> = (props) => {
const {canStartSensor, canStopSensor} = usePermissions();

const {jobOriginId, name, sensorState} = sensor;
const {status} = sensorState;
const {status, selectorId} = sensorState;
const sensorSelector = {
...repoAddressToSelector(repoAddress),
sensorName: name,
Expand All @@ -43,7 +43,7 @@ export const SensorSwitch: React.FC<Props> = (props) => {

const onChangeSwitch = () => {
if (status === InstigationStatus.RUNNING) {
stopSensor({variables: {jobOriginId}});
stopSensor({variables: {jobOriginId, jobSelectorId: selectorId}});
} else {
startSensor({variables: {sensorSelector}});
}
Expand Down Expand Up @@ -92,6 +92,7 @@ export const SENSOR_SWITCH_FRAGMENT = gql`
name
sensorState {
id
selectorId
status
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0bc57e9

Please sign in to comment.