fix(lbc): apply pool member weight to load balancer#12
Open
vks-team wants to merge 1 commit into
Open
Conversation
Pool member weights set in LoadBalancerConfig (e.g. 80/20) were never applied to the VNGCloud load balancer; traffic stayed 50/50. Three causes in lbc_uc, all fixed: - checkIfPoolMemberExist ignored weight, so a weight-only change was never detected and UpdatePoolMembers was never called. Weight is now part of member equality (via effectiveWeight, which treats nil/<=1 as the default weight of 1 to avoid a reconcile loop). Identity-only matching moved to a new checkIfPoolMemberExistByAddress, used for de-duplication and delete "can-cover" checks. - Members were built with loadbalancerv2.NewMember, which hardcodes weight to 1. Replaced with buildMemberRequest, constructing the request struct directly with the member's weight (and backup) at all three call sites (deploy_pool create/update, delete_pool). - mergePoolMembers kept the current (cloud) member for in-spec members, discarding the desired weight. It now prefers the spec member. Adds unit tests covering weight-aware equality, identity matching, weight-change detection, and spec-weight preference in merge. Co-Authored-By: Claude <noreply@anthropic.com>
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.
Problem
Pool member weights set in
LoadBalancerConfig(e.g. 80/20) were never applied to the VNGCloud load balancer — the vLB and portal stayed 50/50.Root cause (3 bugs in
lbc_uc)checkIfPoolMemberExistignored weight — a weight-only change was never detected, soUpdatePoolMemberswas never called.NewMemberhardcodesWeight: 1— even when an update fired, equal weights were sent.mergePoolMemberskept the current (cloud) member for in-spec members, discarding the desired weight.Fix
effectiveWeight(treatsnil/<=0as the default1to avoid a reconcile loop). Identity-only matching moved to newcheckIfPoolMemberExistByAddress(used for de-dup and delete "can-cover" checks).buildMemberRequestconstructs the SDK member struct directly with the member's weight + backup, replacingNewMemberat all three call sites (deploy_poolcreate/update,delete_pool).mergePoolMembersnow prefers the spec member, carrying the desired weight.This mirrors the existing pattern already used in
glbc_uc.Tests
deploy_pool_weight_test.go: weight-aware equality, identity matching, weight-change detection, spec-weight preference.go test ./internal/usecase/lbc_uc/...passes.golangci-lintclean.Note:
nsg_uc,vglb_uc,pkg/utilstest failures exist on the base branch and are unrelated.🤖 Generated with Claude Code