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

DRAFT: Latest changes - Using Mutex #6

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

ChristianZaccaria
Copy link
Owner

@ChristianZaccaria ChristianZaccaria commented Jul 30, 2024

Tests are passing here.

There is need to use mutexes in production code as there is a real case of race conditions.

Case 1:
A number of Frameworks are not initially available, but eventually 3 CRDs are installed at the same time alongside a deployment of a component. The 3 running go routines will try at the same time to create a new enabledIntegrations set. Locks are essential in this case to avoid multiple creations of enabledIntegrations sets.

Case 2:
The first Framework to be processed is not available, which will start a go routine. The CRD might become available milliseconds later and attempt to create the enabledIntegrations set, while the second Framework being processed had already created the enabledIntegrations set.

return restMapping, nil
}

var defaultCheckAPIAvailable checkAPIAvailableFunc = func(mgr ctrl.Manager, gvk schema.GroupVersionKind) (bool, error) {

Choose a reason for hiding this comment

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

Nit: but let's make make the fun var to be descriptive.

Suggested change
var defaultCheckAPIAvailable checkAPIAvailableFunc = func(mgr ctrl.Manager, gvk schema.GroupVersionKind) (bool, error) {
var defaultCheckAPIAvailable fetchRestMapperFunc = func(mgr ctrl.Manager, gvk schema.GroupVersionKind) (bool, error) {

@ChristianZaccaria ChristianZaccaria changed the title DRAFT: Latest changes DRAFT: Latest changes - Using Mutex Aug 7, 2024
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.

2 participants