-
-
Notifications
You must be signed in to change notification settings - Fork 13
Limit the conditions for zone removal #968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
4a5b966
f4c34fc
8a0ca6d
cc8a821
a69e753
fa60352
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -264,9 +264,13 @@ pub fn remove_zone(center: &Arc<Center>, name: Name<Bytes>) -> Result<(), ZoneRe | |
|
|
||
| let ZoneByName(zone) = state.zones.get(&name).ok_or(ZoneRemoveError::NotFound)?; | ||
|
|
||
| // TODO(#871): support removing a zone during restoration. | ||
| if zone.read().storage.is_restoring() { | ||
| return Err(ZoneRemoveError::MidRestoration); | ||
| { | ||
| let zone = zone.read(); | ||
| // The zone must be in maintenance mode, and passive/halted. | ||
| // TODO(#871): support removing a zone during restoration. | ||
| if !zone.maintenance_mode || !zone.machine.is_waiting() && !zone.machine.is_halted() { | ||
| return Err(ZoneRemoveError::NotInMaintenanceMode); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might be confusing if the zone is in maintenance mode but not waiting or halted
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the confusion originates from the terminology we use for maintenance mode; e.g. |
||
| } | ||
| } | ||
|
|
||
| let ZoneByName(zone) = state | ||
|
|
@@ -518,8 +522,8 @@ pub enum ZoneRemoveError { | |
| /// No such name could be found. | ||
| NotFound, | ||
|
|
||
| /// The zone is being restored from disk. | ||
| MidRestoration, | ||
| /// The zone is not in maintenance mode. | ||
| NotInMaintenanceMode, | ||
| } | ||
|
|
||
| impl std::error::Error for ZoneRemoveError {} | ||
|
|
@@ -528,7 +532,7 @@ impl fmt::Display for ZoneRemoveError { | |
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| f.write_str(match self { | ||
| Self::NotFound => "no such zone was found", | ||
| Self::MidRestoration => "the zone is being restored from disk", | ||
| Self::NotInMaintenanceMode => "the zone is not in maintenance mode", | ||
| }) | ||
| } | ||
| } | ||
|
|
@@ -537,7 +541,7 @@ impl From<ZoneRemoveError> for api::ZoneRemoveError { | |
| fn from(value: ZoneRemoveError) -> Self { | ||
| match value { | ||
| ZoneRemoveError::NotFound => Self::NotFound, | ||
| ZoneRemoveError::MidRestoration => Self::MidRestoration, | ||
| ZoneRemoveError::NotInMaintenanceMode => Self::NotInMaintenanceMode, | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this or? I thought maintenance mode was always required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right, forgot to update the docs. On it.