diff options
author | Alex <alex@adnab.me> | 2024-02-22 12:05:19 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2024-02-22 12:05:19 +0000 |
commit | 74d0c47f21ae2f9998a7dcbca3a27e3cc51e70b6 (patch) | |
tree | f7747f950672246c1ecc079e50222a07d23bc635 /src/model/helper/key.rs | |
parent | 7e212e20e02b9cdced52ce23111214c6285a095a (diff) | |
parent | cff702a951cb5bb193c7a891ababfd1d962ae9ed (diff) | |
download | garage-74d0c47f21ae2f9998a7dcbca3a27e3cc51e70b6.tar.gz garage-74d0c47f21ae2f9998a7dcbca3a27e3cc51e70b6.zip |
Merge pull request 'Add node-global lock for bucket/key operations (fix #723)' (#728) from lock-createbucket into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/728
Diffstat (limited to 'src/model/helper/key.rs')
-rw-r--r-- | src/model/helper/key.rs | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/src/model/helper/key.rs b/src/model/helper/key.rs index c1a8e974..b8a99d55 100644 --- a/src/model/helper/key.rs +++ b/src/model/helper/key.rs @@ -1,12 +1,9 @@ use garage_table::util::*; -use garage_util::crdt::*; use garage_util::error::OkOrMessage; use crate::garage::Garage; -use crate::helper::bucket::BucketHelper; use crate::helper::error::*; use crate::key_table::{Key, KeyFilter}; -use crate::permission::BucketKeyPerm; pub struct KeyHelper<'a>(pub(crate) &'a Garage); @@ -65,38 +62,4 @@ impl<'a> KeyHelper<'a> { Ok(candidates.into_iter().next().unwrap()) } } - - /// Deletes an API access key - pub async fn delete_key(&self, key: &mut Key) -> Result<(), Error> { - let bucket_helper = BucketHelper(self.0); - - 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 Some(bucket_id) = to { - bucket_helper - .unset_local_bucket_alias(*bucket_id, &key.key_id, alias) - .await?; - } - } - - // 2. Remove permissions on all authorized buckets - for (ab_id, _auth) in state.authorized_buckets.items().iter() { - bucket_helper - .set_bucket_key_permissions(*ab_id, &key.key_id, BucketKeyPerm::NO_PERMISSIONS) - .await?; - } - - // 3. Actually delete key - key.state = Deletable::delete(); - self.0.key_table.insert(key).await?; - - Ok(()) - } } |