Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/share/manager/jsoncs3/jsoncs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,12 @@ func (m *Manager) initialize(ctx context.Context) error {
return nil
}

// Ready returns a channel that is closed once the background initialization
// goroutine has successfully connected to the metadata storage.
func (m *Manager) Ready() <-chan struct{} {
return m.ready
}

// waitForInit blocks until the background initialization goroutine has
// successfully completed, or until ctx is cancelled.
func (m *Manager) waitForInit(ctx context.Context) error {
Expand Down
8 changes: 7 additions & 1 deletion pkg/share/manager/jsoncs3/jsoncs3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,13 @@ var _ = Describe("CleanupStaleShares", func() {
m, err := jsoncs3.New(storage, nil, nil, 0, nil, 0)
Expect(err).ToNot(HaveOccurred())

ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
// New initializes the metadata storage in the background. Wait for that
// to finish, otherwise the context below can expire while the manager is
// still initializing and CleanupStaleShares reports that instead of the
// migration timeout.
Eventually(m.Ready(), 10*time.Second).Should(BeClosed())

ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()

err = m.CleanupStaleShares(ctx)
Expand Down