Skip to content

backupccl: refactor getBackupDetailsAndManifest#78350

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
benbardin:backup-refactor
Mar 30, 2022
Merged

backupccl: refactor getBackupDetailsAndManifest#78350
craig[bot] merged 1 commit intocockroachdb:masterfrom
benbardin:backup-refactor

Conversation

@benbardin
Copy link
Copy Markdown
Collaborator

This should be a complete no-op from a functionality perspective.
The smaller, more encapsulated pieces should be easier to reason about.

Specifically, getBackupDetailsAndManifest has now become a scaffolding function, calling the new updateBackupDetails, createBackupManifest, and validateBackupDetailsAndManifest in turn. These functions have a narrower focus and are a bit easier to follow.

It's also now a bit clearer where one would go to, say, add more validation conditions.

Release note: None

@benbardin benbardin requested review from a team and msbutler and removed request for a team March 23, 2022 17:30
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

overall, I think it's a great refactor! left some initial comments

Destination: details.Destination,
StartTime: details.StartTime,
EndTime: details.EndTime,
URI: details.URI,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

given all the objects the reader has to keep track of during backup_planning, i don't think it's worth creating another BackupDetails object with less info.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok! Wanted to keep the API the same for a pure refactor, but I think you're right. Removed.

Copy link
Copy Markdown
Collaborator

@msbutler msbutler left a comment

Choose a reason for hiding this comment

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

LGTM

Before merging, I think it's worth having Aditya take a look.

@msbutler msbutler requested a review from adityamaru March 28, 2022 13:08
@benbardin benbardin force-pushed the backup-refactor branch 2 times, most recently from 6b28e74 to 3e93417 Compare March 28, 2022 20:04
Copy link
Copy Markdown
Contributor

@adityamaru adityamaru left a comment

Choose a reason for hiding this comment

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

Couple comments but everything else LGTM! Thanks for doing this. Feel free to ignore but if you want you could add a comment or two in the scaffolding method to direct future authors to put things in the right method. Egs: a comment after updateBackupDetails saying that at this point we expect the backup job details to be fully constructed, and will be treated as read-only hereafter.

@@ -1575,104 +1548,174 @@ func getBackupDetailAndManifest(

prevBackups, encryptionOptions, memSize, err := fetchPreviousBackups(ctx, &mem, user,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It makes me slightly uneasy that the error handling for this error has strayed further away from the assignment. Can we move the error check and defer back or am I missing something?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yup, just an oversight. Thanks for catching!

if err != nil {
return jobspb.BackupDetails{}, BackupManifest{}, err
}
defer defaultStore.Close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't we still need to defer a close to the store?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, thank you! Good catch!

@adityamaru adityamaru self-requested a review March 30, 2022 05:45
@benbardin benbardin force-pushed the backup-refactor branch 2 times, most recently from a8af0dd to 6312259 Compare March 30, 2022 13:49
This should be a complete no-op from a functionality perspective.
The smaller, more encapsulated pieces should be easier to reason about.

Release note: None
@benbardin
Copy link
Copy Markdown
Collaborator Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 30, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 30, 2022

This PR was included in a batch that was canceled, it will be automatically retried

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 30, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 30, 2022

Build succeeded:

@craig craig bot merged commit e81ec34 into cockroachdb:master Mar 30, 2022
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.

4 participants