Skip to content

Add load-aware primary node placement webhook for volume creation#330

Open
boddumanohar wants to merge 1 commit into
mainfrom
feature/primary-node-placement
Open

Add load-aware primary node placement webhook for volume creation#330
boddumanohar wants to merge 1 commit into
mainfrom
feature/primary-node-placement

Conversation

@boddumanohar

Copy link
Copy Markdown
Member

Summary

  • New PVC-mutating admission webhook (SimplyblockVolumePlacementInjector) that computes the least-loaded eligible storage node for a new volume's primary, reusing the same latency-deviation signal the auto-rebalancer (Automatic Rebalancing of Volumes (same Storage Cluster) #130) already computes, and stamps it onto the PVC as the simplyblock.io/host-id annotation — read by spdk-csi's CreateVolume path (zero spdk-csi changes needed).
  • Extends autobalancing.StorageNodeSelector with SelectBestNode, ranking eligible nodes by current latency deviation (no source-node/threshold gate, unlike migration-target selection).
  • Extends webapi.StorageNodeInfo with Lvols/LvolsMax (already returned by the backend, just not previously mapped) and IsSecondary (new backend field — see companion PR below) to filter out at-capacity and secondary nodes.
  • Fails open on every skip/error condition (feature not enabled for a cluster, backend/Prometheus unreachable, no eligible node) — falls back to sbcli's existing weighted-random placement exactly as it works today.
  • Full design: operator/docs/designs/design-primary-node-placement.md.

Dependency

Requires simplyblock/sbcli#1175 (exposes is_secondary on the v2 storage-nodes API) to be merged/deployed for the secondary-node filter to work; until then that filter defaults to false (fail-safe, not fail-open on that specific check) since the JSON field will simply be absent.

Test plan

  • go build ./... and go vet ./...
  • make test (includes envtest-based controller suite) — all packages pass
  • make lint (golangci-lint) — 0 issues
  • New unit tests for the webhook: skip conditions (annotation already set, no/invalid StorageClass, cluster not found, rebalancing disabled/misconfigured), full node-selection path against fake webapi + Prometheus servers (verifies eligibility filtering + coolest-node ranking), no-eligible-node fallback
  • make manifests / make operator-build-installer regenerated (webhook registration only; RBAC already covered by existing markers)

🤖 Generated with Claude Code

Adds a new PVC-mutating admission webhook that computes the least-loaded
eligible storage node using the same latency-deviation signal the
auto-rebalancer (#130) already uses, and stamps it onto the PVC as the
simplyblock.io/host-id annotation before spdk-csi's CreateVolume ever runs.
This replaces sbcli's volume-count-weighted random pick with a load-aware
decision when a cluster has latency benchmarking enabled, and degrades
silently to today's behavior otherwise — see
operator/docs/designs/design-primary-node-placement.md for the full design.

Co-Authored-By: Claude Sonnet 5 <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.

1 participant