fix(raven): prevent stale gateway public Service/Endpoints on failover and multi-replica - #2762
Open
WorrierKhushal wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2762 +/- ##
==========================================
+ Coverage 46.20% 46.54% +0.34%
==========================================
Files 405 405
Lines 27540 27567 +27
==========================================
+ Hits 12724 12831 +107
+ Misses 13649 13573 -76
+ Partials 1167 1163 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…r, and Tunnel endpoint paths
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What type of PR is this?
/kind bug
What this PR does / why we need it:
The
GatewayPublicServicecontroller (pkg/yurtmanager/controller/raven/gatewaypublicservice/gateway_public_service_controller.go) derived Service/Endpoints object names only from(gatewayName, type), e.g.x-raven-proxy-svc-<gw>, while the classify logic (classifyService/classifyEndpoints) keyed objects by(nodeName, type). This mismatch meant:Createa Service for nodeB with the same name as the still-existing nodeA Service, hitAlreadyExists, and the code returnednilbefore the delete step for the stale nodeA object ever ran. The stale Service/Endpoints (pointing at the dead node) persisted forever, and reconcile kept reporting success.ProxyConfig.Replicas: 2(which the Gateway webhook explicitly allows for >=2 proxy endpoints), only the first endpoint's Service/Endpoints were ever created — the secondCreatehit the sameAlreadyExistsshort-circuit and was silently dropped.This PR:
NodeNamein the generated Service/Endpoints object names, so names uniquely match the classify key and no longer collide across nodes.AlreadyExistshandling inmanageServiceandmanageEndpointsto reconcile the object as an update instead of aborting the reconcile, so the delete step for genuinely stale objects still runs.TestReconcileService_TwoReplicasandTestReconcileService_Failoverto cover both previously-broken scenarios with deterministic assertions (replacing the olderr == nil-only check that passed even though only one endpoint was ever exposed).Verified locally with:
go test ./pkg/yurtmanager/controller/raven/gatewaypublicservice/... -v
go test -race ./pkg/yurtmanager/controller/raven/gatewaypublicservice/... -v
go vet ./pkg/yurtmanager/controller/raven/...
golangci-lint run -v ./pkg/yurtmanager/controller/raven/gatewaypublicservice/...
All clean — 0 test failures, 0 vet issues, 0 lint issues.
Which issue(s) this PR fixes:
Fixes #2760
Special notes for your reviewer:
/assign @zyjhtangtang
corev1.Endpointsis used throughout this controller (not introduced by this PR) and is flagged by staticcheck (SA1019) as deprecated in favor ofdiscoveryv1.EndpointSlice. Migrating to EndpointSlice is a much larger, separate refactor — this PR follows the existing repo convention of suppressing that specific warning with//nolint:staticcheck // SA1019: ..., matching the same directive already present in the production file and sibling test files in this package.FormatNameappends a random hash suffix to object names, so the new tests locate Services/Endpoints via theLabelCurrentGatewayEndpointslabel rather than predicting exact names.Does this PR introduce a user-facing change?
NONE
other Note
NONE