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(spanner): add samples for MR CMEK #14674

Merged
merged 22 commits into from
Dec 5, 2024
Merged

Conversation

panerorenn9541
Copy link
Contributor

@panerorenn9541 panerorenn9541 commented Aug 29, 2024

Add samples for MR CMEK database creation, backup creation, copy backup, and backup restore.


This change is Reviewable

@panerorenn9541 panerorenn9541 requested a review from a team as a code owner August 29, 2024 18:25
Copy link

snippet-bot bot commented Aug 29, 2024

Here is the summary of changes.

You are about to add 4 region tags.

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

@product-auto-label product-auto-label bot added api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples. labels Aug 29, 2024
Copy link

conventional-commit-lint-gcf bot commented Aug 29, 2024

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

Copy link
Member

@scotthart scotthart left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 5 unresolved discussions (waiting on @panerorenn9541)


google/cloud/spanner/samples/samples.cc line 1304 at r1 (raw file):

                std::string const& src_project_id,
                std::string const& src_instance_id,
                std::string const& src_backup_id,

This is a lot of parameters for a function. Perhaps define a struct

struct BackupIdentifier {
  std::string project_id;
  std::string instance_id;
  std::string backup_id;
};

void CopyBackupWithMRCMEK(google::cloud::spanner_admin::DatabaseAdminClient client,
    BackupIdentifier const& src,
    BackupIdentifier const& dst,
...

google/cloud/spanner/samples/samples.cc line 1320 at r1 (raw file):

          .get();
  if (!copy_backup) throw std::move(copy_backup).status();
  std::cout << "Copy Backup " << copy_backup->name()  //

Are these comment sequences needed?


google/cloud/spanner/samples/samples.cc line 1355 at r1 (raw file):

  auto expire_time = TimestampAdd(
      google::cloud::spanner::MakeTimestamp(backup->expire_time()).value(),
      absl::Hours(7));

Can we use std::chrono instead of absl here?


google/cloud/spanner/samples/samples.cc line 1614 at r1 (raw file):

void CreateBackupWithMRCMEK(
    google::cloud::spanner_admin::DatabaseAdminClient client,
    std::string const& project_id, std::string const& instance_id,

Same comment about excessive number of parameters.


google/cloud/spanner/samples/samples.cc line 1650 at r1 (raw file):

      std::cout << ", ";
    }
  }

We seem to do this several times. Perhaps factor this out into a function.

Code quote:

      << " using encryption keys ";
  for (int i = 0; i < encryption_keys.size(); ++i) {
    std::cout << encryption_keys[i].FullName();
    if (i != encryption_keys.size() - 1) {
      std::cout << ", ";
    }
  }

Use struct and create function to print kms keys
Use std::chrono instead of absl::hours
Copy link
Contributor Author

@panerorenn9541 panerorenn9541 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 1 files reviewed, 5 unresolved discussions (waiting on @scotthart)


google/cloud/spanner/samples/samples.cc line 1304 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

This is a lot of parameters for a function. Perhaps define a struct

struct BackupIdentifier {
  std::string project_id;
  std::string instance_id;
  std::string backup_id;
};

void CopyBackupWithMRCMEK(google::cloud::spanner_admin::DatabaseAdminClient client,
    BackupIdentifier const& src,
    BackupIdentifier const& dst,
...

Done.


google/cloud/spanner/samples/samples.cc line 1320 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

Are these comment sequences needed?

The logs are there for other copy/create/restores.


google/cloud/spanner/samples/samples.cc line 1355 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

Can we use std::chrono instead of absl here?

Done.


google/cloud/spanner/samples/samples.cc line 1614 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

Same comment about excessive number of parameters.

Done.


google/cloud/spanner/samples/samples.cc line 1650 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

We seem to do this several times. Perhaps factor this out into a function.

Done.

@dbolduc
Copy link
Member

dbolduc commented Oct 16, 2024

/gcbrun

@scotthart
Copy link
Member

/gcbrun

@scotthart
Copy link
Member

/gcbrun

@scotthart
Copy link
Member

/gcbrun

Fix formatting
@scotthart
Copy link
Member

/gcbrun

@scotthart
Copy link
Member

/gcbrun

Copy link

codecov bot commented Dec 5, 2024

Codecov Report

Attention: Patch coverage is 5.71429% with 198 lines in your changes missing coverage. Please review.

Project coverage is 92.92%. Comparing base (59e5fdd) to head (3b935f2).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
google/cloud/spanner/samples/samples.cc 5.71% 198 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14674      +/-   ##
==========================================
- Coverage   93.00%   92.92%   -0.09%     
==========================================
  Files        2351     2351              
  Lines      209479   209689     +210     
==========================================
+ Hits       194821   194845      +24     
- Misses      14658    14844     +186     

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

Use single key in vector
@scotthart
Copy link
Member

/gcbrun

@scotthart
Copy link
Member

/gcbrun

Copy link
Member

@scotthart scotthart left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r9.
Reviewable status: all files reviewed (commit messages unreviewed), 5 unresolved discussions (waiting on @panerorenn9541)

@scotthart scotthart merged commit c91f736 into googleapis:main Dec 5, 2024
74 of 75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. samples Issues that are directly related to samples.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants