Skip to content

Commit

Permalink
Temporarily disable region snapshot replacement (#6728)
Browse files Browse the repository at this point in the history
Until read-only region reference counting is implemented, region
snapshot replacement should be disabled - it is currently the only thing
that creates read-only regions.
  • Loading branch information
jmpesp authored Sep 30, 2024
1 parent f0b8048 commit 469522d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 16 deletions.
32 changes: 20 additions & 12 deletions nexus/src/app/background/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,8 @@ impl BackgroundTasksInitializer {
"detect if region snapshots need replacement and begin the \
process",
period: config.region_snapshot_replacement_start.period_secs,
task_impl: Box::new(RegionSnapshotReplacementDetector::new(
// XXX temporarily disabled, see oxidecomputer/omicron#6353
task_impl: Box::new(RegionSnapshotReplacementDetector::disabled(
datastore.clone(),
sagas.clone(),
)),
Expand All @@ -794,10 +795,13 @@ impl BackgroundTasksInitializer {
period: config
.region_snapshot_replacement_garbage_collection
.period_secs,
task_impl: Box::new(RegionSnapshotReplacementGarbageCollect::new(
datastore.clone(),
sagas.clone(),
)),
// XXX temporarily disabled, see oxidecomputer/omicron#6353
task_impl: Box::new(
RegionSnapshotReplacementGarbageCollect::disabled(
datastore.clone(),
sagas.clone(),
),
),
opctx: opctx.child(BTreeMap::new()),
watchers: vec![],
activator: task_region_snapshot_replacement_garbage_collection,
Expand All @@ -809,10 +813,13 @@ impl BackgroundTasksInitializer {
"detect what volumes were affected by a region snapshot \
replacement, and run the step saga for them",
period: config.region_snapshot_replacement_step.period_secs,
task_impl: Box::new(RegionSnapshotReplacementFindAffected::new(
datastore.clone(),
sagas.clone(),
)),
// XXX temporarily disabled, see oxidecomputer/omicron#6353
task_impl: Box::new(
RegionSnapshotReplacementFindAffected::disabled(
datastore.clone(),
sagas.clone(),
),
),
opctx: opctx.child(BTreeMap::new()),
watchers: vec![],
activator: task_region_snapshot_replacement_step,
Expand All @@ -824,9 +831,10 @@ impl BackgroundTasksInitializer {
"complete a region snapshot replacement if all the steps are \
done",
period: config.region_snapshot_replacement_finish.period_secs,
task_impl: Box::new(RegionSnapshotReplacementFinishDetector::new(
datastore,
)),
// XXX temporarily disabled, see oxidecomputer/omicron#6353
task_impl: Box::new(
RegionSnapshotReplacementFinishDetector::disabled(datastore),
),
opctx: opctx.child(BTreeMap::new()),
watchers: vec![],
activator: task_region_snapshot_replacement_finish,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ use std::sync::Arc;

pub struct RegionSnapshotReplacementFinishDetector {
datastore: Arc<DataStore>,
disabled: bool,
}

impl RegionSnapshotReplacementFinishDetector {
#[allow(dead_code)]
pub fn new(datastore: Arc<DataStore>) -> Self {
RegionSnapshotReplacementFinishDetector { datastore }
RegionSnapshotReplacementFinishDetector { datastore, disabled: false }
}

pub fn disabled(datastore: Arc<DataStore>) -> Self {
RegionSnapshotReplacementFinishDetector { datastore, disabled: true }
}

async fn transition_requests_to_done(
Expand Down Expand Up @@ -153,6 +159,10 @@ impl BackgroundTask for RegionSnapshotReplacementFinishDetector {
async move {
let mut status = RegionSnapshotReplacementFinishStatus::default();

if self.disabled {
return json!(status);
}

self.transition_requests_to_done(opctx, &mut status).await;

json!(status)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,28 @@ use std::sync::Arc;
pub struct RegionSnapshotReplacementGarbageCollect {
datastore: Arc<DataStore>,
sagas: Arc<dyn StartSaga>,
disabled: bool,
}

impl RegionSnapshotReplacementGarbageCollect {
#[allow(dead_code)]
pub fn new(datastore: Arc<DataStore>, sagas: Arc<dyn StartSaga>) -> Self {
RegionSnapshotReplacementGarbageCollect { datastore, sagas }
RegionSnapshotReplacementGarbageCollect {
datastore,
sagas,
disabled: false,
}
}

pub fn disabled(
datastore: Arc<DataStore>,
sagas: Arc<dyn StartSaga>,
) -> Self {
RegionSnapshotReplacementGarbageCollect {
datastore,
sagas,
disabled: true,
}
}

async fn send_garbage_collect_request(
Expand Down Expand Up @@ -135,6 +152,10 @@ impl BackgroundTask for RegionSnapshotReplacementGarbageCollect {
let mut status =
RegionSnapshotReplacementGarbageCollectStatus::default();

if self.disabled {
return json!(status);
}

self.clean_up_region_snapshot_replacement_volumes(
opctx,
&mut status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,20 @@ use std::sync::Arc;
pub struct RegionSnapshotReplacementDetector {
datastore: Arc<DataStore>,
sagas: Arc<dyn StartSaga>,
disabled: bool,
}

impl RegionSnapshotReplacementDetector {
#[allow(dead_code)]
pub fn new(datastore: Arc<DataStore>, sagas: Arc<dyn StartSaga>) -> Self {
RegionSnapshotReplacementDetector { datastore, sagas }
RegionSnapshotReplacementDetector { datastore, sagas, disabled: false }
}

pub fn disabled(
datastore: Arc<DataStore>,
sagas: Arc<dyn StartSaga>,
) -> Self {
RegionSnapshotReplacementDetector { datastore, sagas, disabled: true }
}

async fn send_start_request(
Expand Down Expand Up @@ -237,6 +246,10 @@ impl BackgroundTask for RegionSnapshotReplacementDetector {
async {
let mut status = RegionSnapshotReplacementStartStatus::default();

if self.disabled {
return json!(status);
}

self.create_requests_for_region_snapshots_on_expunged_disks(
opctx,
&mut status,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,28 @@ use std::sync::Arc;
pub struct RegionSnapshotReplacementFindAffected {
datastore: Arc<DataStore>,
sagas: Arc<dyn StartSaga>,
disabled: bool,
}

impl RegionSnapshotReplacementFindAffected {
#[allow(dead_code)]
pub fn new(datastore: Arc<DataStore>, sagas: Arc<dyn StartSaga>) -> Self {
RegionSnapshotReplacementFindAffected { datastore, sagas }
RegionSnapshotReplacementFindAffected {
datastore,
sagas,
disabled: false,
}
}

pub fn disabled(
datastore: Arc<DataStore>,
sagas: Arc<dyn StartSaga>,
) -> Self {
RegionSnapshotReplacementFindAffected {
datastore,
sagas,
disabled: true,
}
}

async fn send_start_request(
Expand Down Expand Up @@ -435,6 +452,10 @@ impl BackgroundTask for RegionSnapshotReplacementFindAffected {
async move {
let mut status = RegionSnapshotReplacementStepStatus::default();

if self.disabled {
return json!(status);
}

// Importantly, clean old steps up before finding affected volumes!
// Otherwise, will continue to find the snapshot in volumes to
// delete, and will continue to see conflicts in next function.
Expand Down

0 comments on commit 469522d

Please sign in to comment.