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

feat: add a dynamic, relation-driven sidebar #118

Conversation

ca-scribner
Copy link
Contributor

@ca-scribner ca-scribner commented Jun 27, 2023

Summary

This PR refactors how kubeflow dashboard's sidebar is implemented. Previously, the sidebar was defined statically in a configmap template. This PR removes the static definition, replacing it with links that are requested by other applications through a new sidebar relation. Full details are here.

Added here are:

  • lib/charms/kubeflow_dashboard/v1/kubeflow_dashboard_sidebar.py: Requirer and Provider side handler for the sidebar relation
  • tests/integration/sidebar_requirer_tester_charm: a mock charm that uses the Requirer side of the library. This is used in integration tests and can be used in manual testing
  • updated unit and integration tests for the sidebar

Notes for reviewer:

  • See this commit message/changes for a potentially controversial implementation that handles the sidebar when relations are broken.
  • To test, you can manually deploy the tester charm in tests/integration/sidebar_requirer_tester_charm (which is a simple implementation of the Requirer side of the relation) and relate it to the kubeflow-dashboard charm
  • Note that this PR targets a feature branch as it is a breaking change to our bundle that we don't want to roll out immediately

Out of scope (will be covered in separate PRs):

  • sidebar links defined through charm config
  • sidebar link ordering (current order is based on how juju assigns relation numbering)

Todo at merge

Closes #8

Adds:
* KubeflowDashboardSidebarRequirer
* KubeflowDashboardSidebarProvider
* SidebarItem
* associated tests
Used as a helper in unit tests
This change delays the computation of the k8s context until it is needed, instead of in __init__.  It does not change the outward function of the charm.

This change was implemented because in future, the sidebar links will be obtained from a relation and this should not be done in __init__.
previously, the Provider lib had a bug that would return only the last relation's data, not the entire set of data.  This fixes that bug.
This adds the feature to get_sidebar_items to, when executed during a relation-broken event for this relation, omit the relation data for the breaking app (the app leaving the relation).  For context, see https://chat.charmhub.io/charmhub/pl/

Possibly controversially, this feature uses the Juju environment variables to determine what event type is being executed.  This is to avoid having to pass the `BoundEvent` object to every `get_sidebar_items()` call, and to keep this hack entirely in the relation library so the charm does not need to know about it.
Previously, the links portion of the kubeflow dashboard configmap was incorrectly rendering only the menulinks, not all links.
@ca-scribner ca-scribner added the enhancement New feature or request label Jun 27, 2023
@ca-scribner ca-scribner requested a review from a team as a code owner June 27, 2023 15:31
metadata.yaml Outdated Show resolved Hide resolved
@i-chvets
Copy link
Contributor

Left some comments.LGTM otherwise.

@ca-scribner
Copy link
Contributor Author

Not sure what is wrong with the selenium integration tests. They might be failing because they're stuck on the profile creation page, but I don't know why this PR would have caused that. Need to look into that more

When refactoring the template, the links were changed by mistake.  This reverts those changes.
Previously, the lib was defined as v1, but the original v0 was never published so we have to re-use v0.
Copy link
Contributor

@i-chvets i-chvets left a comment

Choose a reason for hiding this comment

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

Approved.

@ca-scribner ca-scribner force-pushed the kf-3664-add-dynamic-sidebar-lib branch from ecacdd8 to e880538 Compare June 28, 2023 20:58
@ca-scribner ca-scribner merged commit 97d1929 into kf-3664-dynamic-sidebar-feature-branch Jun 28, 2023
@ca-scribner ca-scribner deleted the kf-3664-add-dynamic-sidebar-lib branch June 28, 2023 21:26
ca-scribner added a commit that referenced this pull request Jul 12, 2023
Changes include:
* adding KubeflowDashboardSidebarRequirer
* adding KubeflowDashboardSidebarProvider
* adding SidebarItem
* adding associated tests, including a Requires side tester for the new relation
* adding the sidebar relation and using the KubeflowDashboardSidebarProvider to manage it
* refactoring computation of k8s context until it is needed, instead of in `__init__`, to make testing easier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants