Skip to content

Commit

Permalink
move datafile update into "SMF ok!" branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jmpesp committed May 10, 2023
1 parent 03086e6 commit bc0ba2d
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ fn worker(
info!(log, "SMF ok!");
}
}

State::Tombstoned => {
info!(log, "applying SMF actions before removal...");
let result = apply_smf(
Expand Down Expand Up @@ -907,6 +908,7 @@ fn worker(
rs.id.0,
rs.state,
);

let result = apply_smf(
&log,
&df,
Expand All @@ -919,36 +921,37 @@ fn worker(
error!(log, "SMF application failure: {:?}", e);
} else {
info!(log, "SMF ok!");
}

// `apply_smf` returned Ok, so the desired state transition
// succeeded: update the datafile.
let res = match &rs.state {
State::Requested => {
df.created_rs(&region_id, &snapshot_name)
}
// `apply_smf` returned Ok, so the desired state transition
// succeeded: update the datafile.
let res = match &rs.state {
State::Requested => {
df.created_rs(&region_id, &snapshot_name)
}

State::Tombstoned => {
df.destroyed_rs(&region_id, &snapshot_name)
}
State::Tombstoned => {
df.destroyed_rs(&region_id, &snapshot_name)
}

_ => {
eprintln!(
"worker got unexpected running snapshot state: {:?}",
rs,
_ => {
eprintln!(
"worker got unexpected running snapshot state: {:?}",
rs,
);
std::process::exit(1);
}
};

if let Err(e) = res {
error!(
log,
"running snapshot {} state change failed: {:?}",
rs.id.0,
e
);
std::process::exit(1);
}
};

if let Err(e) = res {
error!(
log,
"running snapshot {} state change failed: {:?}",
rs.id.0,
e
);
df.fail_rs(&region_id, &snapshot_name);
df.fail_rs(&region_id, &snapshot_name);
}
}
}
}
Expand Down

0 comments on commit bc0ba2d

Please sign in to comment.