Skip to content

fix(lbc): apply pool member weight to load balancer#12

Open
vks-team wants to merge 1 commit into
mainfrom
worktree-fix-pool-member-weight
Open

fix(lbc): apply pool member weight to load balancer#12
vks-team wants to merge 1 commit into
mainfrom
worktree-fix-pool-member-weight

Conversation

@vks-team

Copy link
Copy Markdown
Contributor

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)

  1. checkIfPoolMemberExist ignored weight — a weight-only change was never detected, so UpdatePoolMembers was never called.
  2. NewMember hardcodes Weight: 1 — even when an update fired, equal weights were sent.
  3. mergePoolMembers kept the current (cloud) member for in-spec members, discarding the desired weight.

Fix

  • Weight is now part of member equality via effectiveWeight (treats nil/<=0 as the default 1 to avoid a reconcile loop). Identity-only matching moved to new checkIfPoolMemberExistByAddress (used for de-dup and delete "can-cover" checks).
  • New buildMemberRequest constructs the SDK member struct directly with the member's weight + backup, replacing NewMember at all three call sites (deploy_pool create/update, delete_pool).
  • mergePoolMembers now prefers the spec member, carrying the desired weight.

This mirrors the existing pattern already used in glbc_uc.

Tests

  • Added deploy_pool_weight_test.go: weight-aware equality, identity matching, weight-change detection, spec-weight preference.
  • go test ./internal/usecase/lbc_uc/... passes.
  • golangci-lint clean.

Note: nsg_uc, vglb_uc, pkg/utils test failures exist on the base branch and are unrelated.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants