Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v14] fix access request cache test race #44652

Merged
merged 1 commit into from
Jul 25, 2024
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
7 changes: 7 additions & 0 deletions lib/services/access_request_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ func (c *AccessRequestCache) getResourcesAndUpdateCurrent(ctx context.Context) e
c.rw.Lock()
defer c.rw.Unlock()
c.primaryCache = cache
close(c.initC)
return nil
}

Expand Down Expand Up @@ -394,6 +395,12 @@ func (c *AccessRequestCache) initializationChan() <-chan struct{} {
return c.initC
}

// InitializationChan is part of the resourceCollector interface and gets the channel
// used to signal that the accessRequestCache has been initialized.
func (c *AccessRequestCache) InitializationChan() <-chan struct{} {
return c.initializationChan()
}

// Close terminates the background process that keeps the access request cache up to
// date, and terminates any inflight load operations.
func (c *AccessRequestCache) Close() error {
Expand Down
6 changes: 6 additions & 0 deletions lib/services/access_request_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ func newAccessRequestPack(t *testing.T) (accessRequestServices, *services.Access
})
require.NoError(t, err)

select {
case <-cache.InitializationChan():
case <-time.After(time.Second * 30):
require.FailNow(t, "timeout waiting for access request cache to initialize")
}

return svcs, cache
}

Expand Down
Loading