Skip to content

fix(gateway): circuit breaker should check if upstream exists before creating#326

Open
stefan-ctrl wants to merge 8 commits into
mainfrom
fix/gateway-circuitbreaker
Open

fix(gateway): circuit breaker should check if upstream exists before creating#326
stefan-ctrl wants to merge 8 commits into
mainfrom
fix/gateway-circuitbreaker

Conversation

@stefan-ctrl
Copy link
Copy Markdown
Member

@stefan-ctrl stefan-ctrl commented Apr 14, 2026

fix(gateway): circuit breaker should check if upstream exists before creating
refactor(gateway): circuit breaker requests have better logging by showing the path the caused the error

@stefan-ctrl stefan-ctrl marked this pull request as ready for review April 14, 2026 10:51
Copilot AI review requested due to automatic review settings April 14, 2026 10:51
@stefan-ctrl stefan-ctrl self-assigned this Apr 14, 2026
@stefan-ctrl stefan-ctrl added bug Something isn't working go Pull requests that update go code gateway Anything related to gateway domain labels Apr 14, 2026
Copy link
Copy Markdown
Contributor

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

This PR updates the Circuit Breaker feature’s Kong Admin API interaction so that upstream targets are upserted (idempotent reconciliation) rather than always created.

Changes:

  • Switch Circuit Breaker target management from CreateTargetForUpstreamWithResponse (POST) to UpsertTargetForUpstreamWithResponse (PUT).
  • Extend the KongAdminApi interface and regenerate the gomock client to include UpsertTargetForUpstreamWithResponse.
  • Update Circuit Breaker unit tests to mock/verify the new upsert target call.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
gateway/pkg/kong/client/mock/client.gen.go Adds the gomock method/recorder for UpsertTargetForUpstreamWithResponse.
gateway/pkg/kong/client/client.go Extends KongAdminApi interface with the new upsert-target method.
gateway/internal/features/feature/circuit_breaker.go Uses target upsert (PUT) and updates status-code/error handling for targets.
gateway/internal/features/feature/circuit_breaker_test.go Updates mocks/assertions for the new upsert-target call.

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

Comment thread gateway/internal/features/feature/circuit_breaker_test.go Outdated
@@ -155,25 +156,27 @@ var _ = Describe("CircuitBreakerFeature", func() {
}
mockKongAdminApi.EXPECT().UpsertUpstreamWithResponse(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(upsertUpstreamWithResponse_func).Times(1)
@stefan-ctrl stefan-ctrl changed the title fix(gateway): circuit breaker should upsert upstream fix(gateway): circuit breaker should check if upstream exists before creating Apr 15, 2026
Copy link
Copy Markdown
Contributor

@julius-malcovsky julius-malcovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread gateway/internal/features/feature/circuit_breaker.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gateway Anything related to gateway domain go Pull requests that update go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants