Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/loader/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ impl LoaderZoneHandle<'_> {
/// Start a pending enqueued refresh.
///
/// This should be called when the zone data storage is in the passive
/// state. If a load has been enqueued, it will be initiated (making the
/// data storage busy), and `true` will be returned.
/// state and the zone is not in maintenance mode. If a load has been
/// enqueued, it will be initiated (making the data storage busy), and
/// `true` will be returned.
///
/// ## Panics
///
Expand Down
5 changes: 3 additions & 2 deletions src/signer/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@ impl SignerZoneHandle<'_> {
/// Start a pending enqueued re-sign.
///
/// This should be called when the zone state machine is in the waiting
/// state. If a re-sign has been enqueued, it will be initiated (making the
/// data storage busy), and `true` will be returned.
/// state and the zone is not in maintenance mode. If a re-sign has been
/// enqueued, it will be initiated (making the data storage busy), and
/// `true` will be returned.
///
/// This method cannot initiate enqueued new-signing operations (see
/// [`Self::enqueue_new_sign()`]); when a new-signing operation is enqueued,
Expand Down
20 changes: 5 additions & 15 deletions src/zone/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,10 @@ impl ZoneStateMachine {
/// # Initiating operations
impl<'a> ZoneHandle<'a> {
pub(crate) fn try_start_load(&mut self) -> Option<LoadedZoneBuilder> {
// If we're in maintenance mode, then we don't start this operation.
// TODO: distinguish between a manual load and an automatic one.
if self.state.maintenance_mode {
return None;
}

let ZoneStateMachine::Waiting(_) = &self.state.machine else {
info!("Could not start load since an operation is in progress on the zone.");
if !self.state.ready_for_operation() {
info!(
"Could not start load since an operation is in progress on the zone or the zone is in maintenance mode."
);
return None;
};

Expand All @@ -138,13 +134,7 @@ impl<'a> ZoneHandle<'a> {
}

pub(crate) fn try_start_resign(&mut self) -> Option<SignedZoneBuilder> {
// If we're in maintenance mode, then we don't start this operation.
// TODO: distinguish between a manual resign and an automatic one.
if self.state.maintenance_mode {
return None;
}

let ZoneStateMachine::Waiting(_) = &self.state.machine else {
if !self.state.ready_for_operation() {
info!("Could not start load since an operation is in progress on the zone.");
return None;
};
Expand Down
8 changes: 8 additions & 0 deletions src/zone/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,14 @@ impl ZoneState {
.find(|item| item.event.is_of_type(typ) && (serial.is_none() || item.serial == serial))
}

/// Whether the zone state is ready to start a new loading or signing operation
///
/// This checks the maintenance mode and the zone state machine.
pub fn ready_for_operation(&self) -> bool {
// TODO: distinguish between a manual load/sign and an automatic one.
!self.maintenance_mode && matches!(&self.machine, ZoneStateMachine::Waiting(_))
}

/// Get the most recent signed metadata for the zone.
///
/// During restore the metadata for the currently published instance is
Expand Down
2 changes: 2 additions & 0 deletions src/zone/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ impl Spec {
match self {
Self::V1(v1::Spec {
policy,
maintenance_mode,
instances,
source,
min_expiration,
Expand Down Expand Up @@ -135,6 +136,7 @@ impl Spec {
loader,
history,
persistence,
maintenance_mode,
..Default::default()
})
}
Expand Down
7 changes: 7 additions & 0 deletions src/zone/state/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ pub struct Spec {
/// version of the policy that is not yet in use.
pub policy: Option<PolicySpec>,

/// Whether the zone is in maintenance mode
///
/// Maintenance mode means that Cascade won't start loading and signing
/// operations automatically.
pub maintenance_mode: bool,

/// Instances of the zone.
pub instances: InstancesSpec,

Expand Down Expand Up @@ -125,6 +131,7 @@ impl Spec {
pub fn build(zone: &ZoneState) -> Self {
Self {
policy: zone.policy.as_ref().map(|p| PolicySpec::build(p)),
maintenance_mode: zone.maintenance_mode,
instances: InstancesSpec::build(&zone.instances),
source: ZoneLoadSourceSpec::build(&zone.loader.source),
min_expiration: zone.min_expiration,
Expand Down
4 changes: 2 additions & 2 deletions src/zone/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::{
persistence::zone::IxfrZoneDiffs,
server::{LoadedReviewServer, PublicationServer, SignedReviewServer},
util::BackgroundTasks,
zone::{Zone, ZoneHandle, ZoneState, machine::ZoneStateMachine},
zone::{Zone, ZoneHandle, ZoneState},
};

//----------- StorageZoneHandle ------------------------------------------------
Expand Down Expand Up @@ -815,7 +815,7 @@ impl StorageZoneHandle<'_> {
// loading a new instance.

// Ensure a new operation can be started.
let ZoneStateMachine::Waiting(_) = &self.state.machine else {
if !self.state.ready_for_operation() {
trace!("Ignoring `on_passive()` because the pipeline is busy");
return;
};
Expand Down
Loading