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

support v3 discovery to bootstrap a new etcd cluster #13635

Merged
merged 1 commit into from
Feb 21, 2022

Conversation

ahrtr
Copy link
Member

@ahrtr ahrtr commented Jan 24, 2022

It's the first PR for issues/13624. I will raise separate PRs to add test (including unit test and integration or e2e tests) and update documentation.

It follows the same workflow as the existing v2discovery.

Each etcd instance in the bootstrapped cluster communicates with the discovery service(anther etcd instance or cluster) using v3client. It's similar to etcdctl communicating with etcd server, so basically most of the global flags(such as --cert, --key, etc.) for etcdctl can be used here as well.

cc @serathius @ptabor @spzala

server/embed/config.go Outdated Show resolved Hide resolved
@ahrtr
Copy link
Member Author

ahrtr commented Jan 24, 2022

The test failures should be caused by unstable test cases, because all test passed in another PR, see ahrtr#1

@ahrtr ahrtr force-pushed the v3_discovery branch 3 times, most recently from a143acd to a2174c2 Compare January 24, 2022 11:32
@ahrtr
Copy link
Member Author

ahrtr commented Jan 24, 2022

@serathius Resolved all your comments, PTAL. Thanks!

@ahrtr
Copy link
Member Author

ahrtr commented Jan 25, 2022

@serathius Thanks for the useful comments, and I resolved all of them.

server/embed/config.go Outdated Show resolved Hide resolved
maxExpoentialRetries = uint(8)
)

