Skip to content

⚠️ NewTypedUnmanaged: Stop requiring a manager #3141

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

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

alvaroaleman
Copy link
Member

Currently, NewUnmanaged and NewTypedUnmanaged require a manager but the only properties they ever access from it are GetControllerOptions and GetLogger. It makes no sense to require a Manager for something that is unmanaged, so remove that.

Doing so naively means that we require two options parameters for these constructors, one that has the actual options and another one to default from which again is confusing. Remove the options struct to default from and instead implement a DefaultFromConfig that defaults the controller options config.Controller which also clarifies what belongs where. This defaulting gets automatically called in the managed constructors and is exported so anyone can use it.

This change is breaking only for users of New[Typed]Unmanaged in that:

  • The signature changes
  • The defaulting of the controller.Options from config.Controller doesn't happen anymore, but it is still possible to do that explicitly

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 4, 2025
@k8s-ci-robot k8s-ci-robot requested a review from joelanford March 4, 2025 19:12
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 4, 2025
@k8s-ci-robot k8s-ci-robot requested a review from troy0820 March 4, 2025 19:12
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 4, 2025
}

// DefaultFromConfig defaults the config from a config.Controller
func (options *TypedOptions[request]) DefaultFromConfig(config config.Controller) {
Copy link
Member Author

Choose a reason for hiding this comment

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

What is notably absent from this change are tests - That is because this behavior is already verified by existing tests

@alvaroaleman alvaroaleman changed the title :warn: NewTypedUnmanaged: Stop requiring a manager ⚠️ NewTypedUnmanaged: Stop requiring a manager Mar 4, 2025
@alvaroaleman alvaroaleman force-pushed the factor-out branch 2 times, most recently from df0838a to 3b05ebd Compare March 4, 2025 19:20
@alvaroaleman alvaroaleman force-pushed the factor-out branch 2 times, most recently from deb06d8 to ceb6d37 Compare March 4, 2025 22:40
Currently, `NewUnmanaged` and `NewTypedUnmanaged` require a manager but
the only properties they ever access from it are `GetControllerOptions`
and `GetLogger`. It makes no sense to require a `Manager` for something
that is unmanaged, so remove that.

Doing so naively means that we require two options parameters for these
constructors, one that has the actual options and another one to default
from which again is confusing. Remove the options struct to default from
and instead implement a `DefaultFromConfig` that defaults the controller
options `config.Controller` which also clarifies what belongs where.
This defaulting gets automatically called in the managed constructors
and is exported so anyone can use it.

This change is breaking only for users of `New[Typed]Unmanaged` in that:
* The signature changes
* The defaulting of the `controller.Options` from `config.Controller`
  doesn't happen anymore, but it is still possible to do that explicitly
@k8s-ci-robot
Copy link
Contributor

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

Test name Commit Details Required Rerun command
pull-controller-runtime-apidiff d9ff283 link false /test pull-controller-runtime-apidiff

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

@sbueringer
Copy link
Member

Thank you!

/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 Mar 5, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 607fe96b999392c4a720f02a48a0fc6d8debe0ec

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, sbueringer

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:
  • OWNERS [alvaroaleman,sbueringer]

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 merged commit 385eeaa into kubernetes-sigs:main Mar 5, 2025
8 of 9 checks passed
@alvaroaleman alvaroaleman deleted the factor-out branch March 5, 2025 22:21
embik added a commit to embik/multicluster-runtime that referenced this pull request May 22, 2025
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants