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

feat(storage): Soft deleted Bucket Restore #28138

Conversation

shubhangi-google
Copy link
Contributor

Add support for restoring soft deleted bucket.

Operation Supported:

  • Get Bucket Generation
  • Get a Soft Deleted Bucket (Also soft-delete time and hard-delete time)
  • List Soft Deleted Buckets
  • Restore a Soft Deleted Bucket
@example
require "google/cloud/storage"
storage = Google::Cloud::Storage.new
bucket = storage.bucket "my-bucket"
bucket.delete
##fetch bucket generation
 generation= bucket.generation
## list soft_deleted buckets
deleted_buckets= storage.buckets soft_deleted: true
## restore bucket
bucket = storage.restore_bucket "my-bucket", generation

Copy link
Contributor

@bajajneha27 bajajneha27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark the PR ready for review once you're ready for it to be reviewed. Also please check the CI job failures.

@shubhangi-google shubhangi-google marked this pull request as ready for review December 21, 2024 05:52
Copy link

snippet-bot bot commented Dec 21, 2024

No region tags are edited in this PR.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Sorry, something went wrong.

Copy link
Contributor

@bajajneha27 bajajneha27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM. Please fix the CI issues.

@@ -223,6 +232,10 @@ def buckets prefix: nil, token: nil, max: nil, user_project: nil
# account, transit costs will be billed to the given project. This
# parameter is required with requester pays-enabled buckets. The
# default is `nil`.
# @param [Integer] generation generation no of bucket
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# @param [Integer] generation generation no of bucket
# @param [Integer] generation Generation of the bucket

@shubhangi-google
Copy link
Contributor Author

Hi @bajajneha27 @JesseLovelace can you please take a look at the sample failure
getting permission error on sample run

Google::Cloud::PermissionDeniedError: forbidden: 542339357638-cr0dserr2evg7sv1meghqeu703274f3h@developer.gserviceaccount.com does not have storage.buckets.get access to the Google Cloud Storage bucket. Permission 'storage.buckets.get' denied on resource (or it may not exist).

@bajajneha27
Copy link
Contributor

@shubhangi-google Does the yard / rubocop ci work in your local?

@bajajneha27
Copy link
Contributor

Can you please double check that the APIARY i.e. google-apis-storage_v1 has soft delete changes? We might have to bump the storage_v1 version in storage gemspec

@shubhangi-google shubhangi-google force-pushed the soft_deleted_bucket_restore_samples_new3 branch from 209b570 to 59a3f9c Compare January 17, 2025 05:41
@shubhangi-google
Copy link
Contributor Author

Can you please double check that the APIARY i.e. google-apis-storage_v1 has soft delete changes? We might have to bump the storage_v1 version in storage gemspec

updating the version in gemspec did not help will debug this further

@@ -21,7 +21,7 @@ Gem::Specification.new do |gem|
gem.add_dependency "google-cloud-core", "~> 1.6"
gem.add_dependency "google-apis-core", "~> 0.13"
gem.add_dependency "google-apis-iamcredentials_v1", "~> 0.18"
gem.add_dependency "google-apis-storage_v1", "~> 0.38"
gem.add_dependency "google-apis-storage_v1", "~> 0.40"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The soft_deleted field on get_bucket was introduced in storage_v1 0.42 version. Ref
Which version were you using in local?
Also generally, just update to the latest version of the dependency when you do this.
This should solve the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current gem version present on KOKORO is 0.49 (as seen in sample logs)
image
"~> 0.40" will specify that we want to use a version of the gem that is at least 0.40, but less than 0.5.

@bajajneha27 bajajneha27 added the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 17, 2025
@yoshi-kokoro yoshi-kokoro removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Jan 17, 2025
@@ -895,7 +911,7 @@ def encryption_key_headers options, key, copy_source: false
headers = (options[:header] ||= {})
headers["x-goog-#{source}encryption-algorithm"] = "AES256"
headers["x-goog-#{source}encryption-key"] = Base64.strict_encode64 key
headers["x-goog-#{source}encryption-key-sha256"] = \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we're modifying this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rubocop lint issue was coming for this line

@@ -17,6 +17,9 @@

describe "Storage Quickstart" do
let(:project) { Google::Cloud::Storage.new }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe these changes are not needed any more?

soft_deleted= true

mock = Minitest::Mock.new
mock.expect :list_buckets, list_buckets_gapi(num_buckets,nil,soft_deleted), [project], prefix: nil, page_token: nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of passing nil, we could pass a dummy token here.

@bajajneha27
Copy link
Contributor

Can you please fix the CI failure?

@bajajneha27
Copy link
Contributor

The CI job is still failing. Can you please take a look?

@shubhangi-google
Copy link
Contributor Author

The CI job is still failing. Can you please take a look?

Hi @bajajneha27 the ci failure is related to yard and GitHub action which I suppose we don't handle locally
please correct me if I am missing out something?

@bajajneha27
Copy link
Contributor

The CI job is still failing. Can you please take a look?

Hi @bajajneha27 the ci failure is related to yard and GitHub action which I suppose we don't handle locally please correct me if I am missing out something?

Yeah, the failure doesn't seem directly related to our changes but we cannot merge the PR because it's one of the required CI jobs. Can you please try and fix it? You should be able to run it locally.

@bajajneha27 bajajneha27 merged commit fbd37f1 into googleapis:main Feb 13, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants