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>

source

pub fn bucket(&self) -> BucketHelper<'a>

source

pub fn key(&self) -> KeyHelper<'a>

source

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
source

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)
source

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)
source

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
source

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)
source

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”
source

pub async fn delete_key(&self, key: &mut Key) -> Result<(), Error>

Deletes an API access key

Auto Trait Implementations§

§

impl<'a> Freeze for LockedHelper<'a>

§

impl<'a> !RefUnwindSafe for LockedHelper<'a>

§

impl<'a> Send for LockedHelper<'a>

§

impl<'a> Sync for LockedHelper<'a>

§

impl<'a> Unpin for LockedHelper<'a>

§

impl<'a> !UnwindSafe for LockedHelper<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more