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

Add some retry to the service proxy. #2281

Merged
merged 1 commit into from
Nov 13, 2014
Merged

Conversation

brendandburns
Copy link
Contributor

No description provided.

glog.V(3).Infof("Mapped service %q to endpoint %s", service, endpoint)
// TODO: This could spin up a new goroutine to make the outbound connection,
// and keep accepting inbound traffic.
outConn, err := net.DialTimeout("tcp", endpoint, endpointDialTimeout)
Copy link
Member

Choose a reason for hiding this comment

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

If we're going to retry, we should crank down the dial timeout, no? or maybe start it small and grow it on each failed backend (1sec on first backend, 2 on 2nd, 4 on 3rd)?

@thockin
Copy link
Member

thockin commented Nov 11, 2014

no love for UDP?

@brendandburns
Copy link
Contributor Author

comments addressed.

thanks

@brendandburns
Copy link
Contributor Author

Since @thockin is out, can I have mergez from someone else?

Thanks!
--brendan

@lavalamp lavalamp self-assigned this Nov 12, 2014
@@ -76,6 +76,26 @@ type tcpProxySocket struct {
net.Listener
}

func tryConnect(service string, srcAddr net.Addr, protocol string, proxier *Proxier) (out net.Conn, err error) {
for retries := 0; retries < 3; retries++ {
Copy link
Member

Choose a reason for hiding this comment

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

for _, timeout := range endpointDialTimeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@brendandburns
Copy link
Contributor Author

Comments addressed.

--brendan

// How long we wait for a connection to a backend.
const endpointDialTimeout = 5 * time.Second
// How long we wait for a connection to a backend in seconds
var endpointDialTimeout = []time.Duration{1, 2, 4, 8}
Copy link
Member

Choose a reason for hiding this comment

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

I'm really sorry, I should have noticed this before-- can you either make this an []int, or put the x*time.Second up here? It sort of breaks the Duration concept to multiply a duration by a duration, like what happens down on line 89.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't let you do that with an int type variable without a cast, Go must
be doing something magical for 1*time.Second.

So the options are:

Duration[] { 1_time.Second, 2_time.Second, ...}

Or

time.Duration(timeout)*time.Second

Both of which are worse in my opinion.

Brendan

In pkg/proxy/proxier.go:

@@ -56,8 +56,8 @@ func (si *serviceInfo) setActive(val bool) bool {
return tmp
}

-// How long we wait for a connection to a backend.
-const endpointDialTimeout = 5 * time.Second
+// How long we wait for a connection to a backend in seconds
+var endpointDialTimeout = []time.Duration{1, 2, 4, 8}

I'm really sorry, I should have noticed this before-- can you either make
this an []int, or put the x*time.Second up here? It sort of breaks the
Duration concept to multiply a duration by a duration, like what happens
down on line 89.


Reply to this email directly or view it on GitHub
https://github.com/GoogleCloudPlatform/kubernetes/pull/2281/files#r20266395
.

Copy link
Member

Choose a reason for hiding this comment

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

ah, right, it works because constants are untyped.

sigh I'd prefer Duration[] { 1_time.Second, 2_time.Second, ...} but I guess I won't make you change it.

@lavalamp
Copy link
Member

LGTM

lavalamp added a commit that referenced this pull request Nov 13, 2014
Add some retry to the service proxy.
@lavalamp lavalamp merged commit 787c221 into kubernetes:master Nov 13, 2014
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.

None yet

3 participants