Skip to content

Commit

Permalink
Use regions_dataset path for apply_smf (#1000)
Browse files Browse the repository at this point in the history
`apply_smf`'s `dataset` argument is meant to be for the regions dataset,
not the specific region dataset.

Additionally, panic if regions_dataset.path() returns Err: the agent
requires a valid regions dataset and path to work.
  • Loading branch information
jmpesp authored Oct 13, 2023
1 parent b7a6856 commit 657d985
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum Args {
},
}

#[derive(Debug)]
pub struct ZFSDataset {
dataset: String,
}
Expand Down Expand Up @@ -1527,6 +1528,16 @@ fn worker(
downstairs_prefix: String,
snapshot_prefix: String,
) {
let regions_dataset_path = match regions_dataset.path() {
Ok(regions_dataset_path) => regions_dataset_path,
Err(e) => {
panic!(
"Cannot get regions_dataset_path for {:?}: {}",
regions_dataset, e,
);
}
};

loop {
/*
* This loop fires whenever there's work to do. This work may be:
Expand Down Expand Up @@ -1638,7 +1649,7 @@ fn worker(
let result = apply_smf(
&log,
&df,
dataset_path,
regions_dataset_path.clone(),
&downstairs_prefix,
&snapshot_prefix,
);
Expand All @@ -1651,24 +1662,11 @@ fn worker(
}

State::Tombstoned => 'tombstoned: {
let dataset_path = match regions_dataset.path() {
Ok(dataset_path) => dataset_path,
Err(e) => {
error!(
log,
"Cannot get path on tombstoned dataset {}: {}",
&r.id.0,
e,
);
df.fail(&r.id);
break 'tombstoned;
}
};
info!(log, "applying SMF actions before removal...");
let result = apply_smf(
&log,
&df,
dataset_path,
regions_dataset_path.clone(),
&downstairs_prefix,
&snapshot_prefix,
);
Expand Down Expand Up @@ -1741,7 +1739,7 @@ fn worker(
let result = apply_smf(
&log,
&df,
regions_dataset.path().unwrap(),
regions_dataset_path.clone(),
&downstairs_prefix,
&snapshot_prefix,
);
Expand Down

0 comments on commit 657d985

Please sign in to comment.