Skip to content

Add CRD detection guard and unit tests for Agones views#12

Open
NAME-ASHWANIYADAV wants to merge 3 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:feat/crd-detection-guard
Open

Add CRD detection guard and unit tests for Agones views#12
NAME-ASHWANIYADAV wants to merge 3 commits into
agones-dev:mainfrom
NAME-ASHWANIYADAV:feat/crd-detection-guard

Conversation

@NAME-ASHWANIYADAV

Copy link
Copy Markdown
Contributor

Type of change

  • 🐛 Bug fix
  • 🚀 New feature / enhancement
  • 📖 Documentation
  • 🧹 Refactoring / cleanup
  • ⚙️ CI / tooling
  • ⚠️ Breaking change

What this PR does

This PR introduces a robust detection mechanism to verify if the Agones Custom Resource Definitions (CRDs) are installed on the active Kubernetes cluster before attempting to render Agones-specific UI views.

Key additions:

  • isAgonesInstalled utility: Queries the /apis/agones.dev/v1 endpoint and explicitly validates that the response is a valid Kubernetes APIResourceList.
  • useAgonesInstalled hook: A React hook to manage the asynchronous loading state.
  • AgonesInstallCheck wrapper component: Intercepts routes and is designed to display a helpful banner if the API is missing.
  • Route Wrapping: All Agones plugin routes in src/index.tsx are wrapped with this component.
  • Comprehensive Unit Tests: Vitest suite covers the API detection logic and hook completely. All tests pass successfully.

Screenshots / recordings

(I am currently facing a UI rendering issue locally. Attached are the screenshots showing minikube vs test-no-agones where the UI still renders the default view instead of the fallback banner).

image image

Test plan

Automated checks

  • npm ci
  • npm run build
  • npm run tsc
  • npm run lint
  • npm run format -- --check
  • npm run test

Manual verification

  • Tested in Headlamp against a cluster with Agones installed (minikube)
  • Verified on a cluster without Agones (test-no-agones)
    (See Notes for Reviewers regarding the local UI verification issue).

RBAC considerations

No additional RBAC permissions are required beyond what the plugin already needs.

Notes for reviewers

⚠️ Requesting some guidance on the UI rendering:
I have successfully implemented the logic, wrapped the components in index.tsx, and all automated unit tests pass perfectly.

However, when I test this locally on the Headlamp Desktop App (using my test-no-agones cluster), I am facing a weird issue: The isAgonesInstalled check should catch the missing API, but the UI still renders the default AgonesOverview component instead of my NotInstalledBanner (as seen in the second screenshot).

I suspect this might be related to how registerRoute handles wrapped components in Headlamp, or perhaps UI caching in the Desktop app (though I have cleared the .plugins cache).

I've opened this PR so you can review the code structure. Any pointers on why the route wrapper isn't displaying the fallback banner would be hugely appreciated!

Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
Signed-off-by: ashwani yadav <22ashwaniyadav@gmail.com>
@NAME-ASHWANIYADAV NAME-ASHWANIYADAV force-pushed the feat/crd-detection-guard branch from 13b713b to b33c7f0 Compare June 12, 2026 14:14
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.

1 participant