Skip to content

KUBEDR-7763: Don't panic if CanShareWork() is called on a closed workpool#442

Merged
dzaninovic merged 1 commit intov0.19.0.xfrom
KUBEDR-7763_David
Apr 17, 2026
Merged

KUBEDR-7763: Don't panic if CanShareWork() is called on a closed workpool#442
dzaninovic merged 1 commit intov0.19.0.xfrom
KUBEDR-7763_David

Conversation

@dzaninovic
Copy link
Copy Markdown
Collaborator

@dzaninovic dzaninovic commented Apr 17, 2026

Don't panic if CanShareWork() is called on a closed workpool
Log a warning instead.
Context passing is needed to make the log levels work.
I tested to make sure the log is printed in our mover log.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the internal/workshare worker pool to avoid panicking when AsyncGroup.CanShareWork() is called after the pool has been closed, and instead emits a warning log (requiring context to be passed into pool construction so logging can use the correct context-derived log level behavior).

Changes:

  • Change workshare.NewPool to accept a context.Context and store it on the pool.
  • Update AsyncGroup.CanShareWork() to return false (and warn) instead of panicking when the pool is closed.
  • Update snapshotfs call sites and workshare tests to pass context into NewPool, and adjust expectations for the new CanShareWork() behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
snapshot/snapshotfs/upload.go Passes ctx into workshare.NewPool when creating the uploader worker pool.
snapshot/snapshotfs/snapshot_tree_walker.go Passes ctx into workshare.NewPool for TreeWalker parallel traversal.
snapshot/snapshotfs/dir_rewriter.go Passes ctx into workshare.NewPool for directory rewriting work sharing.
internal/workshare/workshare_waitgroup.go Replaces CanShareWork() panic-on-closed with warning + false return.
internal/workshare/workshare_test.go Updates tests/benchmarks to use the new NewPool(ctx, n) signature and new CanShareWork() behavior.
internal/workshare/workshare_pool.go Adds context storage to Pool and updates NewPool signature accordingly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread snapshot/snapshotfs/snapshot_tree_walker.go
Comment thread snapshot/snapshotfs/dir_rewriter.go
Comment thread internal/workshare/workshare_pool.go
Comment thread snapshot/snapshotfs/upload.go
@dzaninovic dzaninovic requested a review from draghuram April 17, 2026 20:52
@dzaninovic dzaninovic marked this pull request as draft April 17, 2026 21:00
@dzaninovic
Copy link
Copy Markdown
Collaborator Author

Kopia linter did not like me passing context in a struct. I will fix that.

/home/davidz/cloudcasa/kopia/tools/.tools/golangci-lint-1.62.0/golangci-lint --timeout 1200s run 
internal/workshare/workshare_pool.go:25:2: found a struct that contains a context.Context field (containedctx)
	ctx       context.Context
	^

@dzaninovic
Copy link
Copy Markdown
Collaborator Author

We will fix the linter issue later.

@dzaninovic dzaninovic marked this pull request as ready for review April 17, 2026 21:22
@dzaninovic dzaninovic merged commit 8ec3a6f into v0.19.0.x Apr 17, 2026
6 of 8 checks passed
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.

3 participants