Skip to content

storage: don't modify the given cfg.Opts#96770

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
RaduBerinde:no-opt-mod
Feb 8, 2023
Merged

storage: don't modify the given cfg.Opts#96770
craig[bot] merged 1 commit intocockroachdb:masterfrom
RaduBerinde:no-opt-mod

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

This change improves the NewPebble code to not modify the given cfg.Opts. Such behavior is surprising and can trip up tests that reuse the same config.

Also, ResolveEncryptedEnvOptions and wrapFilesystemMiddleware no longer modify the Options directly; and CheckNoRegistryFile is now a standalone function.

Release note: None
Epic: none

@RaduBerinde RaduBerinde requested a review from jbowens February 8, 2023 03:47
@RaduBerinde RaduBerinde requested review from a team as code owners February 8, 2023 03:47
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

This change improves the `NewPebble` code to not modify the given
`cfg.Opts`. Such behavior is surprising and can trip up tests that
reuse the same config.

Also, `ResolveEncryptedEnvOptions` and `wrapFilesystemMiddleware` no
longer modify the Options directly; and `CheckNoRegistryFile` is now a
standalone function.

Release note: None
Epic: none
Copy link
Copy Markdown
Contributor

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

:lgtm:

thanks for tackling this much-needed cleanup!

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde)


pkg/storage/pebble.go line 862 at r1 (raw file):

func NewPebble(ctx context.Context, cfg PebbleConfig) (p *Pebble, err error) {
	// pebble.Open also calls EnsureDefaults, but only after doing a clone. Call
	// EnsureDefaults beforehand so we have a matching cfg here for when we save

lol at how far this comment had drifted from the cfg.Opts.EnsureDefaults() call that it describes.

@RaduBerinde
Copy link
Copy Markdown
Member Author

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 8, 2023

Build succeeded:

@craig craig bot merged commit 844a370 into cockroachdb:master Feb 8, 2023
@RaduBerinde RaduBerinde deleted the no-opt-mod branch November 7, 2025 15:11
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.

3 participants