Handle OpenAPI spec fetch failures#57
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👀 |
| } | ||
|
|
||
| // Only fetch if spec has changed (generation mismatch) or env var changed | ||
| if apiProductObj.Status.OpenAPI != nil && apiProductObj.Generation == apiProductObj.Status.ObservedGeneration && apiProductObj.Status.OpenAPI.MaxSizeUsed == r.OpenAPISpecMaxSize { |
There was a problem hiding this comment.
With this check and the new changes, were introducing the same error being showed everytime becuase the check doesn't pass, the status won't update, the same with generation and openapi size, Does that make sense? The new status doesnt get reconciled to break the loop
There was a problem hiding this comment.
Makes perfect sense.
I'm going to step back and take a broader view of the issue.
There was a problem hiding this comment.
Created issue to address this #59
In the meantime, let's at least partially fix the issue where APIProduct status isn't reconciled when OpenAPI spec fetching fails.
… spec fetch failures as reconciliation errors Signed-off-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
… change Signed-off-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
a4f2081 to
29c419e
Compare
What
Fixed the issue where the APIProduct controller was reporting OpenAPI spec fetch failures as reconciliation errors
Why
When the controller fails to fetch the OpenAPI spec due to network errors (e.g., DNS lookup failures), it was returning a regular error which caused the reconciliation to fail and logged "Reconciler error" messages. This made it appear as a controller bug rather than a transient issue with the external resource.
Now, network errors and other fetch failures are gracefully handled and reported in the resource's status conditions instead, following Kubernetes best practices for reporting resource state.
How
Modified the
openAPIStatus()function inapiproduct_controller.goto returnOpenAPISpecErrfor all fetch failures instead of regular errors:RequestCreationFailedreasonFetchFailedreasonReadFailedreasonThe error details are reflected in the
OpenAPISpecReadystatus condition, and thestatus.openapifield contains an empty content.Verification
Prerequisites
make local-setupExpected: No "Reconciler error" entries related to OpenAPI fetch
kubectl get apiproduct test-apiproduct -n gamestore -o jsonpath='{.status.conditions[?(@.type=="OpenAPISpecReady")]}{"\n"}'Expected output:
{ "lastTransitionTime": "2026-05-18T20:36:23Z", "message": "failed to fetch OpenAPI spec from https://api2.example.com/spec.yaml: dial tcp: lookup api2.example.com on 10.96.0.10:53: server misbehaving", "reason": "FetchFailed", "status": "False", "type": "OpenAPISpecReady" }kubectl patch apiproduct -n gamestore test-apiproduct --type=merge -p '{"spec":{"documentation":{"openAPISpecURL":"https://petstore3.swagger.io/api/v3/openapi.json"}}}'Wait for reconciliation, then check:
Expected:
{ "message": "OpenAPI spec was successfully fetched", "reason": "SpecFetched", "status": "True", "type": "OpenAPISpecReady" }