backupbase,backupdest,backuputils: introduce new backup packages#82381
Conversation
b398f9b to
83fdf90
Compare
| @@ -0,0 +1,51 @@ | |||
| // Copyright 2022 The Cockroach Authors. | |||
There was a problem hiding this comment.
Since backupccl is in the path, the prefix backup in backupbase seems redundant? Maybe just name the packages base, destination, and utils?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
stevendanna
left a comment
There was a problem hiding this comment.
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. | |||
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| IncludeManifest = true | ||
|
|
||
| // OmitManifest is a named const that can be passed to FindPriorBackups. | ||
| OmitManifest = false |
There was a problem hiding this comment.
Since these two are only used as arguments to a function that lives in backupdestination perhaps we can move them there now.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
99e67b5 to
2180634
Compare
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
2180634 to
5c91ef6
Compare
|
Checking this in, but feel free to comment or open up changes to improve this! TFTR! bors r+ |
|
Build failed (retrying...): |
|
Build succeeded: |
This change introduces three new packages:
backupdest- all logic related to backup destination resolutionbackuputils- shared utility and test methodsbackupbase- shared constants and cluster settingsIn order to minimize the churn, this change focuses on moving methods
and constants needed to carve out
backupdestination. There are TODOsthat 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
backupinfopackage that will containall the logic related to backup manifest construction and resolution.
This is a refactor only change.
Release note: None