Skip to content

fix(apiserver): register OpenAPI v2 spec for aggregation#1803

Merged
praveenrewar merged 2 commits intocarvel-dev:developfrom
himsngh:fix-openapi-v2-logs
Apr 6, 2026
Merged

fix(apiserver): register OpenAPI v2 spec for aggregation#1803
praveenrewar merged 2 commits intocarvel-dev:developfrom
himsngh:fix-openapi-v2-logs

Conversation

@himsngh
Copy link
Copy Markdown
Contributor

@himsngh himsngh commented Mar 26, 2026

What this PR does / why we need it:

In Kubernetes v1.30+, the API Aggregation Controller inside the kube-apiserver is designed to synchronize discovery information for both OpenAPI v2 and v3 to ensure compatibility with all client types. Previously, kapp-controller only registered the OpenAPIV3Config for its aggregated API server (v1alpha1.data.packaging.carvel.dev).

Because the v2 spec was missing, the main kube-apiserver failed with a resource not found (404) error when attempting to fetch it during its aggregation sync loop. Consequently, the control plane logs were flooded with continuous retry errors (failed to download v1alpha1.data.packaging.carvel.dev: resource not found), even though functional package reconciliation was unaffected.

This PR registers the OpenAPI v2 configuration using genericapiserver.DefaultOpenAPIConfig to satisfy the K8s Aggregation Controller, successfully eliminating the 404 errors in the kube-apiserver logs.

Ref: https://kubernetes.io/docs/concepts/overview/kubernetes-api/#openapi-interface-definition:~:text=Kubernetes%20serves%20both%20OpenAPI%20v2.0%20and%20OpenAPI%20v3.0.

Which issue(s) this PR fixes:

Fixes #1703

Does this PR introduce a user-facing change?

Fixed an issue where kube-apiserver logs (v1.30+) were flooded with "resource not found" errors for the v1alpha1.data.packaging.carvel.dev OpenAPI spec. The kapp-controller aggregated API server now correctly registers and serves the OpenAPI v2 specification required by the Kubernetes aggregator.

Additional Notes for your reviewer:

Testing Done:

  • Spun up a fresh Minikube cluster (K8s v1.35+) and deployed kapp-controller built from this branch.

  • Verified that the APIService object v1alpha1.data.packaging.carvel.dev successfully reaches the Available: True state.

❯ kubectl get apiservices v1alpha1.data.packaging.carvel.dev ○ minikube
NAME SERVICE AVAILABLE AGE
v1alpha1.data.packaging.carvel.dev kapp-controller/packaging-api True 15m

  • Tailed kubectl logs -n kube-system -l component=kube-apiserver and verified the failed to download... resource not found error is completely resolved.

❯ kubectl logs -n kube-system -l component=kube-apiserver --since=5m | grep "failed to download v1alpha1.data.packaging.carvel.dev"

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:

N/A - This is a bug fix for API aggregation logging.

Copy link
Copy Markdown

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

Registers an OpenAPI v2 spec for kapp-controller’s aggregated API server so Kubernetes (v1.30+) API aggregation can successfully sync both OpenAPI v2 and v3 without spamming kube-apiserver logs with 404 retries.

Changes:

  • Adds serverConfig.OpenAPIConfig (OpenAPI v2) alongside the existing OpenAPIV3Config.
  • Sets OpenAPI v2 Info metadata (Title/Version) for the aggregated API server.

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

Comment thread pkg/apiserver/apiserver.go
Comment thread pkg/apiserver/apiserver.go
Copy link
Copy Markdown

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


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

himsngh added 2 commits April 3, 2026 16:27
Signed-off-by: Himanshu Singh <himansh.singh3@gmail.com>
…3 version

This commit addresses OpenAPI spec generation issues by ensuring both V2 and V3 configurations are instantiated before calling 'recommendedOptions.ApplyTo(serverConfig)'. This allows the authentication wiring to properly decorate the OpenAPI security definitions. Additionally, it explicitly sets the V3 spec 'Info.Version' to 'v1alpha1' to satisfy strict OpenAPI schema requirements.

Signed-off-by: Himanshu Singh <himansh.singh3@gmail.com>
@himsngh himsngh force-pushed the fix-openapi-v2-logs branch from b5aabc8 to 15ece02 Compare April 3, 2026 10:57
@praveenrewar praveenrewar merged commit 46eb34c into carvel-dev:develop Apr 6, 2026
12 of 13 checks passed
@github-project-automation github-project-automation Bot moved this to Closed in Carvel Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

kube-apiserver logs show error message: 'failed to download v1alpha1.data.packaging.carvel.dev: resource not found'

5 participants