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

✨ Introduce generics to providers #475

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

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Mar 25, 2024

What this PR does / why we need it:

This implementation achieves the following:

  • Separate each provider in it’s own reconciler.
  • Share common logic between reconcilers via phase functions, while preserving the original provider type per reconciler. Reconcilers can reuse common methods without restrictions or add their own, applicable only for the reconciler itself.
  • Unifies Clusterctl provider generation for plugin and provider reconcilers under providers package import. Removes the need to do switch cases on provider types in multiple locations. Only one needs to be up-to-date now.
  • Reconcile is split into stages. These are defined like this:
	PreflightChecks(ctx context.Context, provider P) []ReconcileFn[P, Group[P]]
	ReconcileNormal(ctx context.Context, provider P) []ReconcileFn[P, Group[P]]
	ReportStatus(ctx context.Context, provider P) []ReconcileFn[P, Group[P]]
	ReconcileDelete(ctx context.Context, provider P) []ReconcileFn[P, Group[P]]

Each provider can extend/replace/re-order the phases for each stage at their liking.

Additionally a couple of issues are fixed:

  • Core provider singleton check. Previously Core provider was using name check for differentiating other core providers, but the core provider can only be named cluster-api.
  • Pre-flight checks are now unique per each provider, type casting to check provider type to perform some validation is no longer needed.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 25, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from danil-grigorev. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 25, 2024
Copy link

netlify bot commented Mar 25, 2024

Deploy Preview for kubernetes-sigs-cluster-api-operator ready!

Name Link
🔨 Latest commit d365a10
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-operator/deploys/661e91feb942050008756769
😎 Deploy Preview https://deploy-preview-475--kubernetes-sigs-cluster-api-operator.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Danil-Grigorev Danil-Grigorev force-pushed the operator-generics branch 2 times, most recently from 33c6640 to eacf57f Compare March 25, 2024 15:23
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 9, 2024
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 16, 2024
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev
Copy link
Member Author

/test pull-cluster-api-operator-test-main

@k8s-ci-robot
Copy link
Contributor

@Danil-Grigorev: The following tests 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-cluster-api-operator-apidiff-main d365a10 link false /test pull-cluster-api-operator-apidiff-main
pull-cluster-api-operator-test-main d365a10 link true /test pull-cluster-api-operator-test-main

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 19, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please 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 18, 2024
@furkatgofurov7
Copy link
Member

@Danil-Grigorev can you please rebase this PR if this change is needed and to get things going?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants