Struct garage_model::helper::locked::LockedHelper
source · pub struct LockedHelper<'a>(/* private fields */);
Expand description
A LockedHelper is the mandatory struct to hold when doing operations that modify access keys or bucket aliases. This structure takes a lock to a unit value that is in the globally-shared Garage struct.
This avoid several concurrent requests to modify the list of buckets and aliases at the same time, ending up in inconsistent states. This DOES NOT FIX THE FUNDAMENTAL ISSUE as CreateBucket requests handled by different API nodes can still break the cluster, but it is a first fix that allows consistency to be maintained if all such requests are directed to a single node, which is doable for many deployments.
See issues: #649, #723
Implementations§
source§impl<'a> LockedHelper<'a>
impl<'a> LockedHelper<'a>
pub fn bucket(&self) -> BucketHelper<'a>
pub fn key(&self) -> KeyHelper<'a>
sourcepub async fn set_global_bucket_alias(
&self,
bucket_id: Uuid,
alias_name: &String
) -> Result<(), Error>
pub async fn set_global_bucket_alias( &self, bucket_id: Uuid, alias_name: &String ) -> Result<(), Error>
Sets a new alias for a bucket in global namespace. This function fails if:
- alias name is not valid according to S3 spec
- bucket does not exist or is deleted
- alias already exists and points to another bucket
sourcepub async fn unset_global_bucket_alias(
&self,
bucket_id: Uuid,
alias_name: &String
) -> Result<(), Error>
pub async fn unset_global_bucket_alias( &self, bucket_id: Uuid, alias_name: &String ) -> Result<(), Error>
Unsets an alias for a bucket in global namespace. This function fails if:
- bucket does not exist or is deleted
- alias does not exist or maps to another bucket (-> internal error)
- bucket has no other aliases (global or local)
sourcepub async fn purge_global_bucket_alias(
&self,
bucket_id: Uuid,
alias_name: &String
) -> Result<(), Error>
pub async fn purge_global_bucket_alias( &self, bucket_id: Uuid, alias_name: &String ) -> Result<(), Error>
Ensures a bucket does not have a certain global alias. Contrarily to unset_global_bucket_alias, this does not fail on any condition other than:
- bucket cannot be found (its fine if it is in deleted state)
- alias cannot be found (its fine if it points to nothing or to another bucket)
sourcepub async fn set_local_bucket_alias(
&self,
bucket_id: Uuid,
key_id: &String,
alias_name: &String
) -> Result<(), Error>
pub async fn set_local_bucket_alias( &self, bucket_id: Uuid, key_id: &String, alias_name: &String ) -> Result<(), Error>
Sets a new alias for a bucket in the local namespace of a key. This function fails if:
- alias name is not valid according to S3 spec
- bucket does not exist or is deleted
- key does not exist or is deleted
- alias already exists and points to another bucket
sourcepub async fn unset_local_bucket_alias(
&self,
bucket_id: Uuid,
key_id: &String,
alias_name: &String
) -> Result<(), Error>
pub async fn unset_local_bucket_alias( &self, bucket_id: Uuid, key_id: &String, alias_name: &String ) -> Result<(), Error>
Unsets an alias for a bucket in the local namespace of a key. This function fails if:
- bucket does not exist or is deleted
- key does not exist or is deleted
- alias does not exist or maps to another bucket (-> internal error)
- bucket has no other aliases (global or local)
sourcepub async fn set_bucket_key_permissions(
&self,
bucket_id: Uuid,
key_id: &String,
perm: BucketKeyPerm
) -> Result<(), Error>
pub async fn set_bucket_key_permissions( &self, bucket_id: Uuid, key_id: &String, perm: BucketKeyPerm ) -> Result<(), Error>
Sets permissions for a key on a bucket. This function fails if:
- bucket or key cannot be found at all (its ok if they are in deleted state)
- bucket or key is in deleted state and we are trying to set permissions other than “deny all”