Skip to content
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

S3 endpoints 2 #237

Merged
merged 4 commits into from
Aug 2, 2023
Merged

S3 endpoints 2 #237

merged 4 commits into from
Aug 2, 2023

Conversation

giubacc
Copy link

@giubacc giubacc commented Jul 26, 2023

Describe your changes

  1. add result to set_bucket_versioning and set_bucket_tagging

    • set_bucket_versioning -> bool (True is success, False is failure)
    • set_bucket_tagging -> bool (True is success, False is failure)
  2. add set of bucket related endpoints

Added endpoints:

  - api/bucket/update
  - api/bucket/lifecycle-configuration (GET)
  - api/bucket/lifecycle-configuration (PUT)

Issue ticket number and link

https://github.com/aquarist-labs/s3gw/issues/607

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • CHANGELOG.md has been updated should there be relevant changes in this PR

@giubacc giubacc marked this pull request as draft July 26, 2023 14:51
@giubacc giubacc self-assigned this Jul 26, 2023
@giubacc giubacc added this to the v0.19.0 milestone Jul 26, 2023
@giubacc giubacc added area/ui User Interface kind/enhancement Add more things to something labels Jul 26, 2023
@codecov
Copy link

codecov bot commented Jul 26, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.56% 🎉

Comparison is base (49f2d8f) 91.85% compared to head (f263a0d) 92.41%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
+ Coverage   91.85%   92.41%   +0.56%     
==========================================
  Files          12       12              
  Lines         589      633      +44     
==========================================
+ Hits          541      585      +44     
  Misses         48       48              
Files Changed Coverage Δ
src/backend/api/buckets.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@giubacc
Copy link
Author

giubacc commented Jul 26, 2023

@irq0 as I was telling you, this is the original update implementation that was collecting coroutines and then spawned those in parallel:

@router.post(
    "/update",
    response_model=BucketAttributes,
    responses=s3gw_client_responses(),
)
async def update_bucket(
    conn: S3GWClientDep, attributes: BucketAttributes
) -> BucketAttributes:
    """
    Aggregating function to update bucket related attributes:
        - Versioning
        - Tags
        - ObjectLock configuration
    """
    old_attributes = await get_bucket_attributes(
        conn=conn, bucket_name=attributes.Name
    )

    requests: List[Coroutine[Any, Any, Any]] = []

    # Versioning
    if attributes.VersioningEnabled is not None:
        if attributes.VersioningEnabled != old_attributes.VersioningEnabled:
            requests.append(
                set_bucket_versioning(
                    conn=conn,
                    bucket_name=attributes.Name,
                    enabled=attributes.VersioningEnabled,
                )
            )

    # Tags
    if set(attributes.TagSet) != set(old_attributes.TagSet):
        requests.append(
            set_bucket_tagging(
                conn=conn,
                bucket_name=attributes.Name,
                tags=list(
                    map(
                        lambda tag: {"Key": tag.Key, "Value": tag.Value},
                        attributes.TagSet,
                    )
                ),
            )
        )

    # ObjectLock
    if (
        attributes.ObjectLockEnabled is not None
        and attributes.RetentionMode is not None
        and attributes.RetentionValidity is not None
        and attributes.RetentionUnit is not None
    ):
        if attributes.ObjectLockEnabled and (
            attributes.RetentionEnabled != old_attributes.RetentionEnabled
            or attributes.RetentionMode != old_attributes.RetentionMode
            or attributes.RetentionValidity != old_attributes.RetentionValidity
            or attributes.RetentionUnit != old_attributes.RetentionUnit
        ):
            requests.append(
                set_bucket_object_lock_configuration(
                    conn=conn, bucket_name=attributes.Name, config=attributes
                )
            )

    future_list = await asyncio.gather(*requests, return_exceptions=True)
    res_dict = {}
    for it in future_list:
        if it is not None and not isinstance(it, HTTPException):
            res_dict |= it.dict()

    res = BucketAttributes.parse_obj(attributes.dict() | res_dict)
    return res  

the scenario described in https://github.com/aquarist-labs/s3gw/issues/637 has been produced using the above function.

@giubacc giubacc force-pushed the s3-endpoints-2 branch 2 times, most recently from f673ab7 to de10f2b Compare July 27, 2023 15:23
@giubacc giubacc marked this pull request as ready for review July 27, 2023 15:39
@giubacc giubacc requested review from votdev and jecluis July 27, 2023 15:39
@votdev votdev added the DNM Do not merge label Jul 31, 2023
@votdev votdev force-pushed the s3-endpoints-2 branch 4 times, most recently from ef1e748 to 92e873c Compare August 1, 2023 08:53
Giuseppe Baccini added 3 commits August 1, 2023 13:28
- set_bucket_versioning -> bool (True is success, False is failure)
- set_bucket_tagging -> bool (True is success, False is failure)

Signed-off-by: Giuseppe Baccini <[email protected]>
Added endpoint:

  - api/bucket/update

Refers to: https://github.com/aquarist-labs/s3gw/issues/607
Signed-off-by: Giuseppe Baccini <[email protected]>
Added endpoints:

  - api/bucket/lifecycle-configuration (GET)
  - api/bucket/lifecycle-configuration (PUT)

Refers to: https://github.com/aquarist-labs/s3gw/issues/607

Signed-off-by: Giuseppe Baccini <[email protected]>
Signed-off-by: Volker Theile <[email protected]>
@votdev votdev force-pushed the s3-endpoints-2 branch 10 times, most recently from 1254d9e to b92b5c6 Compare August 2, 2023 14:48
@votdev votdev merged commit 54b0c0d into s3gw-tech:main Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui User Interface DNM Do not merge kind/enhancement Add more things to something
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants