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

✨ Support creating management v3 cluster #362

Merged

Conversation

salasberryfin
Copy link
Contributor

@salasberryfin salasberryfin commented Jan 29, 2024

What this PR does / why we need it:

This PR adds support for representing imported CAPI clusters as management.cattle.io/v3 clusters instead of the current provisioning.cattle.io/v1 resource.

ADR 8 contains the rationale behind choosing this implementation approach and the discussions on different alternatives before agreeing to a decision.

This includes a new import controller specific for the new type of resource, which is only enabled if using a feature flag, so the default behavior of Rancher Turtles is to continue with the current import strategy. Some of the functions that are used by both controllers have been centralized so that we have less code to maintain. Still, some of the controller code is very similar to one another but re-utilizing it would probably increase complexity and reduce readability.

An E2E specification equivalent to the existing import gitops has been created for when Rancher Turtles is executed with this feature flag enabled.

There are definitely improvements to the way the code is structured. Especially in terms of increasing the re-usability, for both controller and E2E, but my opinion is that this PR is large enough to also add a larger refactor. Probably it would be better if we can have a couple of follow-ups to simplify the code where possible. But this is obviously a team decision. Additionally, there will be a discussion on whether we should move completely to this new controller and deprecate provisioning.cattle.io, so it may not make much sense to invest time in increasing re-usable components at this point.

Which issue(s) this PR fixes:
Fixes #298

Special notes for your reviewer:

The DeletionTimestamp seems to not be set when the Rancher Cluster is deleted. The logic is the same that we use for other controller, though. I would appreciate any feedback on this. I'll leave a comment below.

The new feature flag is added to the docs here.

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@salasberryfin salasberryfin requested a review from a team as a code owner January 29, 2024 08:57
@salasberryfin salasberryfin force-pushed the support-creating-management-v3-cluster branch 15 times, most recently from ef74d3e to fa01e18 Compare February 1, 2024 17:34
@salasberryfin salasberryfin force-pushed the support-creating-management-v3-cluster branch 3 times, most recently from 9ab7beb to 0de8141 Compare February 2, 2024 13:49
@salasberryfin salasberryfin changed the title WIP: Support creating management v3 cluster Support creating management v3 cluster Feb 2, 2024
@salasberryfin salasberryfin force-pushed the support-creating-management-v3-cluster branch 4 times, most recently from f3988f0 to dcacd4a Compare February 14, 2024 10:44
@salasberryfin salasberryfin requested review from richardcase and removed request for a team February 14, 2024 11:36
@salasberryfin salasberryfin force-pushed the support-creating-management-v3-cluster branch from f74610b to 463bf77 Compare February 26, 2024 13:21
@salasberryfin
Copy link
Contributor Author

This is now updated and rebased with the recent changes to the test environment.

@salasberryfin
Copy link
Contributor Author

Seems like this is now ready for a final review. Thanks everyone for taking the time to add your suggestions.

@salasberryfin
Copy link
Contributor Author

Reminder that there's also this documentation PR rancher/turtles-docs#59 to document the new feature flag.

internal/controllers/helpers.go Outdated Show resolved Hide resolved
internal/controllers/import_controller.go Outdated Show resolved Hide resolved
Danil-Grigorev
Danil-Grigorev previously approved these changes Feb 28, 2024
Copy link
Contributor

@Danil-Grigorev Danil-Grigorev left a comment

Choose a reason for hiding this comment

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

Some nits, overall looks good

internal/controllers/import_controller_v3.go Outdated Show resolved Hide resolved
internal/controllers/import_controller_v3.go Outdated Show resolved Hide resolved
internal/controllers/import_controller_v3.go Show resolved Hide resolved
internal/controllers/import_controller_v3.go Show resolved Hide resolved
internal/controllers/import_controller_v3.go Show resolved Hide resolved
test/e2e/suites/managementv3/managementv3_test.go Outdated Show resolved Hide resolved
Copy link
Member

@alexander-demicev alexander-demicev left a comment

Choose a reason for hiding this comment

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

looks great, couple minor comments

internal/controllers/helpers.go Show resolved Hide resolved
internal/controllers/helpers.go Outdated Show resolved Hide resolved
internal/controllers/import_controller_v3.go Outdated Show resolved Hide resolved
internal/controllers/import_controller_v3.go Outdated Show resolved Hide resolved
internal/controllers/import_controller_v3.go Outdated Show resolved Hide resolved
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
@salasberryfin salasberryfin force-pushed the support-creating-management-v3-cluster branch 2 times, most recently from 9f4d45f to 927cae7 Compare February 29, 2024 16:20
Signed-off-by: Carlos Salas <carlos.salas@suse.com>
@richardcase richardcase merged commit 1d4de3b into rancher:main Mar 5, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to generate v3.Cluster
4 participants