Skip to content

Commit 1cbca02

Browse files
authored
Fix sync started Nexus ops not coming across as such (#901)
1 parent e18982e commit 1cbca02

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

core/src/worker/workflow/machines/nexus_operation_state_machine.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ fsm! {
7676
pub(super) enum NexusOperationCommand {
7777
#[display("Start")]
7878
Start { operation_id: String },
79+
#[display("StartSync")]
80+
StartSync,
7981
#[display("CancelBeforeStart")]
8082
CancelBeforeStart,
8183
#[display("Complete")]
@@ -185,9 +187,7 @@ impl ScheduledEventRecorded {
185187
ca: NexusOperationCompletedEventAttributes,
186188
) -> NexusOperationMachineTransition<Completed> {
187189
NexusOperationMachineTransition::commands([
188-
NexusOperationCommand::Start {
189-
operation_id: String::default(),
190-
},
190+
NexusOperationCommand::StartSync,
191191
NexusOperationCommand::Complete(ca.result),
192192
])
193193
}
@@ -197,9 +197,7 @@ impl ScheduledEventRecorded {
197197
fa: NexusOperationFailedEventAttributes,
198198
) -> NexusOperationMachineTransition<Failed> {
199199
NexusOperationMachineTransition::commands([
200-
NexusOperationCommand::Start {
201-
operation_id: String::default(),
202-
},
200+
NexusOperationCommand::StartSync,
203201
NexusOperationCommand::Fail(fa.failure.unwrap_or_else(|| Failure {
204202
message: "Nexus operation failed but failure field was not populated".to_owned(),
205203
..Default::default()
@@ -212,9 +210,7 @@ impl ScheduledEventRecorded {
212210
ca: NexusOperationCanceledEventAttributes,
213211
) -> NexusOperationMachineTransition<Cancelled> {
214212
NexusOperationMachineTransition::commands([
215-
NexusOperationCommand::Start {
216-
operation_id: String::default(),
217-
},
213+
NexusOperationCommand::StartSync,
218214
NexusOperationCommand::Cancel(ca.failure.unwrap_or_else(|| Failure {
219215
message:
220216
"Nexus operation was cancelled but failure field was not populated".to_owned(),
@@ -228,9 +224,7 @@ impl ScheduledEventRecorded {
228224
toa: NexusOperationTimedOutEventAttributes,
229225
) -> NexusOperationMachineTransition<TimedOut> {
230226
NexusOperationMachineTransition::commands([
231-
NexusOperationCommand::Start {
232-
operation_id: String::default(),
233-
},
227+
NexusOperationCommand::StartSync,
234228
NexusOperationCommand::TimedOut(toa.failure.unwrap_or_else(|| Failure {
235229
message: "Nexus operation timed out but failure field was not populated".to_owned(),
236230
..Default::default()
@@ -412,6 +406,15 @@ impl WFMachinesAdapter for NexusOperationMachine {
412406
_: Option<EventInfo>,
413407
) -> Result<Vec<MachineResponse>, WFMachinesError> {
414408
Ok(match my_command {
409+
NexusOperationCommand::StartSync => {
410+
vec![
411+
ResolveNexusOperationStart {
412+
seq: self.shared_state.lang_seq_num,
413+
status: Some(resolve_nexus_operation_start::Status::StartedSync(true)),
414+
}
415+
.into(),
416+
]
417+
}
415418
NexusOperationCommand::Start { operation_id } => {
416419
vec![
417420
ResolveNexusOperationStart {

tests/integ_tests/workflow_tests/nexus.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ async fn nexus_basic(
6262
})
6363
.await
6464
.unwrap();
65+
assert_eq!(started.operation_id, None);
6566
let res = started.result().await;
6667
Ok(res.into())
6768
}

0 commit comments

Comments
 (0)