Repository navigation
fix(server): spread background jobs across workers; make the pool size configurable - #31
Conversation
…e configurable TaskManager.getAvailableWorker scanned the pool from the first worker and returned the first one with queue capacity. Each worker's queue holds 10 jobs, so every job landed on worker 1 and ran serially while the other workers stayed idle: eight parallel virtual-media inserts completed one after another, 1.2-1.9s apart, instead of concurrently. Start the scan from an atomic round-robin cursor so consecutive jobs go to different workers, and replace the hardcoded pool size of 4 with server.workers (KUBEVIRT_REDFISH_SERVER_WORKERS), default 8, range 1-64, zero meaning the default. The pool size is read once at startup. Signed-off-by: itayherzberg <itayherzberg@gmail.com>
|
Hi @itayherzberg. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
…ory, write tracker dropped Picks up bd12d08, the review revision of kubevirt#32. Conflicts were the adjacent hunks the rebase note in SCALEFIX-CHANGES.md describes: kept kubevirt#30/kubevirt#31's qps/burst/workers lines and their shared test helpers, dropped cache_enabled and the write tracker. # Conflicts: # config/config.yaml # helm/templates/secret.yaml # helm/values-example.yaml # helm/values.yaml # pkg/config/config.go # pkg/config/config_test.go # pkg/kubevirt/client.go
|
@MarSik Gentle ping on this when you have a chance! Let me know if you need any additional context |
|
/lgtm |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MarSik The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Problem
Background jobs (virtual-media insert/eject and the other async Redfish tasks) never run in parallel. Eight
InsertMediarequests sent at the same moment are processed one after another by a single worker while the other three sit idle, and the pool size (4) is hardcoded.Cause
TaskManager.getAvailableWorkerscans the pool from the first worker and returns the first one whose job channel has capacity. Each channel holds 10 jobs, so worker 1 always has room and receives every job; workers 2–4 never see one.Unit test added by this PR, run against current
main(4 workers, 8 picks):On a cluster (upstream
b40c637, OpenShift 4.22 / OpenShift Virtualization 4.22.12), 8InsertMediaPOSTs sent at once: all 8 jobs ran onWorker 1, completing one at a time 1.2–1.9 s apart; the batch took 10.3 s and the import pods finished 21–24 s after the POSTs.Fix
sync/atomiccounter, no new locking.server.workers(KUBEVIRT_REDFISH_SERVER_WORKERS) replaces the hardcoded 4: default 8, allowed 1–64, zero means default. Read once at startup;NewServerlogsTask manager started with N workers.server.workersvalue (default 8), rendered into the config when set.Behaviour change: the default pool grows from 4 to 8 workers. Each job is a short burst of Kubernetes API calls (create the PVC and the copy pod; the ISO copy itself runs inside that pod), so the pool size bounds how many inserts start at once, not how many ISOs copy at once.
Verification on the cluster
This branch, defaults, 8
InsertMediaPOSTs sent at once:8 distinct workers, jobs overlapping (workers 2, 3 and 4 started in the same millisecond). All 8 drives reported
Inserted: truewithin 20 s of the POSTs; ejecting all 8 in parallel returned 200 each,Inserted: falseon every drive, and no PVCs or pods were left behind.KUBEVIRT_REDFISH_SERVER_WORKERS=3→Started 3 workers/Task manager started with 3 workers.KUBEVIRT_REDFISH_SERVER_WORKERS=65→Failed to load configuration: … Invalid worker count (server.workers must be between 1 and 64, got 65).Tests
pkg/server/task_manager_test.go:TestGetAvailableWorkerRoundRobin(fails on currentmainas shown above, passes with the fix).pkg/config/config_test.go: default 8; value from the file and from the environment; out-of-range rejected; zero means default.go build ./...,go vet ./...,go test ./...,gofmt,go mod tidy(no change) andhelm lintpass.Related
One of four independent PRs from running many concurrent BMHs against kubevirt-redfish; each stands on its own and they can merge in any order: #30 (client-go rate limit), #32 (VM/VMI informer cache), #29 (shutdown hang). The three config PRs add the same two test helpers (
minimalConfig,writeConfig) topkg/config/config_test.go; whichever lands later drops its copy on rebase.