-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not initialize custom REST handler during ApiVersion initialization
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.
- Loading branch information
Showing
2 changed files
with
26 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters