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

begin should let NSE unregister it self even if it doesn't have an event factory #1529

Closed
wants to merge 16 commits into from

Conversation

NikitaSkrynnik
Copy link
Contributor

Description

begin should let NSE unregister it self even if it doesn't have an event factory. Also change expire a bit to distinguish between events coming from begin and NSE.

Issue link

networkservicemesh/sdk-k8s#456

How Has This Been Tested?

  • Added unit testing to cover
  • Tested manually
  • Tested by integration testing
  • Have not tested

Types of changes

  • Bug fix
  • New functionality
  • Documentation
  • Refactoring
  • CI

@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

All modified lines are covered by tests ✅

❗ No coverage uploaded for pull request base (main@7ad780b). Click here to learn what that means.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1529   +/-   ##
=======================================
  Coverage        ?   66.99%           
=======================================
  Files           ?      259           
  Lines           ?    12357           
  Branches        ?        0           
=======================================
  Hits            ?     8279           
  Misses          ?     3557           
  Partials        ?      521           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Signed-off-by: Nikita Skrynnik <[email protected]>
Comment on lines +125 to +132
q.Lock()
_, err := next.NetworkServiceEndpointRegistryServer(ctx).Unregister(ctx, in)
q.eventCount--
if q.eventCount == 0 {
b.queueMap.Delete(id)
}
q.Unlock()
return &emptypb.Empty{}, err
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we hold the lock for the whole next.Unregister call?
I would think that we only need it for q.eventCount manipulations and b.queueMap.Delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, there is a reason for this. Next chain elements can manipulate some data and if we have several concurrent Unregister events it can lead to data races. We need mutex for the whole Unregister call to let only one event go further.

Copy link
Contributor

@d-uzlov d-uzlov Oct 20, 2023

Choose a reason for hiding this comment

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

Oh, I have just noticed that you don't use event factory here.
But now I have a different question: what will happen if we get Register call with the same ID as this Unregister call while Unregister is running under this mutex?

@NikitaSkrynnik
Copy link
Contributor Author

Fixed in another PR: #1542

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