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

Extensions: Add hooks to support virtual clusters #11064

Merged
merged 23 commits into from
Jan 31, 2025

Conversation

nwmac
Copy link
Member

@nwmac nwmac commented May 21, 2024

Summary

Fixes #11065

This PR adds several hooks for virtual cluster support.

The main change is a new extension API addModelExtension - this is marked experimental for now - once we establish if we need any changes, we can remove that label.

You can register model extensions and they are stored against a model type, e.g. provisioning.cattle.io.cluster. There is a method on the Steve base class to retrieve all of the model extensions for a given model type. You can register multiple model extensions for a given model.

Beyond that, it is up to a given model to decide how to use these model extensions - i.e. a model needs to define an API for them and explicitly wire that into itself. This ensures we have a defined API for extensibility, rather than allowing a model extension to do anything it wants.

In this PR, we write a model extension into the provisioning cluster model to support the needs of virtual clusters.

Risk wise, this PR is designed to minimise impact to existing code, so the risk is small.

Areas or cases that should be tested

These hooks will be tested by extensions.

Current e2e test should validate that the hooks do not break existing functionality.

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes

@rancher-ui-project-bot rancher-ui-project-bot bot added this to the v2.9.0 milestone May 21, 2024
@nwmac nwmac marked this pull request as ready for review May 23, 2024 10:36
@nwmac nwmac requested a review from mantis-toboggan-md May 23, 2024 10:37
@nwmac nwmac changed the title Add hooks to support virtual clusters Extensions: Add hooks to support virtual clusters May 23, 2024
@nwmac nwmac force-pushed the add-virtual-cluster-hooks branch 3 times, most recently from 3225ac2 to 82fc100 Compare June 14, 2024 17:09
@nwmac
Copy link
Member Author

nwmac commented Jun 14, 2024

@mantis-toboggan-md finally got this to pass gates - refactored as we discussed.

@nwmac nwmac modified the milestones: v2.9.0, v2.10.0 Jun 27, 2024
@nwmac nwmac force-pushed the add-virtual-cluster-hooks branch from 82fc100 to 37c7477 Compare July 10, 2024 16:53
@nwmac nwmac force-pushed the add-virtual-cluster-hooks branch from 71c0394 to 29ec9b5 Compare August 13, 2024 15:35
@nwmac nwmac modified the milestones: v2.10.0, v2.11.0 Oct 22, 2024
@nwmac nwmac modified the milestones: v2.12.0, v2.11.0 Nov 1, 2024
@nwmac nwmac force-pushed the add-virtual-cluster-hooks branch from 29ec9b5 to 06756d1 Compare January 22, 2025 13:39
@nwmac nwmac requested review from aalves08 and richard-cox January 24, 2025 11:07
Copy link
Member

@aalves08 aalves08 left a comment

Choose a reason for hiding this comment

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

Reviewing this, changes seem pretty self self-contained as it's targeting the provisioning.cattle.io.cluster. I assume that since this is experimental, we don't want to document it right now, but in the future, if we open it, we need to add it to the documentation.

One last remark would be around using modelExtensions instead of extending/reusing uiConfig 🤔

nevertheless, I would say that it LGTM

Copy link
Member

@richard-cox richard-cox left a comment

Choose a reason for hiding this comment

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

Haven't given this a functional test, just looked at code.

Only minor comments. We are limiting model extensions to be singular though. Not sure we'll ever be in a scenario where different extensions might want to update things like deployment actions?

shell/core/types-provisioning.ts Outdated Show resolved Hide resolved
shell/core/types.ts Outdated Show resolved Hide resolved
shell/list/provisioning.cattle.io.cluster.vue Outdated Show resolved Hide resolved
@nwmac nwmac force-pushed the add-virtual-cluster-hooks branch from 8432344 to 1f0919e Compare January 27, 2025 16:40
@nwmac nwmac requested a review from richard-cox January 27, 2025 18:01
Copy link
Member

@mantis-toboggan-md mantis-toboggan-md left a comment

Choose a reason for hiding this comment

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

LGTM - I tested this by running code against the virtual clusters ui poc

@nwmac nwmac merged commit 8001967 into rancher:master Jan 31, 2025
32 checks passed
@nwmac nwmac deleted the add-virtual-cluster-hooks branch January 31, 2025 08:52
izaac pushed a commit to izaac/dashboard that referenced this pull request Feb 3, 2025
* Add hooks to support virtual clusters

* Fix lint issues

* Refinements

* Update for Vue 3 changes

* Fix import

* Minor tweaks

* Fix bug causing e2e tests to fail

* Fix lint issue

* Rename internal properties and ensure they don't break clone/save

* Ensure we generate types for the plugins package to give us access to mapDriver

* Simpler approach

* Fix lint issues and add type

* Remove unused code

* Revery unnecessary changes

* Bug fix for finding model extension

* Factor out string constant and add provider display method

* Add experimental to API

* Update typegen.sh to use SHELL_DIR var

* Move type def

* Fix lint issue

* Address PR feedback

* Update steve-class.js so we always get an array

* Fix type definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow clusters list to group clusters based on parent cluster
4 participants