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: Add feature for copying backups #1153

Merged

Conversation

danieljbruce
Copy link
Contributor

@danieljbruce danieljbruce commented Sep 9, 2022

This PR includes changes in the veneer layer that implement the new copy backup feature which allows users to copy a backup of a table to a cluster of their choice.

A config interface is introduced which is used to specify details about the copied backup. On a backup object, a copy function is added which copies the backup to a destination specified by the config passed into the function parameter. Code that parses expiry time is reused for the copy backup function.

Unit tests are added to make sure source and destination information get passed along to the Gapic layer. System tests are added to check that copying a backup works when copying to the same cluster, different cluster and different project. System tests are also added to be sure that expiry times can be passed in using different formats and tests are added so that we can confirm restoring the copied backup works properly.

@danieljbruce danieljbruce requested review from a team as code owners September 9, 2022 19:08
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: bigtable Issues related to the googleapis/nodejs-bigtable API. labels Sep 9, 2022
system-test/bigtable.ts Outdated Show resolved Hide resolved
test/backup.ts Outdated Show resolved Hide resolved
@danieljbruce danieljbruce changed the title Copy backup 2 relevant changes only fix: Add feature for copying backups Sep 21, 2022
@danieljbruce danieljbruce added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Sep 21, 2022
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 12, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 12, 2024
assert.deepStrictEqual(backup.expireDate, sourceExpireTime);
}
// Create client, instance, cluster for second project
const bigtable = new Bigtable(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - I would rename this to something that signifies it's the second project. Maybe bigtableSecondaryProject?

Copy link
Contributor

Choose a reason for hiding this comment

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

or bigtableDestinationProject?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

? {projectId: process.env.GCLOUD_PROJECT2}
: {}
);
const instanceId = generateId('instance');
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - I think we can inline this to the line below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

: {}
);
const instanceId = generateId('instance');
const instance = bigtable.instance(instanceId);
Copy link
Contributor

Choose a reason for hiding this comment

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

as above, I would rename this to show it's the second project instance

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@danieljbruce danieljbruce requested a review from kolea2 May 6, 2024 14:28
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label May 10, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 10, 2024
src/cluster.ts Show resolved Hide resolved
@@ -1414,6 +1421,269 @@ describe('Bigtable', () => {

Object.keys(policy).forEach(key => assert(key in updatedPolicy));
});
describe('copying backups', () => {
const sourceExpireTimeMilliseconds =
PreciseDate.now() + (8 + 300) * 60 * 60 * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning behind this arithmetic? I'm sure there is some, but to an outsider, all I think of is PEMDAS 🙂 Consider adding a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My local system tests are hitting quotas so it's hard to recall exactly by testing it out. But if I recall correctly, the create backup expire time has to be sufficiently far ahead of the current time and the copied backup expire time has to be sufficiently ahead of the create backup expire time to avoid server errors specific to the copy backup feature. I added a comment for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the comment! Makes sense as to why it needs to be a large number. My remaining confusion is why the arithmetic needs to be there rather than adding a fixed integer to PreciseDate.now()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To your point, I think we can change this to 308 * 60 * 60 * 1000 and 608 * 60 * 60 * 1000, but I want to keep the 60 * 60 * 1000 in there because it is beneficial to the reader to know that 308 is the number of hours (milliseconds/second * seconds/minute * minutes/hour).

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, thank you! I agree with the 60 * 60 * 1000 making sense. I made a suggestion to modify the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggestions applied

system-test/bigtable.ts Outdated Show resolved Hide resolved
test/backup.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@leahecole leahecole left a comment

Choose a reason for hiding this comment

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

approving once suggestions with comments are added and with the assumption that the failing conformance tests are unrelated

system-test/bigtable.ts Outdated Show resolved Hide resolved
@@ -1414,6 +1421,269 @@ describe('Bigtable', () => {

Object.keys(policy).forEach(key => assert(key in updatedPolicy));
});
describe('copying backups', () => {
const sourceExpireTimeMilliseconds =
PreciseDate.now() + (8 + 300) * 60 * 60 * 1000;
Copy link
Contributor

Choose a reason for hiding this comment

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

ah, thank you! I agree with the 60 * 60 * 1000 making sense. I made a suggestion to modify the comment

system-test/bigtable.ts Show resolved Hide resolved
danieljbruce and others added 2 commits May 21, 2024 15:28
Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com>
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label May 21, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 21, 2024
@danieljbruce danieljbruce added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 22, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 22, 2024
@danieljbruce danieljbruce merged commit 91f85b5 into googleapis:main May 22, 2024
15 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/nodejs-bigtable API. size: l Pull request size is large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants