aboutsummaryrefslogtreecommitdiff
path: root/src/garage/admin.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-03 18:32:15 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:52:47 +0100
commit1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec (patch)
tree6a812200ac8e049c21702ae1623a516d6e274f28 /src/garage/admin.rs
parentba7f268b990cd17c5d20bf9e0eb6ff77d30fe845 (diff)
downloadgarage-1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec.tar.gz
garage-1bcd6fabbdc0cd9dee88ba28daecb5339f2c13ec.zip
New buckets for 0.6.0: small changes
- Fix bucket delete - fix merge of bucket creation date - Replace deletable with option in aliases Rationale: if two aliases point to conflicting bucket, resolving by making an arbitrary choice risks making data accessible when it shouldn't be. We'd rather resolve to deleting the alias until someone puts it back.
Diffstat (limited to 'src/garage/admin.rs')
-rw-r--r--src/garage/admin.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/garage/admin.rs b/src/garage/admin.rs
index 0c1e58f8..bca1bc5a 100644
--- a/src/garage/admin.rs
+++ b/src/garage/admin.rs
@@ -140,7 +140,7 @@ impl AdminRpcHandler {
}
if let Some(alias) = self.garage.bucket_alias_table.get(&EmptyKey, name).await? {
- if !alias.state.get().is_deleted() {
+ if alias.state.get().is_some() {
return Err(Error::BadRequest(format!("Bucket {} already exists", name)));
}
}
@@ -229,7 +229,7 @@ impl AdminRpcHandler {
// 2. delete bucket alias
if bucket_alias.is_some() {
helper
- .unset_global_bucket_alias(bucket_id, &query.name)
+ .purge_global_bucket_alias(bucket_id, &query.name)
.await?;
}
@@ -281,7 +281,7 @@ impl AdminRpcHandler {
.unwrap()
.local_aliases
.get(&query.name)
- .map(|a| a.into_option())
+ .cloned()
.flatten()
.ok_or_bad_request("Bucket not found")?;
@@ -484,20 +484,26 @@ impl AdminRpcHandler {
let state = key.state.as_option_mut().unwrap();
// --- done checking, now commit ---
+ // (the step at unset_local_bucket_alias will fail if a bucket
+ // does not have another alias, the deletion will be
+ // interrupted in the middle if that happens)
+
// 1. Delete local aliases
for (alias, _, to) in state.local_aliases.items().iter() {
- if let Deletable::Present(bucket_id) = to {
+ if let Some(bucket_id) = to {
helper
.unset_local_bucket_alias(*bucket_id, &key.key_id, alias)
.await?;
}
}
- // 2. Delete authorized buckets
+
+ // 2. Remove permissions on all authorized buckets
for (ab_id, _auth) in state.authorized_buckets.items().iter() {
helper
.set_bucket_key_permissions(*ab_id, &key.key_id, BucketKeyPerm::no_permissions())
.await?;
}
+
// 3. Actually delete key
key.state = Deletable::delete();
self.garage.key_table.insert(&key).await?;