Skip to content

frontend: src: Use kind and apiVersion for Link component routing#4409

Open
dibyanshu-pal-kushwaha wants to merge 2 commits intokubernetes-sigs:mainfrom
dibyanshu-pal-kushwaha:Correcting-Link-components-routes
Open

frontend: src: Use kind and apiVersion for Link component routing#4409
dibyanshu-pal-kushwaha wants to merge 2 commits intokubernetes-sigs:mainfrom
dibyanshu-pal-kushwaha:Correcting-Link-components-routes

Conversation

@dibyanshu-pal-kushwaha
Copy link

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha commented Jan 21, 2026

Summary

This PR fixes the incorrect routing of resources that share the same Kind name as core Kubernetes resources (but belong to different apiGroups), such as Knative Services.Currently in the codebase, any Non core service with kind Service navigates to the core Service details page instead of the dedicated Service page.So , This PR helps in correct routing.

Related Issue

Fixes #4267

Changes

  1. Link component: Updated the routing logic to check both kind and apiGroupName.
    2.Collision Detection: Added a check to verify if a resource's API group matches the "standard" core group before attempting to open the right-side details drawer.
    3.Routing: Ensures that non-standard resources (like Knative Services) bypass the standard drawer and correctly navigate to their specific full-page views.

Steps to Test

  1. Verify Core Resources: Navigate to Network > Services. Click on the kubernetes service.
    Expected: The right-side drawer should open normally.
  2. Verify colliding CRDs (Knative): Navigate to Custom Resources > services.serving.knative.dev. Click on a Knative Service link.
    Expected: You should be redirected to the Knative Service details page. The core Service drawer should not open.

Screenshots (After Fixing)

For Core Services :
Core

For Custom Services :
As you can see clearly , here I have created a fake Knative service to check and it is working positively , routing to the dedicated page rather than Core K8s services.
Custom

Notes for the Reviewer

  • The implementation is generic and does not hardcode "Knative". It will work for any CRD that happens to reuse a core Kind name .
  • This change specifically touches the Link component which is used throughout the dashboard, so it improves routing across all resource tables.

@k8s-ci-robot k8s-ci-robot requested review from skoeva and sniok January 21, 2026 05:00
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 21, 2026
@illume illume requested a review from Copilot January 21, 2026 11:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes routing issues for Custom Resource Definitions (CRDs) that share the same kind name as core Kubernetes resources, such as Knative Services. The solution adds collision detection logic to distinguish between standard and non-standard resources by comparing their API groups, ensuring that only resources matching the standard API group open in the detail drawer.

Changes:

  • Added collision detection in the Link component to compare API group names between custom resources and standard Kubernetes resources
  • Modified the drawer opening condition to prevent non-standard resources from incorrectly opening the standard resource drawer
  • Updated indentation for code consistency (with some minor formatting issues remaining)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dibyanshu-pal-kushwaha, kahirokunn
Once this PR has been reviewed and has the lgtm label, please assign joaquimrocha for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@kahirokunn
Copy link
Member

The matchesStandard check appears to be functioning correctly.

@kahirokunn
Copy link
Member

Did it function properly when you actually tested it manually? 👀

Copy link
Contributor

@skoeva skoeva left a comment

Choose a reason for hiding this comment

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

Hi! Would you mind addressing the copilot review comments and the linting failure in the CI?

@kahirokunn
Copy link
Member

After reviewing the source code, it appears that the comparison is likely being made solely based on the kind without checking the apiGroup. Could you explain why this resolved the issue? 🙏

frontend: src: Change apiVersion to apiGroup and fix linting error

frontend: src: Fix check using kind and apiGroup
@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the Correcting-Link-components-routes branch from 55c6198 to ad01d08 Compare January 24, 2026 15:49
@dibyanshu-pal-kushwaha
Copy link
Author

dibyanshu-pal-kushwaha commented Jan 24, 2026

@kahirokunn

