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

blobfixture: create utility for managing blob fixtures #140368

Merged
merged 1 commit into from
Feb 10, 2025

Conversation

jeffswenson
Copy link
Collaborator

@jeffswenson jeffswenson commented Feb 3, 2025

This introduces the blobfixture package. It will be used by the DR team to manage the lifetime of fixtures created for restore roachtests. Currently, fixture generation is a manual process so many of our fixtures date back to 22.2. blobfixture has two features which allow for automated fixture generation:

  1. There is an explicit step to mark a fixture as ready. This prevents a restore roachtest from attempting to use a fixture that is in the process of creation.
  2. It garbage collects old fixtures. The GC is easy to retrofit once we start tracking fixture ready time. GC is superior to using a TTL because we don't throw away fixtures if fixture creation breaks and we can delete fixtures more aggressively than if we depended on TTL, which helps minimize the cost of the fixtures.

Release note: none
Part of: #139159

@jeffswenson jeffswenson requested a review from msbutler February 3, 2025 13:00
@jeffswenson jeffswenson requested review from a team as code owners February 3, 2025 13:00
@jeffswenson jeffswenson requested review from herkolategan and DarrylWong and removed request for a team February 3, 2025 13:00
@cockroach-teamcity
Copy link
Member

This change is Reviewable

jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 3, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
@jeffswenson jeffswenson force-pushed the jeffswenson-fixture-registr branch from 0905435 to 05449e0 Compare February 3, 2025 13:20
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 3, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 3, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
Copy link
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.

This is awesome!! Left mostly nits

pkg/roachprod/blobfixture/registry.go Outdated Show resolved Hide resolved
pkg/roachprod/blobfixture/registry.go Outdated Show resolved Hide resolved
pkg/roachprod/blobfixture/registry.go Show resolved Hide resolved

func (r *Registry) deleteBlobsMatchingPrefix(prefix string) error {
return r.storage.List(context.Background(), prefix, "", func(path string) error {
return r.storage.Delete(context.Background(), prefix+path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

i hope this scales!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The list is going to be fast. We may need to parallelize the deletes, but I'm trying to write the simplest possible code on the first pass.

pkg/roachprod/blobfixture/registry_test.go Show resolved Hide resolved
// 'nodelocal://' support is a little hacky and is only intended to support
// testing fixture generation in local tests.
node := uri.Host
root := path.Join(os.Getenv("HOME"), "local", node, "data", "extern")
Copy link
Collaborator

Choose a reason for hiding this comment

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

i assume you used this in demo? It may be worth adding a baby unit test to ensure this works.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up removing all support for nodelocal for now. I did use it when testing fixture generation. I think it would be possible to make this work in the future by creating a fixture directory somewhere on the local machine and linking it into the external data directory when the roachprod cluster is created. But I don't want to do that right now.

@@ -49,17 +49,14 @@ func ReplaceNodeLocalForTesting(root string) func() {
func TestingMakeNodelocalStorage(
root string, settings *cluster.Settings, es cloudpb.ExternalStorage,
) cloud.ExternalStorage {
if !buildutil.CrdbTestBuild {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you provide more context on this change? It seems unrelated to the rest of this commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed this from the PR and may do something like this in the future if I add local support.

The motivation for this change is the roachtest and roachprod binaries are not considered test binaries. So calling this would panic.

// GC deletes fixtures that were leaked or obsolete. See the comment on the
// fixturesToGc for details about the GC policy.
func (r *Registry) GC(ctx context.Context, l *logger.Logger) error {
// List objects in /roachtest/v25.1/metadata
Copy link
Member

Choose a reason for hiding this comment

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

The comment is perhaps a hint that this package should really be inside roachtest proper. Roachprod is used outside of roachtest, so we want to keep them loosely coupled, when possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't have strong opinions as to where this goes, but I put it in roachprod because I considered adding a roachprod command that restores fixtures into a roachprod cluster or prints the uri for the latest copy of a fixture.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, in that case it makes sense. I also wondered if there would be a self-contained command (via CLI).

@srosenberg srosenberg requested a review from golgeek February 3, 2025 21:39
@jeffswenson jeffswenson force-pushed the jeffswenson-fixture-registr branch from 05449e0 to 6e51494 Compare February 4, 2025 14:22
Copy link
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.

I'm very excited for this.

jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
This introduces the `blobfixture` package. It will be used by the DR
team to manage the lifetime of fixtures created for restore roachtests.
Currently, fixture generation is a manual process so many of our
fixtures date back to 22.2. blobfixture has two features which allow for
automated fixture generation:

1. There is an explicit step to mark a fixture as ready. This prevents a
	 restore roachtest from attempting to use a fixture that is in the
	 process of creation.
2. It garbage collects old fixtures. The GC is easy to retrofit once we
	 start tracking fixture ready time. GC is superior to using a TTL
	 because we don't throw away fixtures if fixture creation breaks and
	 we can delete fixtures more aggressively than if we depended on TTL,
	 which helps minimize the cost of the fixtures.

Release note: none
Part of: 139159
@jeffswenson jeffswenson force-pushed the jeffswenson-fixture-registr branch from 6e51494 to 118501a Compare February 4, 2025 16:13
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 4, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 5, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
@jeffswenson
Copy link
Collaborator Author

Thanks for the reviews!

bors r+

@craig craig bot merged commit 85ecd9c into cockroachdb:master Feb 10, 2025
22 checks passed
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 10, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 11, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 11, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 12, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 12, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 12, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 12, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 12, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 12, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 13, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 14, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
jeffswenson added a commit to jeffswenson/cockroach that referenced this pull request Feb 14, 2025
Previously, backup fixture creation was a manual process. Now, fixture
creation will run as a roachtest and use the fixture registry utility
added by cockroachdb#140368.

Fixture generation was reworked to use import instead of old backup
fixtures. This makes it trivial to bootstrap fixtures in new clouds and
in new fixture buckets.

Release note: none
Part of: cockroachdb#139159
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