Skip to content

backupbase,backupdest,backuputils: introduce new backup packages#82381

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
adityamaru:introduce-backupdestination
Jun 7, 2022
Merged

backupbase,backupdest,backuputils: introduce new backup packages#82381
craig[bot] merged 1 commit intocockroachdb:masterfrom
adityamaru:introduce-backupdestination

Conversation

@adityamaru
Copy link
Copy Markdown
Contributor

@adityamaru adityamaru commented Jun 2, 2022

This change introduces three new packages:

backupdest - all logic related to backup destination resolution
backuputils - shared utility and test methods
backupbase - shared constants and cluster settings

In order to minimize the churn, this change focuses on moving methods
and constants needed to carve out backupdestination. There are TODOs
that will be addressed in follow up PRs to centralize shared methods and
variables such as cluster settings, test setup helpers etc. There will
also be a fast follow introduction of a backupinfo package that will contain
all the logic related to backup manifest construction and resolution.

This is a refactor only change.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@adityamaru adityamaru force-pushed the introduce-backupdestination branch 2 times, most recently from b398f9b to 83fdf90 Compare June 3, 2022 14:30
@adityamaru adityamaru changed the title backupdestination,backuputils: introduce new backup packages backupbase,backupdestination,backuputils: introduce new backup packages Jun 3, 2022
@adityamaru adityamaru marked this pull request as ready for review June 3, 2022 14:34
@adityamaru adityamaru requested a review from a team as a code owner June 3, 2022 14:34
@adityamaru adityamaru requested review from a team, benbardin, dt, msbutler and stevendanna and removed request for a team and stevendanna June 3, 2022 14:34
@@ -0,0 +1,51 @@
// Copyright 2022 The Cockroach Authors.
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.

Since backupccl is in the path, the prefix backup in backupbase seems redundant? Maybe just name the packages base, destination, and utils?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hmmm so when these packages are used by others it'll be backupbase.foo which might be more informative than just base.foo? I agree the stutter is not ideal but I think we have some precedence here:

changfeedccl/changefeedbase, kv/kvserver/kvbase being a few of them.

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.

The schemachanger package settled on a sort abbreviation for their "sub packages" (scexec, scplan), but I'm not sure bk or bu have the same ring to them.

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.

I was OOO so no need to revisit, but I'm comfortable putting it on importers to use import aliasing!

"github.com/cockroachdb/cockroach/pkg/util"
)

// TODO(adityamaru): Move all backup related cluster settings to this file.
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.

Is this a goal?

If a setting is only used during destination resolution, or only used during data exporting, etc, moving it here is the opposite of dependency hygiene; now if we change this setting, or add another one, etc, we're needlessly adding churn to a dependency of other packages, because something specific to one package leaked out into a common package.

Copy link
Copy Markdown
Contributor Author

@adityamaru adityamaru Jun 3, 2022

Choose a reason for hiding this comment

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

makes sense, I needed this setting in a place that I could import into testutils.go so that it is registered at the time the test cluster is started. I'll remove the TODO but I don't think I'd want testutils.go to import any of backupdestination or backupinfo so I think I'll need to keep this file around?

@adityamaru adityamaru requested review from benbardin and dt June 3, 2022 17:20
Copy link
Copy Markdown
Collaborator

@stevendanna stevendanna left a comment

Choose a reason for hiding this comment

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

Overall, huge kudos for starting this process.

This will increase the cost of backports for us for this release, but I think we should probably just pay that cost now.

I've left a few comments, but I assume this is something we are going to iterate on over time, so none of them are really blocking.

@@ -0,0 +1,51 @@
// Copyright 2022 The Cockroach Authors.
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.

The schemachanger package settled on a sort abbreviation for their "sub packages" (scexec, scplan), but I'm not sure bk or bu have the same ring to them.


package backupbase

const (
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.

I'm OK with this since we are trying to make incremental progress here. But I think some of these constants eventually belong in a more appropriate package. For example, many of them have to do with the layout of the backup collection itself.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup I agree, some of these constants are used in test files, backupdest, debug_backup as well as manifest handling. I want to introduce backupinfo to better understand the dependency graph before we move these into specific packages.

Comment on lines +13 to +16
IncludeManifest = true

// OmitManifest is a named const that can be passed to FindPriorBackups.
OmitManifest = false
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.

Since these two are only used as arguments to a function that lives in backupdestination perhaps we can move them there now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently IncludeManifest is used in manifest_handling.go which will move into backupinfo. OmitManifest is used backupdest as well as cliccl.

Now that I'm looking at the method resolveBackupManifests that uses IncludeManifest in manifest_handling.go, this will cause issues when moving manifest_handling.go into backupinfo since backupinfo should probably not depend on backupdest?

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.

Perhaps I misread, but the only uses of these are in calls to FindPriorBackups. Since FindPriorBackups is in backupdest, then anything that depends on these constants already depends on backupdest. So, the only way to break the dependency is to move FindPriorBackups and then these constants can live in whatever package that function lives in.

All that said, you have this dependency graph more in mind than I do at the moment, and I think we can do this iteratively so don't treat this as blocking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Chatted offline, this is a dependency we are going to have to break at some point. Whether we do this through dependency injection/interfaces is still to be seen. I think we agree that we should draw the lines in the sand with these packages and then iterate on cleaning up the dependency graph. I might capture some of these improvements in a TODO list issue just so that we don't forget.

// to accidentally correct an unauthorized file path to an authorized one, then
// write a backup to an unexpected place or print the wrong error message on
// a restore.
func JoinURLPath(args ...string) string {
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.

I could see this living in the cloud package since it is particular to our external storage implementation. But, we can leave that bikeshed to a follow-up PR if anyone else agrees.

@adityamaru adityamaru requested a review from stevendanna June 7, 2022 13:58
@adityamaru adityamaru force-pushed the introduce-backupdestination branch 2 times, most recently from 99e67b5 to 2180634 Compare June 7, 2022 14:27
@adityamaru adityamaru changed the title backupbase,backupdestination,backuputils: introduce new backup packages backupbase,backupdest,backuputils: introduce new backup packages Jun 7, 2022
This change introduces three new packages:

`backupdest` - all logic related to backup destination resolution
`backuputils` - shared utility and test methods
`backupbase` - shared constants and cluster settings

In order to minimize the churn, this change focuses on moving methods
and constants needed to carve out `backupdest`. There are TODOs
that will be addressed in follow up PRs to centralize shared methods and
variables such as cluster settings, test setup helpers etc. There will
also be a fast follow introduction of a `backupinfo` package that will contain
all the logic related to backup manifest construction and resolution.

This is a refactor only change.

Release note: None
@adityamaru adityamaru force-pushed the introduce-backupdestination branch from 2180634 to 5c91ef6 Compare June 7, 2022 16:05
@adityamaru
Copy link
Copy Markdown
Contributor Author

Checking this in, but feel free to comment or open up changes to improve this!

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 7, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 7, 2022

Build succeeded:

@craig craig bot merged commit 7d7f2d4 into cockroachdb:master Jun 7, 2022
@adityamaru adityamaru deleted the introduce-backupdestination branch June 7, 2022 23:57
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.

5 participants