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

Fix racy bundle client tests #3575

Merged
merged 2 commits into from
Nov 4, 2022

Conversation

azdagron
Copy link
Member

@azdagron azdagron commented Nov 4, 2022

This change fixes test failures in the bundle client package. The failures were caused by non-goroutine safe manipulation of a map of configurations used as a config source and also an errant assertion that didn't account for production code behavior.

To fix the non-goroutine safe config source, a new type was introduced that protected the underlying config map with a RW mutex.

The errant assertion assumed that only one bundle refresh would be performed for a newly discovered trust domain. However, since the manual refresh operation ends up kicking off a goroutine that will also periodically refresh the bundle, under certain timing conditions, the bundle is refreshed twice. The assertion was updated to ensure that the bundle is updated at least once.

Fixes: #2840,#3401

This change fixes test failures in the bundle client package. The
failures were caused by non-goroutine safe manipulation of a map of
configurations used as a config source and also an errant assertion that
didn't account for production code behavior.

To fix the non-goroutine safe config source, a new type was introduced
that protected the underlying config map with a RW mutex.

The errant assertion assumed that only one bundle refresh would be
performed for a newly discovered trust domain. However, since the manual
refresh operation ends up kicking off a goroutine that will also
periodically refresh the bundle, under certain timing conditions, the
bundle is refreshed twice. The assertion was updated to ensure that the
bundle is updated at least once.

Fixes: spiffe#2840,spiffe#3401

Signed-off-by: Andrew Harding <aharding@vmware.com>
@azdagron azdagron added this to the 1.5.1 milestone Nov 4, 2022
Copy link
Collaborator

@MarcosDY MarcosDY left a comment

Choose a reason for hiding this comment

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

LGTM!!!

@azdagron azdagron merged commit d98577f into spiffe:main Nov 4, 2022
@azdagron azdagron deleted the fix-racy-bundle-client-tests branch November 4, 2022 22:28
stevend-uber pushed a commit to stevend-uber/spire that referenced this pull request Oct 16, 2023
This change fixes test failures in the bundle client package. The
failures were caused by non-goroutine safe manipulation of a map of
configurations used as a config source and also an errant assertion that
didn't account for production code behavior.

To fix the non-goroutine safe config source, a new type was introduced
that protected the underlying config map with a RW mutex.

The errant assertion assumed that only one bundle refresh would be
performed for a newly discovered trust domain. However, since the manual
refresh operation ends up kicking off a goroutine that will also
periodically refresh the bundle, under certain timing conditions, the
bundle is refreshed twice. The assertion was updated to ensure that the
bundle is updated at least once.

Fixes: spiffe#2840,spiffe#3401

Signed-off-by: Andrew Harding <aharding@vmware.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.

pkg/server/bundle/client.TestManagerOnDemandBundleRefresh flaky under race detector
2 participants