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

Do not initialize custom REST handler during ApiVersion initialization #97

Merged
merged 1 commit into from
Jul 13, 2017

Conversation

ibazhitov
Copy link
Contributor

ApiVersion variable from the versioned package is initialized both
in the apiserver and in the controller-manager because they both
import the versioned package.
When a custom REST handler is defined, its NewFooREST() constructor is
being called directly during ApiVersion initialization. This constructor
may contain some other logic besides simply initializing the custom REST
registry type. For example it may establish a connection to some service.
And we'll end up with an extra unused connection to the external
service, established from the controller manager.

Passing NewFooREST as a function value to builders.NewApiResourceWithStorage()
and then calling it from versionedResourceBuilder.registerEndpoints()
solves this problem.

Fixes #92.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 13, 2017
ApiVersion variable from the versioned package is initialized both
in the apiserver and in the controller-manager because they both
import the versioned package.
When a custom REST handler is defined, its NewFooREST() constructor is
being called directly during ApiVersion initialization. This constructor
may contain some other logic besides simply initializing the custom REST
registry type. For example it may establish a connection to some service.
And we'll end up with an extra unused connection to the external
service, established from the controller manager.

Passing NewFooREST as a function value to builders.NewApiResourceWithStorage()
and then calling it from versionedResourceBuilder.registerEndpoints()
solves this problem.

Fixes kubernetes-sigs#92.
@pwittrock pwittrock merged commit e493e7d into kubernetes-sigs:master Jul 13, 2017
@pwittrock
Copy link
Contributor

@ibazhitov Thanks! Will cut a new release with these changes today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants