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

Stop using deprecated SockRequest #33534

Merged
merged 1 commit into from
Aug 24, 2017

Conversation

sbko
Copy link
Contributor

@sbko sbko commented Jun 6, 2017

Signed-off-by: Stanislav Bondarenko stanislav.bondarenko@gmail.com

per #31410

Use client/ package instead of request deprecated SockRequest. If not viable to use client/ replace with new Do, Post, Get, ...

- Description for the changelog
integration-cli: Use client/ package instead of deprecated SockRequest

@aaronlehmann
Copy link
Contributor

There are gofmt issues with a few files.

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch 2 times, most recently from 20e6a2a to 9718178 Compare June 6, 2017 11:01
@sbko
Copy link
Contributor Author

sbko commented Jun 6, 2017

@aaronlehmann should be fixed now

@sbko
Copy link
Contributor Author

sbko commented Jun 6, 2017

looks like windowsRS1 run out of space.

not sure what to do with:
FAIL: docker_cli_run_test.go:4189: DockerSuite.TestRunStoppedLoggingDriverNoLeak
.... leaked goroutines: expected less than or equal to 1560, got: 1690" ....
using /client increased number of goroutines?

@thaJeztah
Copy link
Member

Looks like a couple of tests are failing

@thaJeztah thaJeztah added the status/failing-ci Indicates that the PR in its current state fails the test suite label Jun 9, 2017
@sbko
Copy link
Contributor Author

sbko commented Jun 9, 2017

@thaJeztah failing tests are counting leaked goroutines. I'm not sure what caused that, the only change around those tests is that getGoroutineNumber() now uses client.Info() instead of SockRequest call to "/info"

https://github.com/moby/moby/pull/33534/files/971817824022fadaa6e46ffa6853c789e8878254#diff-eb56f180020ddc0ad74fde7b5b8b55fbR404

@cpuguy83
Copy link
Member

cpuguy83 commented Jun 9, 2017

@sbko Seems like there is something wrong with the client usage.
800+ goroutines is insanely high.
Maybe we aren't closing out connections somewhere?
At least between the two calls to get the goroutines it's increased.

@sbko
Copy link
Contributor Author

sbko commented Jun 9, 2017

@cpuguy83 looks like it. I just reverted change to getGoroutineNumber() and tests passed. I tried requests.Get("/info") instead of SockRequests("GET", "/info,..) and it passes tests as well. I will take a look at client library.

@sbko
Copy link
Contributor Author

sbko commented Jun 9, 2017

@cpuguy83 Looks like it's client itself. defer cli.Close() solves the leak.

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch 3 times, most recently from 5cdde3b to 341fe69 Compare June 9, 2017 17:28
@sbko
Copy link
Contributor Author

sbko commented Jun 9, 2017

@thaJeztah tests are passing now

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch 3 times, most recently from 17f8658 to 99426d6 Compare June 14, 2017 22:50
@sbko
Copy link
Contributor Author

sbko commented Jun 15, 2017

any changes to api?

value *errors.errorString = &errors.errorString{s:"\"secret create\" requires API version 1.25, but the Docker daemon API version is "} ("\"secret create\" requires API version 1.25, but the Docker daemon API version is ")

@thaJeztah
Copy link
Member

I think I know what's happening; version negotiation is currently in the cli, not in the API-client, hence it doesn't know what version of the daemon it's talking to.

There's a pull request to update that; #32779

@thaJeztah
Copy link
Member

But, hm.. if no version was found, it should probably assume "latest" and have the API server return the appropriate error if needed. This is the code that generates the error;

moby/client/errors.go

Lines 228 to 235 in 69c35da

// NewVersionError returns an error if the APIVersion required
// if less than the current supported version
func (cli *Client) NewVersionError(APIrequired, feature string) error {
if versions.LessThan(cli.version, APIrequired) {
return fmt.Errorf("%q requires API version %s, but the Docker daemon API version is %s", feature, APIrequired, cli.version)
}
return nil
}

@sbko
Copy link
Contributor Author

sbko commented Jun 16, 2017

@thaJeztah do we need to open an issue for that?

@thaJeztah
Copy link
Member

@sbko I see that #32779 was merged, perhaps it resolves the issue we're seeing here; this does need a rebase though; can you try rebasing, and see if the issue is resolved?

@sbko
Copy link
Contributor Author

sbko commented Jun 27, 2017

@thaJeztah sure. Thanks!

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch from 99426d6 to 648c01b Compare June 27, 2017 11:13
@sbko
Copy link
Contributor Author

sbko commented Jul 31, 2017

@vdemeester PTAL. do I need to keep rebasing or wait for reviews first?

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

SGTM 🐸
@sbko You can rebase 😉

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch from c58caaa to d7c1f6a Compare August 1, 2017 11:09
@sbko
Copy link
Contributor Author

sbko commented Aug 1, 2017

@vdemeester done! :)

@sbko
Copy link
Contributor Author

sbko commented Aug 9, 2017

@thaJeztah what should be my next step? just wait?

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM (sorry for the delay)

ping @dnephin can you have another look as well?

I see it needs a minor rebase

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

This PR is quite large. I did another quick scan, and it generally seems fine, but I didn't really look at every change.

In the future doing multiple smaller PRs will make it much easier to review, and should reduce the time it takes to get it merged.

Couple minor comments, but nothing blocking a merge.

}

cli, err := client.NewClient(d.Sock(), api.DefaultVersion, httpClient, nil)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

minor: this if is unnecessary, just return client.NewClient(...)

Copy link
Contributor Author

@sbko sbko Aug 15, 2017

Choose a reason for hiding this comment

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

@dnephin done

Copy link
Member

Choose a reason for hiding this comment

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

I still see the if here

if status != http.StatusOK {
return info.Swarm, fmt.Errorf("get swarm info: invalid statuscode %v", status)
}
cli, err := d.NewClient()
Copy link
Member

Choose a reason for hiding this comment

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

It might be easier to just store a client on the daemon struct here, instead of recreating it each time.

I guess that's an improvement we can make in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch from d7c1f6a to 5824d79 Compare August 15, 2017 11:25
@sbko
Copy link
Contributor Author

sbko commented Aug 15, 2017

@thaJeztah I rebased the code, added requested change and tests failed with looks like unrelated errors. I see that other PRs experience similar errors. is that a known issue? thanks!

@thaJeztah
Copy link
Member

I think there was an issue with Docker Hub search causing these failures; restarting CI

@sbko
Copy link
Contributor Author

sbko commented Aug 15, 2017

@thaJeztah looks like still failing:

19:46:48 FAIL: docker_api_containers_test.go:1584: DockerSuite.TestContainerAPIDeleteWithEmptyName
19:46:48 docker_api_containers_test.go:1590:
19:46:48 c.Assert(err.Error(), checker.Contains, "No container name or ID supplied")
19:46:48 ... obtained string = "Error response from daemon: page not found"
19:46:48 ... substring string = "No container name or ID supplied"

Error should be "No container name or ID supplied" but for some reason it's "Error response from daemon: page not found". Checking why is that...

@thaJeztah
Copy link
Member

@sbko yes, I chatted with the Hub team yesterday, and the cause was that the search index was out of date, causing the busybox image (which is used in that test) not being returned in the first X search results.

They triggered a re-index, and it should now (really) be fixed; triggering once more 😅

@vdemeester
Copy link
Member

arf @sbko needs rebasing 😓
/cc @dnephin can you help ? 👼

@sbko
Copy link
Contributor Author

sbko commented Aug 22, 2017

@vdemeester I was busy last week. I will probably rebase tonight or tomorrow.

@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch 2 times, most recently from 9f810ec to 2332f77 Compare August 23, 2017 03:06
@sbko
Copy link
Contributor Author

sbko commented Aug 23, 2017

@vdemeester @dnephin rebased

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

This might be easier to get in (faster reveiws and fewer rebases) if it were split into smaller chunks. +/- 300 lines is significantly easier to review than +/-1500.

)

func (s *DockerSuite) TestAPICreateWithNotExistImage(c *check.C) {
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a bad merge. These tests were removed in #34000

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

func getAllPlugins() (types.PluginsListResponse, error) {
var plugins types.PluginsListResponse
_, b, err := request.SockRequest("GET", "/plugins", nil, request.DaemonHost())
func getAllPlugins(c *client.Client) (types.PluginsListResponse, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be using client.APIClient (the interface), same is true in other places.

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

cli, err := client.NewEnvClient()
if err != nil {
t.Fatalf("%v", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

require.NoError(t, err)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks like "require.NoError" doesn't work with "testingT"

}

cli, err := client.NewClient(d.Sock(), api.DefaultVersion, httpClient, nil)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I still see the if here

Signed-off-by: Stanislav Bondarenko <stanislav.bondarenko@gmail.com>
@sbko sbko force-pushed the 31410-replace-deprecated-sockrequest branch from 2332f77 to 0fd5a65 Compare August 23, 2017 21:10
@sbko
Copy link
Contributor Author

sbko commented Aug 23, 2017

made changes per @dnephin review and rebased again :)
@dnephin my next pull request will be smaller ;)

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.

None yet

8 participants