Skip to content

Reuse controller manager #11602

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

dmitri-d
Copy link
Contributor

@dmitri-d dmitri-d commented Jul 7, 2025

Description

  • Motivation: Controller manager is currently instantiated in ControllerBuilder, with all controllers added to it as part of NewControllerBuilder call, and without any way to register additional controllers without changing ControllerBuilder implementation.
    It should be possible to update kgateway setup/initialization to support creating additional controllers without creating additional instances of controller manager.
  • What changed: Extended setup api to support updating the default controller manager configuration, such as registering additional controllers.

Change Type

/kind cleanup

Changelog

Added support for updating the default controller manager configuration with custom changes on startup.

Additional Notes

dmitri-d added 2 commits July 4, 2025 14:46
Signed-off-by: Dmitri Dolguikh <[email protected]>
…e option is set in tests

Signed-off-by: Dmitri Dolguikh <[email protected]>
@Copilot Copilot AI review requested due to automatic review settings July 7, 2025 17:50
@dmitri-d dmitri-d self-assigned this Jul 7, 2025
@github-actions github-actions bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note labels Jul 7, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Extends the kgateway startup API to reuse a single controller manager instance and allow external registration of additional controllers and manager options.

  • Introduced functional options for REST config, controller-manager options, and extra manager configuration.
  • Refactored setup flow: replaced multiple StartKgateway variants with a unified Start→BuildKgatewayWithConfig→mgr.Start sequence.
  • Updated tests and examples to use the new manager-based setup API.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/envtestutil/util.go Switched test harness to instantiate a controller-runtime Manager and call the new BuildKgateway API.
pkg/setup/setup.go Added RestConfig, CtrlMgrOptions, and ExtraManagerConfig to Options, removed core.AddToScheme invocation.
internal/kgateway/setup/setup.go Added functional option builders (WithRestConfig, WithControllerManagerOptions, WithExtraManagerConfig), removed old XDS-specific entrypoints, unified Start.
internal/kgateway/controller/start.go Updated StartConfig to accept an injected manager.Manager, removed scheme-extension callback via AddToScheme, wired through cfg.Manager.
examples/plugin/main.go Replaced direct StartKgateway call with setup.New(...).Start(...) to demonstrate the new API.
Comments suppressed due to low confidence (1)

pkg/setup/setup.go:28

  • Add a GoDoc comment for RestConfig (and the other new fields) in Options to clarify their purpose.
	RestConfig               *rest.Config

},
})
if err != nil {
panic("failed to create a manager")
Copy link
Preview

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

[nitpick] In a test goroutine, use t.Fatalf or require.NoError instead of panic so the failure is reported by the test harness.

Suggested change
panic("failed to create a manager")
t.Fatalf("failed to create a manager: %v", err)

Copilot uses AI. Check for mistakes.

dmitri-d added 3 commits July 7, 2025 11:13
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
Signed-off-by: Dmitri Dolguikh <[email protected]>
@timflannagan
Copy link
Member

@dmitri-d I think we can skip release note here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants