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

config: convert ZoneConfig to the new format #8627

Merged
merged 2 commits into from
Aug 29, 2016

Conversation

d4l3k
Copy link
Contributor

@d4l3k d4l3k commented Aug 17, 2016

Converts ZoneConfig to the new format specified in the expressive ZoneConfig
RFC. This is intermediate work on #4868.
https://github.com/cockroachdb/cockroach/blob/develop/docs/RFCS/expressive_zone_config.md

  • Allocator and StorePool use []config.Constraint instead of roachpb.Attributes
    since the new type allows for different types of constraint.
  • Adds a ZoneConfigLegacy struct for upgrades to the new format.
  • Adds a ZoneConfigHuman struct for easier specification on the command line.

@petermattis @bdarnell


This change is Reviewable

@d4l3k d4l3k force-pushed the zoneconfig branch 2 times, most recently from de1d3a7 to 27ecfd1 Compare August 18, 2016 00:01
// NumReplicas specifies the desired number of replicas
optional int32 num_replicas = 5 [(gogoproto.nullable) = false];
// Constraints constrains which stores the replicas can be stored on. The
// order in which the constrains are stored is arbitrary and may change.
Copy link
Member

Choose a reason for hiding this comment

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

s/constrains/constraints/

@d4l3k
Copy link
Contributor Author

d4l3k commented Aug 18, 2016

Review status: 0 of 25 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


config/config.proto, line 69 [r1] (raw file):

Previously, spencerkimball (Spencer Kimball) wrote…

s/constrains/constraints/

Done.

Comments from Reviewable

@bdarnell
Copy link
Contributor

Reviewed 18 of 25 files at r1, 7 of 7 files at r2.
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful.


config/config.proto, line 60 [r2] (raw file):

// ZoneConfig holds configuration that is needed for a range of KV pairs. This
// and the conversion methods must stay in sync with ZoneConfigHuman.
message ZoneConfig {

Add reserved 1 to both message types so we won't try to reuse the deleted tag 1.


config/config.proto, line 74 [r2] (raw file):

}

// ZoneConfigHuman is the human readable shorthand form of ZoneConfig. This and

A protobuf seems like it's only halfway human-readable, and it looks like we never actually use the proto-ness of ZoneConfigHuman. Should it be a plain struct instead (or make To/FromHuman go all the way to strings)? Or could we put MarshalYAML and UnmarshalYAML methods on the Constraint type to get yaml parsing to work the way we want?


config/config.proto, line 86 [r2] (raw file):

// ZoneConfigLegacy is the old version of ZoneConfig and is used for upgrades.
// TODO(d4l3k): Remove after a sufficient amount of time has passed.
message ZoneConfigLegacy {

Shouldn't this also have the range_{min,max}_bytes and gc fields? Could we leave the replica_attrs field in ZoneConfig and do away with the extra proto?


Comments from Reviewable

@d4l3k
Copy link
Contributor Author

d4l3k commented Aug 18, 2016

Review status: 0 of 27 files reviewed at latest revision, 4 unresolved discussions, some commit checks pending.


config/config.proto, line 60 [r2] (raw file):

Previously, bdarnell (Ben Darnell) wrote…

Add reserved 1 to both message types so we won't try to reuse the deleted tag 1.

Done.

config/config.proto, line 74 [r2] (raw file):

Previously, bdarnell (Ben Darnell) wrote…

A protobuf seems like it's only halfway human-readable, and it looks like we never actually use the proto-ness of ZoneConfigHuman. Should it be a plain struct instead (or make To/FromHuman go all the way to strings)? Or could we put MarshalYAML and UnmarshalYAML methods on the Constraint type to get yaml parsing to work the way we want?

Completely slipped my mind that we could use MarshalYAML and UnmarshalYAML. Removed all the ZoneConfigHuman stuff.

config/config.proto, line 86 [r2] (raw file):

Previously, bdarnell (Ben Darnell) wrote…

Shouldn't this also have the range_{min,max}_bytes and gc fields? Could we leave the replica_attrs field in ZoneConfig and do away with the extra proto?

We could leave the `replica_attrs` field in `ZoneConfig` but I feel like having it as a separate proto makes it less confusing. Having a field on a proto that's never supposed to be used sounds hazardous.

As for the other fields, the config.MigrateZoneConfig merges the old and the new proto when upgrading.


Comments from Reviewable

@bdarnell
Copy link
Contributor

Review status: 0 of 27 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful.


config/config.proto, line 86 [r2] (raw file):

Previously, d4l3k (Tristan Rice) wrote…

We could leave the replica_attrs field in ZoneConfig but I feel like having it as a separate proto makes it less confusing. Having a field on a proto that's never supposed to be used sounds hazardous.

As for the other fields, the config.MigrateZoneConfig merges the old and the new proto when upgrading.

But that's the usual case for protobuf evolution: the old fields stick around for as long as they are supported. Removing the field from the "real" protobuf and moving it to a separate "legacy" protobuf is weird. I'd prefer to keep this field in the regular ZoneConfig proto unless there's something specific (like yaml encoding) that makes this tricky to do cleanly.

Comments from Reviewable

@d4l3k
Copy link
Contributor Author

d4l3k commented Aug 18, 2016

Review status: 0 of 27 files reviewed at latest revision, 4 unresolved discussions, some commit checks pending.


config/config.proto, line 86 [r2] (raw file):

Previously, bdarnell (Ben Darnell) wrote…

But that's the usual case for protobuf evolution: the old fields stick around for as long as they are supported. Removing the field from the "real" protobuf and moving it to a separate "legacy" protobuf is weird. I'd prefer to keep this field in the regular ZoneConfig proto unless there's something specific (like yaml encoding) that makes this tricky to do cleanly.

Done.

Comments from Reviewable

@d4l3k
Copy link
Contributor Author

d4l3k commented Aug 23, 2016

@bdarnell boop

@bdarnell
Copy link
Contributor

:lgtm:


Reviewed 2 of 27 files at r3, 25 of 25 files at r4.
Review status: all files reviewed at latest revision, 4 unresolved discussions, some commit checks failed.


Comments from Reviewable

@d4l3k d4l3k force-pushed the zoneconfig branch 2 times, most recently from 7d7b8d9 to 0f79a94 Compare August 25, 2016 16:43
d4l3k added 2 commits August 29, 2016 10:01
Converts ZoneConfig to the new format specified in the expressive ZoneConfig
RFC.  This is intermediate work on cockroachdb#4868.
https://github.com/cockroachdb/cockroach/blob/develop/docs/RFCS/expressive_zone_config.md

- Allocator and StorePool use []config.Constraint instead of roachpb.Attributes
  since the new type allows for different types of constraint.
- Adds a `ZoneConfigLegacy` struct for upgrades to the new format.
- Adds a `ZoneConfigHuman` struct for easier specification on the command line.
@d4l3k d4l3k merged commit efb892b into cockroachdb:develop Aug 29, 2016
@d4l3k d4l3k deleted the zoneconfig branch August 29, 2016 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants