fix: handle missing ate.dev CRDs gracefully in substrate status endpoint#2074
fix: handle missing ate.dev CRDs gracefully in substrate status endpoint#2074AruneshDwivedi wants to merge 2 commits into
Conversation
When the ate.dev CRDs (WorkerPool, ActorTemplate) are not installed on the cluster, the substrate status endpoint returned HTTP 500 due to an unhandled *meta.NoKindMatchError from the KubeClient.List calls. Now catches NoKindMatchError for both WorkerPool and ActorTemplate CRDs and returns empty lists instead, so the endpoint returns 200 with empty arrays when the CRDs are absent. Other errors still propagate normally.
There was a problem hiding this comment.
Pull request overview
Improves the substrate status HTTP endpoint so it no longer returns HTTP 500 when the ate.dev CRDs are absent, instead returning HTTP 200 with empty CRD-derived arrays.
Changes:
- Treat
meta.IsNoMatchErrorfromKubeClient.ListonWorkerPoolList/ActorTemplateListas “CRD missing” and continue with empty results. - Add a unit test covering the “missing CRDs” behavior using a stub client that returns
NoKindMatchError.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| go/core/internal/httpserver/handlers/substrate.go | Swallows “no match” list errors for substrate CRDs to avoid 500s when CRDs aren’t installed. |
| go/core/internal/httpserver/handlers/substrate_test.go | Adds a test validating the endpoint returns 200 and empty CRD arrays when CRDs are missing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if meta.IsNoMatchError(err) { | ||
| ctrllog.FromContext(ctx).Info("WorkerPool CRD not found, returning empty list", "namespace", namespace) | ||
| } else { | ||
| return nil, nil, err | ||
| } |
| if meta.IsNoMatchError(err) { | ||
| ctrllog.FromContext(ctx).Info("ActorTemplate CRD not found, returning empty list", "namespace", namespace) | ||
| } else { | ||
| return nil, nil, err | ||
| } |
|
Thanks so much for the contribution. Now that we've landed on substrate as our sandboxing mechanism I would like to revisit how we handle missing substrate dependencies and unify the approach across the whole app |
…olls Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
|
Good catch — changed both CRD-absence log lines from Info to V(1) so they don't spam normal logs when the endpoint is polled frequently. Available at verbose level for debugging. |
When the ate.dev CRDs (WorkerPool, ActorTemplate) are not installed on the cluster, the substrate status endpoint returned HTTP 500 due to an unhandled *meta.NoKindMatchError from the KubeClient.List calls.
Now catches NoKindMatchError for both WorkerPool and ActorTemplate CRDs and returns empty lists instead, so the endpoint returns 200 with empty arrays when the CRDs are absent. Other errors still propagate normally.
Added a test (TestHandleGetSubstrateStatus_MissingCRDs) that uses a fake client returning NoKindMatchError to verify the endpoint returns 200 with empty data.