Code Monkey home page Code Monkey logo

Comments (11)

frankyn avatar frankyn commented on August 10, 2024 1

I'm okay with not introducing support for copying ACL in this case. It reduces potential security risks.

However, I do see the potential for having a destination_blob with metadata parameter being passed in. That would help in this case.

from python-storage.

frankyn avatar frankyn commented on August 10, 2024 1

Apologies for the delay.

I confirmed with the GCS team that "ACL being copied" behavior was never supported by the copy API in GCS. This might have just been an accident.

I prefer we deprecate in this case. I'd prefer to have a user do a subsequent ACL update in this case or that we have a FR to introduce a parameter to supply metadata when using copy_blob().

from python-storage.

thnee avatar thnee commented on August 10, 2024 1

I really wonder how an argument gets added if it never had an implementation.. But this bug also makes the very existence of rename_blob very misleading, unless it is extended to also include copying of the ACL, because that is definitely what one would expect from a function with that name.

Ultimately it would make much more sense if GCS would just add proper move and copy operations in the API though, but not sure where to even ask for that.

from python-storage.

busunkim96 avatar busunkim96 commented on August 10, 2024

@frankyn Is this the expected behavior for preserve_acl?

from python-storage.

frankyn avatar frankyn commented on August 10, 2024

Taking a look, thanks for the ping.

from python-storage.

frankyn avatar frankyn commented on August 10, 2024

Hi folks,

Based on the code, https://github.com/googleapis/google-cloud-python/blob/a79d98de3e9d6890c4e98d33cecae2f80550fdfd/storage/google/cloud/storage/bucket.py#L1121

I don't see anything necessarily copying ACLs. When exercising the example provided by @HenrikOssipoff, It's not something Cloud Storage does on a copy request.

We may want to deprecate this parameter.

from python-storage.

crwilcox avatar crwilcox commented on August 10, 2024

I agree with @frankyn. Let's mark this deprecated.

from python-storage.

tseaver avatar tseaver commented on August 10, 2024

The objects.copy API actually takes an optional Object resource in the request body, and applies any metadata to the destination object. Maybe we need to use pass the source blob's properties (including ACL, which we normally don't pass)?

from python-storage.

tseaver avatar tseaver commented on August 10, 2024

@frankyn We currently seem to promise that the ACL will be copied unless the user passes preserve_acl=False. Can you check whether the backend changed the "copy ACL" behavior, and if so, when?

Alternatives:

  • Follow up on that promise by passing the source blob's ACL along in the body of the POST request.
  • Deprecate the preserve_acl flag properly, preserving the current "erase ACL if False" behavior for a certain number of releases. We should also emit a warning if the user passes an explicit True value, since the backend doesn't copy (or no longer copies) the ACL.

For clarity, we could also add a Blob.copy_from method which passes along the destination blob's metadata / ACL (or at least any of the changed metadata?) in the body of the POST request. E.g.:

source_blob = bucket.get_blob("source-blob-name")
destination_blob = bucket.blob("destination-blob-name")
destination_blob.acl.all().grant_read()
destination_blob.storage_class = "COLDLINE"
destination_blob.copy_from(source_blob)  # passes ACL, storage class in body

from python-storage.

tseaver avatar tseaver commented on August 10, 2024

For context, see googleapis/google-cloud-python#5456.

from python-storage.

thnee avatar thnee commented on August 10, 2024

For future reference, this is the function I am using to move a file now. I noticed that all metadata seems to be copied correctly, but it does not cover everything, for example the time_created gets bumped here.

def move(source: str, destination: str):
    source_blob = media_bucket.blob(source)
    destination_blob = media_bucket.copy_blob(
        blob=source_blob,
        destination_bucket=media_bucket,
        new_name=destination,
    )
    destination_blob.acl.save(acl=source_blob.acl)
    source_blob.delete()

from python-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.