Skip to content

Conversation

Danil-Grigorev
Copy link
Member

@Danil-Grigorev Danil-Grigorev commented Jun 2, 2025

What this PR does / why we need it:

This PR refactors the generic provider reconciliation logic to expose internal controllers and phases through the controller/alias.go file. This change allows external users to construct and interact with the core controller logic outside the operator pod.

  • Introduce and expose a phase-based framework for generic provider reconciliation.
  • Define and expose a custom Result type to avoid controller-runtime dependency on import.
  • Enable selectable watching of CoreProvider changes for non-core provider types.

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 #798

This change adds existing internal controller implementations into the `controller/alias.go` file.

This is an initial step towards addressing issue kubernetes-sigs#798, which aims to provide a public API for CAPI Operator providers. The current controller implementation is internal, and this change is a step towards organizing the internal structure, potentially in preparation for exposing parts of it or providing extension points for custom providers.

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 2, 2025
Copy link

netlify bot commented Jun 2, 2025

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

Name Link
🔨 Latest commit 0fe1d45
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-operator/deploys/683da0cc45a218000807e648
😎 Deploy Preview https://deploy-preview-826--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 project configuration.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 2, 2025
Introduce a custom `Result` type for reconciliation phases to provide more granular control over the reconciliation flow, including a `Completed` flag.

Update phase functions and the phase runner to use the new `*Result` return type instead of `ctrl.Result`. This allows phases to signal completion explicitly, improving the logic for handling sequential phases.

Modify the generic provider controller and related components (manifests downloader, phases) to align with the new `Result` type and phase function signatures.

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
Implement a phase-based framework for reconciling generic providers.
This refactors the main reconciliation loop into a sequence of distinct, ordered phases (e.g., download, install, delete).
Introduce `PhaseFn` and `phaseReconciler` types to manage phase execution.
Move existing reconciliation logic into dedicated phase functions.
Update the external `controller` package to epose aliases pointing to the refactored internal types for external import.

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
enable it for all non core provider types (Infrastructure, Bootstrap, ControlPlane, Addon, IPAM, RuntimeExtension).

Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev Danil-Grigorev force-pushed the expose-internal-controllers branch from 4597b2d to 75426a2 Compare June 2, 2025 10:49
@alexander-demicev
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexander-demicev

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 Jun 2, 2025
Signed-off-by: Danil-Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev Danil-Grigorev force-pushed the expose-internal-controllers branch from 3b07f31 to 0fe1d45 Compare June 2, 2025 13:02
Copy link
Member

@furkatgofurov7 furkatgofurov7 left a comment

Choose a reason for hiding this comment

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

/lgtm

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

LGTM label has been added.

Git tree hash: 068beb75a84081ed77bdced6545d16cd8f79b540

@k8s-ci-robot k8s-ci-robot merged commit 95adca5 into kubernetes-sigs:main Jun 3, 2025
14 checks passed
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.

Public API for custom provider implementation
4 participants