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

✨ etcd: Etcd client with dialer passthrough. #2031

Closed

Conversation

randomvariable
Copy link
Member

What this PR does / why we need it:
Allows user to contact etcd with arbitrary connection types, useful
when proxying through the Kubernetes API server.

Protobuf types are wrapped such that downstream consumers do not
need to import etcd packages.

Signed-off-by: Naadir Jeewa jeewan@vmware.com

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #1902

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 9, 2020
@randomvariable randomvariable force-pushed the etcd-client branch 4 times, most recently from d9ce606 to d1fe78d Compare January 9, 2020 14:39
@randomvariable
Copy link
Member Author

@dlipovetsky

Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

some architecture concerns and some copy pasta clean ups

util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
@randomvariable randomvariable force-pushed the etcd-client branch 2 times, most recently from 70a1384 to f4cd6c0 Compare January 9, 2020 15:43
Copy link
Contributor

@chuckha chuckha left a comment

Choose a reason for hiding this comment

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

Everything in this review is a nit. Feel free to fix or not. Looks great!

/approve

util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2020
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
@dlipovetsky
Copy link
Contributor

Thanks a lot for creating this client!

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chuckha, dlipovetsky, randomvariable

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dlipovetsky
Copy link
Contributor

Out of curiosity: Why create an ephemeral etcd client in each function, as opposed to creating a long-lived etcd client?

@randomvariable randomvariable force-pushed the etcd-client branch 3 times, most recently from 80f64c8 to 74957ed Compare January 13, 2020 13:30
@randomvariable
Copy link
Member Author

May need to refresh the connection as API servers move around, but it makes more sense for that to be a consumer-level concern, so have switched to long-lived.

@randomvariable
Copy link
Member Author

/retest

@vincepri
Copy link
Member

Reviewing this now

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

Overall this is a great effort. I've left some comments regarding some consistency around the godoc lines (mostly nits), and some others regarding the logic during backoff.

Thank you for putting this together!

util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
util/etcd/etcd.go Outdated Show resolved Hide resolved
@randomvariable randomvariable force-pushed the etcd-client branch 3 times, most recently from f9480df to bcb1e6b Compare January 13, 2020 16:57
@randomvariable randomvariable force-pushed the etcd-client branch 2 times, most recently from 0490393 to 4ad1568 Compare January 13, 2020 17:08
@randomvariable
Copy link
Member Author

/test pull-cluster-api-verify

controlplane/kubeadm/internal/etcd/etcd.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/etcd/etcd.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/etcd/etcd.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/etcd/etcd.go Outdated Show resolved Hide resolved
Allows user to contact etcd with arbitrary connection types, useful
when proxying through the Kubernetes API server.

Protobuf types are wrapped such that downstream consumers do not
need to import etcd packages.

Signed-off-by: Naadir Jeewa <jeewan@vmware.com>
@randomvariable
Copy link
Member Author

Rebased on master.

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/lgtm

/hold
@ncdc feel free to remove the hold when you're ready

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Jan 14, 2020
if c.MemberID == newMember.ID {
newMember.Alarms = append(newMember.Alarms, c.Type)
}
members[i] = newMember
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want this outside of the alarms loop?

}

// UpdateMemberPeerList updates the given member's list of peers.
func (c *Client) UpdateMemberPeerList(id uint64, peerURLs []string) (*[]Member, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You want to return a pointer to a slice, not a slice of pointers?

}

// Members retrieves a list of etcd members.
func (c *Client) Members() (*[]Member, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You want to return a pointer to a slice, not a slice of pointers?

}

// Alarms retrieves all alarms on a cluster.
func (c *Client) Alarms() (*[]MemberAlarm, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You want to return a pointer to a slice, not a slice of pointers?

// BackoffParams sets the parameters for the client
func BackoffParams(params wait.Backoff) func(*Client) error {
return func(c *Client) error {
return c.setBackoffParams(params)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I would have split this out into a separate function, but it's fine to keep it this way if you want.

// Endpoint changes the etcd endpoint for the client
func Endpoint(addr string) func(*Client) error {
return func(c *Client) error {
return c.setEndpoint(addr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I would have split this out into a separate function, but it's fine to keep it this way if you want.

// Timeout changes the method timeout for the etcd client
func Timeout(duration time.Duration) func(*Client) error {
return func(c *Client) error {
return c.setTimeout(duration)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I would have split this out into a separate function, but it's fine to keep it this way if you want.

@ncdc ncdc added this to the v0.3.0 milestone Jan 16, 2020
@randomvariable
Copy link
Member Author

Doing revisions whilst working on consumption of the package. Temporarily closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants