api: add DialTimeout #7617

Merged
merged 1 commit into from Jul 11, 2017

Conversation

Projects
None yet
4 participants
Member

axw commented Jul 11, 2017

Description of change

Add DialTimeout to api.DialOpts, and use
it in worker/apicaller instead of Timeout.
This will cause the workers to not timeout
in case of server-side rate-limiting.

QA steps

  1. juju bootstrap localhost
  2. juju enable-ha

Modify apiserver/admin.go to add a Sleep(2*time.Second) before responding to Login. This emulates a highly loaded apiserver which is rate-limiting clients.

  1. juju upgrade-juju -m controller --build-agent
  2. juju debug-log -m controller
    (observe no errors; there were "context deadline exceeded" errors without the DialTimeout changes)

Documentation changes

None.

Bug reference

Fixes https://bugs.launchpad.net/juju/+bug/1701438

api: add DialTimeout
Add DialTimeout to api.DialOpts, and use
it in worker/apicaller instead of Timeout.
This will cause the workers to not timeout
in case of server-side rate-limiting.

Fixes https://bugs.launchpad.net/juju/+bug/1701438

wallyworld approved these changes Jul 11, 2017 edited

Please ensure --race passes

Member

axw commented Jul 11, 2017

Please ensure --race passes

Yup, have done.

Member

axw commented Jul 11, 2017

$$merge$$

Contributor

jujubot commented Jul 11, 2017

Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju

@jujubot jujubot merged commit b1b5463 into juju:2.2 Jul 11, 2017

1 check passed

github-check-merge-juju Ran tests against PR. Use !!.*!! to request another build. IE, !!build!!, !!retry!!
Details
@@ -1125,6 +1240,10 @@ type loginTimeoutAPIAdmin struct {
}
func (a *loginTimeoutAPIAdmin) Login(req params.LoginRequest) (params.LoginResult, error) {
- <-a.r.unblock
+ ch, ok := <-a.r.unblock
@jameinel

jameinel Jul 11, 2017

Owner

This is 2 cases of bare channel sends without an associated select + a tomb so that we can close the object.
Is this sane to be doing?
(I realize the original code was doing a bare receive as well.)
But its often a big red-flag for potential deadlocks if there are any bugs in other code.

@axw

axw Jul 11, 2017

Member

It's in a test, which controls both the sender and the receiver. IMO this is fine.

Owner

jameinel commented Jul 11, 2017

jujubot added a commit that referenced this pull request Jul 11, 2017

Merge pull request #7622 from axw/api-test-login-unblock-select
api: add timeout for unblocking in login test

## Description of change

Use a select with LongWait timeout around the
login "unblock" receive for the api.Open timeout
tests. This will help prevent leaking goroutines
and deadlocks in the tests.

Addresses concerns raised in #7617 (comment).

## QA steps

Run the tests package `api`.

## Documentation changes

None.

## Bug reference

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