After reviewing the source code, it appears that the comparison is likely being made solely based on the kind without checking the apiGroup. Could you explain why this resolved the issue?

Yes sir Sorry for the late reply , I currently applied the kind and apiGroup check for correct routing. I verified this locally on Minikube by creating a collision scenario . The Link component now correctly identifies it as a generic resource and routes to the generic page instead of the core Service drawer.Please review sir

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Thanks @dibyanshu-pal-kushwaha

It looks like the lint CI check is failing. Please check the commands locally? format, lint, tsc, and test

Can you please check the open review comments?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 1, 2026
@dibyanshu-pal-kushwaha
Copy link
Author

@kahirokunn @illume , I made the changes by you and copilot , please review it.

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Thank you. Looking pretty good now.

Just the commit message needs tidying up. Can you please squash it?

Also the first commit message body should be rewritten. It currently contains previously squashed subject lines in the commit body.

frontend: src: Use kind and apiGroup for Link component routing
frontend: src: Change apiVersion to apiGroup and fix linting error

frontend: src: Fix check using kind and apiGroup

@alokdangre
Copy link
Contributor

alokdangre commented Feb 1, 2026

Screen.Recording.2026-02-01.173408.mp4

@illume @dibyanshu-pal-kushwaha it did'nt worked as expected

@alokdangre
Copy link
Contributor

@dibyanshu-pal-kushwaha plzz test it locally and provide ss/sr

Copy link
Contributor

@alokdangre alokdangre left a comment

Choose a reason for hiding this comment

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

you can check if the object's class has the customResourceDefinition property. This property is typically present on dynamic classes created for erdbut absent on standard core classes

? props.kubeObject?.cluster
: props.activeCluster ?? getCluster() ?? '';

let matchesStandard = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

the matchesStandard check currently returns true for colliding crds because it compares the object's api group against its own constructor's apigroup,,, headlamp instantiates Custom Resources using dynamic classes that correctly match the crd api group, the check passes, and the standard drawer is still triggered.

@illume
Copy link
Contributor

illume commented Feb 1, 2026

Thanks for the review @alokdangre

@dibyanshu-pal-kushwaha
Copy link
Author

dibyanshu-pal-kushwaha commented Feb 1, 2026

@illume @dibyanshu-pal-kushwaha it did'nt worked as expected

@alokdangre , please go through the issue #4267 (You misunderstood this issue) as this states that currently in the codebase , when any non-core Kubernetes services with same kind Service is there and we click it over there it navigates to the core Service details page instead of the dedicated Service page. Your Screenshot shows correctly as it does not navigate to any core services.

I have already tested it locally ......

This is core service navigation->
Core

This is for Custom Service:

Custom

@dibyanshu-pal-kushwaha
Copy link
Author

@illume Sir it worked correctly, I think.

@alokdangre
Copy link
Contributor

alokdangre commented Feb 1, 2026

@dibyanshu-pal-kushwaha i think maybe i have misunderstood it, but the same ss is working in current version as well

@kahirokunn
Copy link
Member

kahirokunn commented Feb 1, 2026

You need to create a Custom Resource KubeObject like this:

class KService extends KubeObject<KServiceResource> {
  static kind = 'Service';
  static apiName = 'services';
  static apiVersion = 'serving.knative.dev/v1';
  static isNamespaced = true;
}

And to properly test this, You need to pass the retrieved object to the Link component as follows:

<Link kubeObject={knativeServiceObject} />

Currently, this navigates to the core Service resource (networking).

My issue would be resolved if the link navigates to the route defined for KService instead of the networking Service resource. If there is no route defined for KService, I believe it would be appropriate to navigate to the target resource page in the custom resources tab.

@illume
Copy link
Contributor

illume commented Feb 9, 2026

@dibyanshu-pal-kushwaha can you please reply to the last review comment?

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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link component routes Knative Service to core Service page when using kubeObject

6 participants