type DiscoveryConfig struct {
Copy link
Member

Choose a reason for hiding this comment

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

This config is part of embed.Config, As so we should annotate its fields with json. Can you replace flags names with json annotations?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done & thanks.

Copy link
Contributor

@ptabor ptabor Feb 21, 2022

Choose a reason for hiding this comment

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

Independently how we structure the flags (the other comment),
I think we should structure this configuration to be explicit what's just client config,
and what's discovery specific (in this case - nothing).

How about structuring this protos/json as follows (ie. grouping client stuff in the client: submessage.

type ClientConfig struct {  // Ideally in `client/v3/...`
  Endpoints string[] `json:"endpoints"`
  DialTimeout time.Duration `json:"dial-timeout"`
  ... 
}

type DiscoveryConfig struct {
  Client client `json:"client"`
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's a good point. Actually previously @serathius already raised a similar comment.

Since it may have some impacts on the clientv3 and also the etcdctl tool, so I'd like to resolve this comment in a separate PR.

There is already a clientconfig, but it's in etcdctl instead of clientv3. So we may need some minor refactor. So I prefer to doing it in a separate PR.

What do you think? @ptabor @serathius @spzala

--discovery ''
Discovery URL used to bootstrap the cluster.
--discovery-dial-timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be way nicer if we had a single json describing any etcd client configuration:

--discovery-conn-json='{url: ... dial-timeout: ...}'

this would keep the configuration up-to date with all the changes we introduce to the client without introducing a lot of custom flags.

Copy link
Member Author

@ahrtr ahrtr Jan 25, 2022

Choose a reason for hiding this comment

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

Yes, I agree that it's extensible, but it looks a little strange and may not be easy to use. Do you mean to get all the new fields (see below) included in a single json?


  --discovery-dial-timeout
    V3 discovery: dial timeout for client connections.
  --discovery-request-timeout
    V3 discovery: timeout for discovery requests (excluding dial timeout).
  --discovery-keepalive-time
    V3 discovery: keepalive time for client connections.
  --discovery-keepalive-timeout
    V3 discovery: keepalive timeout for client connections.
  --discovery-insecure-transport 'false'
    V3 discovery: disable transport security for client connections.
  --discovery-insecure-skip-tls-verify
    V3 discovery: skip server certificate verification (CAUTION: this option should be enabled only for testing purposes).
  --discovery-cert
    V3 discovery: identify secure client using this TLS certificate file.
  --discovery-key
    V3 discovery: identify secure client using this TLS key file.
  --discovery-cacert
    V3 discovery: verify certificates of TLS-enabled secure servers using this CA bundle.
  --discovery-user
    V3 discovery: username[:password] for authentication (prompt if password is not supplied).
  --discovery-password
    V3 discovery: password for authentication (if this option is used, --user option shouldn't include password).



Copy link
Member

@serathius serathius Jan 26, 2022

Choose a reason for hiding this comment

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

I think that we might want to invest into making configuration more reusable, like extracting and reusing common client configuration struct. This is however independent on the decision on introducing hybrid flag like --discovery-conn-json that combine both command line and JSON interface.

Personally I would prefer not to go in this direction as passing JSON into command line commands is very error prone.

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the idea, I will try to fix it in a separate PR. Thanks @serathius

I think that we might want to invest into making configuration more reusable, like extracting and reusing common client configuration struct.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM.
Even if we want to keep the flags separate and top-level, I think we should I'm at sharing the logic with:

rootCmd.PersistentFlags().BoolVar(&globalFlags.Insecure, "insecure-transport", true, "disable transport security for client connections")
rootCmd.PersistentFlags().BoolVar(&globalFlags.InsecureDiscovery, "insecure-discovery", true, "accept insecure SRV records describing cluster endpoints")
rootCmd.PersistentFlags().BoolVar(&globalFlags.InsecureSkipVerify, "insecure-skip-tls-verify", false, "skip server certificate verification (CAUTION: this option should be enabled only for testing purposes)")
rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.CertFile, "cert", "", "identify secure client using this TLS certificate file")
rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.KeyFile, "key", "", "identify secure client using this TLS key file")
rootCmd.PersistentFlags().StringVar(&globalFlags.TLS.TrustedCAFile, "cacert", "", "verify certificates of TLS-enabled secure servers using this CA bundle")
rootCmd.PersistentFlags().StringVar(&globalFlags.User, "user", "", "username[:password] for authentication (prompt if password is not supplied)")
rootCmd.PersistentFlags().StringVar(&globalFlags.Password, "password", "", "password for authentication (if this option is used, --user option shouldn't include password)")
rootCmd.PersistentFlags().StringVarP(&globalFlags.TLS.ServerName, "discovery-srv", "d", "", "domain name to query for SRV records describing cluster endpoints")
rootCmd.PersistentFlags().StringVarP(&globalFlags.DNSClusterServiceName, "discovery-srv-name", "", "", "service name to query when using DNS discovery")
rootCmd.AddCommand(
command.NewGetCommand(),
command.NewPutCommand(),
command.NewDelCommand(),
.

such tag all the flags can be imported as:

  DeclareV3ClientFlags(rootCmd.PersistentFlags(), &someContext.Client, "discovery", "discoveryV3: ");

But I'm fine with doing this in separate PR. Just it's good to align the naming.

Copy link
Contributor

@ptabor ptabor left a comment

Choose a reason for hiding this comment

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

Thank you for migrating this code.

server/etcdserver/api/v3discovery/discovery.go Outdated Show resolved Hide resolved
server/etcdserver/api/v3discovery/discovery.go Outdated Show resolved Hide resolved
server/etcdserver/api/v3discovery/discovery.go Outdated Show resolved Hide resolved
server/etcdserver/api/v3discovery/discovery.go Outdated Show resolved Hide resolved
Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

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

LGTM
PTAL @spzala @ptabor

@spzala
Copy link
Member

spzala commented Feb 10, 2022

@ahrtr @serathius sorry didn't get to review it earlier, but doing it today. Thanks!

Copy link
Member

@spzala spzala left a comment

Choose a reason for hiding this comment

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

@ahrtr great work, thanks!! I have one comment in help.go that should be addressed, and also a few nits (I won't ask changes just for nits but for help.go comment we should make changes if you agree) Thanks!

server/etcdmain/help.go Outdated Show resolved Hide resolved
@ahrtr ahrtr force-pushed the v3_discovery branch 2 times, most recently from e359364 to 539c263 Compare February 10, 2022 23:52
@ahrtr
Copy link
Member Author

ahrtr commented Feb 11, 2022

Resolved the comment in help.go. PTAL @spzala Thanks.

@spzala
Copy link
Member

spzala commented Feb 11, 2022

Resolved the comment in help.go. PTAL @spzala Thanks.

Thanks @ahrtr

Copy link
Member

@serathius serathius left a comment

Choose a reason for hiding this comment

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

LGTM,

Let's also get @ptabor optinion as he proposed the migration plan.

@ahrtr
Copy link
Member Author

ahrtr commented Feb 14, 2022

Just rebased this PR.

@ahrtr
Copy link
Member Author

ahrtr commented Feb 18, 2022

Just rebased this PR. cc @ptabor

@ahrtr ahrtr force-pushed the v3_discovery branch 2 times, most recently from 8478fc7 to 8ca3ea6 Compare February 21, 2022 15:07
@ahrtr
Copy link
Member Author

ahrtr commented Feb 21, 2022

Resolved all your comments except the following two items:

  1. Make V3 discovery and clientv3 to reuse the same client config;
  2. Change v3 discovery url to endpoints so as to support failover.

Since the changes to resolve above two comments might have some impacts on the existing clientv3 and etcdctl, so I prefer to resolving them in a separate PR. WDYT? @ptabor @serathius @spzala

@serathius
Copy link
Member

SGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants