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: InitFunc and base controller interface. #95885

Merged
merged 3 commits into from
Aug 27, 2021
Merged

refactor: controller manager: InitFunc and base controller interface. #95885

merged 3 commits into from
Aug 27, 2021

Conversation

jiahuif
Copy link
Member

@jiahuif jiahuif commented Oct 26, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds an interface for all controllers, as defined as follows:

// Interface defines the base of a controller managed by a controller manager
type Interface interface {
}

// Debuggable defines a controller that requests the controller manager
// to expose a debugging handler for the controller
//
// If a controller implements Debuggable, and the returned handler is
// not nil, the controller manager will mount the handler during startup.
type Debuggable interface {
	// DebuggingHandler returns a Handler that expose debugging information
	// for the controller, or nil if a debugging handler is not desired.
	//
	// The handler will be accessible at "/debug/controllers/{controllerName}/".
	DebuggingHandler() http.Handler
}

Originally, a controller expose debugging handler by returning the handler through InitFunc, added in #66623

// InitFunc is used to launch a particular controller.  It may run additional "should I activate checks".
// Any error returned will cause the controller process to `Fatal`
// The bool indicates whether the controller was enabled.
type InitFunc func(ctx ControllerContext) (debuggingHandler http.Handler, enabled bool, err error)

This method limits the extensibility of controllers. If we need to add other features (e.g. health checks) to each controller, we have to yet add another return value. Also, it will benefit us to have a standardized controller.Interface type.

Which issue(s) this PR fixes:

Special notes for your reviewer:
cloud-controller-manager explicitly disallowed debuggingHandler.

https://github.com/kubernetes/kubernetes/blob/v1.22.1/staging/src/k8s.io/cloud-provider/app/controllermanager.go#L276

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

https://kubernetes.io/docs/concepts/architecture/controller/
https://github.com/kubernetes/kubernetes/pull/66623

@k8s-ci-robot k8s-ci-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/cloudprovider sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/network Categorizes an issue or PR as relevant to SIG Network. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 26, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 26, 2020
@jiahuif jiahuif changed the title refactor: controller manager: base Controller type. refactor: controller manager: base Controller type and InitFunc. Oct 26, 2020
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 26, 2020
@jiahuif
Copy link
Member Author

jiahuif commented Oct 27, 2020

/assign @cheftako

@fedebongio
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 27, 2020
@k8s-triage-robot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jul 29, 2021
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 20, 2021
@jiahuif
Copy link
Member Author

jiahuif commented Aug 20, 2021

/remove-lifecycle stale
because of a split PR.

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Aug 20, 2021
@cheftako
Copy link
Member

Looks like format need to be run.

@jiahuif
Copy link
Member Author

jiahuif commented Aug 25, 2021

Rebased this PR as go is upgraded to 1.17

@@ -726,3 +726,7 @@ func GetDeletableResources(discoveryClient discovery.ServerResourcesInterface) m

return deletableGroupVersionResources
}

func (gc *GarbageCollector) Name() string {
Copy link
Member

Choose a reason for hiding this comment

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

If we want GarbageCollector to implement the controller.Interface then we should add a check when we define GarbageCollector that it implements that interface.

var _ contoller.Interface = GarbageCollector{}

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. Added these assertions below the def. of GarbageCollector.

@cheftako
Copy link
Member

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 27, 2021
@jiahuif
Copy link
Member Author

jiahuif commented Aug 27, 2021

/assign @BenTheElder

could you take a look at vendor/?

Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

/approve
for vendor/modules.txt

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, cheftako, jiahuif

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 27, 2021
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Aug 27, 2021

@jiahuif: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Rerun command
pull-kubernetes-conformance-kind-ipv6-parallel ceaab9c70b6be01bf797c38e296356ba8aca77ee link /test pull-kubernetes-conformance-kind-ipv6-parallel
pull-kubernetes-e2e-ubuntu-gce-network-policies ceaab9c70b6be01bf797c38e296356ba8aca77ee link /test pull-kubernetes-e2e-ubuntu-gce-network-policies
pull-kubernetes-conformance-image-test ceaab9c70b6be01bf797c38e296356ba8aca77ee link /test pull-kubernetes-conformance-image-test
pull-kubernetes-e2e-gce-alpha-features ceaab9c70b6be01bf797c38e296356ba8aca77ee link /test pull-kubernetes-e2e-gce-alpha-features

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@jiahuif
Copy link
Member Author

jiahuif commented Aug 27, 2021

/retest

@k8s-ci-robot k8s-ci-robot merged commit cd63952 into kubernetes:master Aug 27, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Aug 27, 2021
@jiahuif jiahuif deleted the refactor/controller-manager branch August 27, 2021 22:41
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. area/cloudprovider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/autoscaling Categorizes an issue or PR as relevant to SIG Autoscaling. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/network Categorizes an issue or PR as relevant to SIG Network. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants