kubernetes/kubernetes · error

<dynamic> error listing API services for group

Error message

<dynamic> error listing API services for group

What it means

This error comes from the kube-aggregator's /apis/<group> handler (handler_apis.go:144). After checking for a StatusError (which is written as a structured status object at line 140), the handler falls through to a generic error path if r.lister.List() returns a non-Status error, writing err.Error() as HTTP 500. This indicates a low-level failure in the APIService informer cache that is not a standard Kubernetes API status error.

Source

Thrown at staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_apis.go:144

// apiGroupHandler serves the `/apis/<group>` endpoint.
type apiGroupHandler struct {
	codecs    serializer.CodecFactory
	groupName string

	lister listers.APIServiceLister

	delegate http.Handler
}

func (r *apiGroupHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
	apiServices, err := r.lister.List(labels.Everything())
	if statusErr, ok := err.(*apierrors.StatusError); ok {
		responsewriters.WriteRawJSON(int(statusErr.Status().Code), statusErr.Status(), w)
		return
	}
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}

	apiServicesForGroup := []*apiregistrationv1api.APIService{}
	for _, apiService := range apiServices {
		if apiService.Spec.Group == r.groupName {
			apiServicesForGroup = append(apiServicesForGroup, apiService)
		}
	}

	if len(apiServicesForGroup) == 0 {
		r.delegate.ServeHTTP(w, req)
		return
	}

	discoveryGroup := convertToDiscoveryAPIGroup(apiServicesForGroup)
	if discoveryGroup == nil {
		http.Error(w, "", http.StatusNotFound)

View on GitHub (pinned to 94c1367642)

Solutions

  1. Check the API server logs for informer initialization errors around the time of the request
  2. Verify the informer factory has started and the APIService informer has synced before serving traffic
  3. Restart the API server / aggregator if the cache is persistently broken
  4. Review any custom changes to informer lifecycle management in the aggregator
Defensive patterns

Strategy: retry

Validate before calling

// Gate the apiGroupHandler on informer cache sync before serving:
func (r *apiGroupHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
    if !r.cacheSynced() {
        http.Error(w, "cache not synced", http.StatusServiceUnavailable)
        return
    }
    // ... existing handler logic
}

Prevention

When it happens

Trigger: An HTTP GET to /apis/<group> when the informer-backed APIService lister fails with a non-status error — e.g., the cache was never primed, the informer was stopped, or an internal data structure corruption occurred in the indexer.

Common situations: Race condition during API server startup where requests arrive before the informer cache syncs; informer factory shutdown during graceful termination; a bug in a custom informer wrapper causing unexpected error types from the underlying cache.

Related errors


AI-assisted analysis of kubernetes/kubernetes@94c1367642 (2026-08-08). Data as JSON: /api/errors/a0d843d1514a8de7. Report an issue: GitHub.