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

Refactor controller-manager: turn Serve func into handlerchain builder #60197

Conversation

hzxuzhonghu
Copy link
Member

What this PR does / why we need it:
follow up #59582 fix

turn Serve func into a handler chain builder #59582 (comment)

Special notes for your reviewer:

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 22, 2018
@hzxuzhonghu
Copy link
Member Author

/assign @sttts @deads2k

@hzxuzhonghu
Copy link
Member Author

/assign @lavalamp

@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from dfb7068 to d20e4e5 Compare February 22, 2018 09:43
@hzxuzhonghu
Copy link
Member Author

/cc @stewart-yu

@k8s-ci-robot
Copy link
Contributor

@hzxuzhonghu: GitHub didn't allow me to request PR reviews from the following users: stewart-yu.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @stewart-yu

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

// Serve creates a base handler chain for a controller manager. It runs the
// the chain with the given serveFunc.
func Serve(c *CompletedConfig, serveFunc serveFunc, stopCh <-chan struct{}) error {
func DefaultBuildHandlerChain(c *CompletedConfig) http.Handler {
Copy link
Contributor

Choose a reason for hiding this comment

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

take a handler in? Trying to match func(apiHandler http.Handler, c *Config) (secure http.Handler)

Copy link
Member Author

Choose a reason for hiding this comment

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

No, remove serverFunc. DefaultBuildHandlerChain only takes in config and return a handler like it does in apiserver.

Copy link
Member Author

Choose a reason for hiding this comment

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

github does not compare accurately

@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from 400d5d6 to 5654c2d Compare February 22, 2018 13:18
// the chain with the given serveFunc.
func Serve(c *CompletedConfig, serveFunc serveFunc, stopCh <-chan struct{}) error {
// DefaultBuildHandlerChain takes in CompletedConfig and returns a handler.
func DefaultBuildHandlerChain(c *CompletedConfig) http.Handler {
Copy link
Contributor

Choose a reason for hiding this comment

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

We're trying to match this: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/server/config.go#L130 so that we'll have choices about using this instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for your explanation. And will think about tomorrow morning。

Copy link
Member Author

Choose a reason for hiding this comment

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

@deads2k PTAL

@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from 5654c2d to d7ac2be Compare February 23, 2018 06:17
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 23, 2018
@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from d7ac2be to e32aebe Compare February 23, 2018 08:50
@lavalamp
Copy link
Member

/assign @cheftako

// the chain with the given serveFunc.
func Serve(c *CompletedConfig, serveFunc serveFunc, stopCh <-chan struct{}) error {
// NewDebugHandler takes in CompletedConfig and returns a handler.
func NewDebugHandler(c *CompletedConfig) http.Handler {
Copy link
Contributor

Choose a reason for hiding this comment

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

healthz is not really debug. Can we call it NewBaseHandler or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok to me

@sttts
Copy link
Contributor

sttts commented Feb 27, 2018

Lgtm, only the name DebugHandler is not so good IMO.

@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from e32aebe to d3b3db9 Compare February 27, 2018 12:09
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 27, 2018
@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from d3b3db9 to 51c6043 Compare February 27, 2018 12:14
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 27, 2018
@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from 51c6043 to 9243339 Compare February 27, 2018 12:17
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 27, 2018
@hzxuzhonghu
Copy link
Member Author

Lgtm, only the name DebugHandler is not so good IMO.

Done, renamed to NewBaseHandler

@@ -33,11 +32,23 @@ import (
"k8s.io/kubernetes/pkg/util/configz"
)

type serveFunc func(handler http.Handler, shutdownTimeout time.Duration, stopCh <-chan struct{}) error
// DefaultBuildHandlerChain takes in handler and CompletedConfig and returns a handler.
func DefaultBuildHandlerChain(apiHandler http.Handler, c *CompletedConfig) http.Handler {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: as this is hardcoded anyway, we could just call is BuildHandlerChain. In the apiserver it can be customized for the config. So we called it DefaultBuildHandlerChain because it is the default func.

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, ic, missed it. fixed now

@sttts
Copy link
Contributor

sttts commented Feb 27, 2018

/approve
Lgtm, only little nit: https://github.com/kubernetes/kubernetes/pull/60197/files#r170916600

@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from 9243339 to 1233b17 Compare February 28, 2018 01:42
@hzxuzhonghu
Copy link
Member Author

/retest

@hzxuzhonghu hzxuzhonghu reopened this Feb 28, 2018
@deads2k
Copy link
Contributor

deads2k commented Mar 5, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 5, 2018
@thockin
Copy link
Member

thockin commented Mar 5, 2018

This change is Reviewable

@hzxuzhonghu hzxuzhonghu force-pushed the controller-manager-handler-chain branch from 1233b17 to 540a1de Compare March 6, 2018 01:39
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 6, 2018
@hzxuzhonghu
Copy link
Member Author

rebased @thockin for approval

@hzxuzhonghu
Copy link
Member Author

kindly ping @thockin for approval

@sttts
Copy link
Contributor

sttts commented Mar 22, 2018

@luxas can you approve?

@hzxuzhonghu
Copy link
Member Author

ping @luxas can you approve?

Copy link
Member

@luxas luxas left a comment

Choose a reason for hiding this comment

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

/approve

Thanks @sttts for the ping on Slack. I'm and have been OOO for the first four months of the year, so I don't watch Github or notification email. Sorry for not seeing this.

Thanka for the patch!

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 10, 2018
@sttts
Copy link
Contributor

sttts commented Apr 10, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 10, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, hzxuzhonghu, luxas, sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel comment for consistent failures.

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 60197, 61614, 62074, 62071, 62301). If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 60c6d0e into kubernetes:master Apr 10, 2018
@hzxuzhonghu hzxuzhonghu deleted the controller-manager-handler-chain branch April 11, 2018 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants