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

qfix: begin should correctly handle reselect #1485

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

denis-tingaikin
Copy link
Member

Description

Issue link

Fixes networkservicemesh/integration-k8s-kind#845

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

Signed-off-by: denis-tingaikin <denis.tingajkin@xored.com>
@codecov
Copy link

codecov bot commented Jul 8, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@7ec603e). Click here to learn what that means.
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1485   +/-   ##
=======================================
  Coverage        ?   70.38%           
=======================================
  Files           ?      248           
  Lines           ?    11197           
  Branches        ?        0           
=======================================
  Hits            ?     7881           
  Misses          ?     2815           
  Partials        ?      501           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

eventFactoryServer.request != nil && eventFactoryServer.request.Connection != nil {
log.FromContext(ctx).Info("Closing connection due to RESELECT_REQUESTED state")
_, closeErr := next.Server(withEventFactoryCtx).Close(withEventFactoryCtx, eventFactoryServer.request.Connection)
if closeErr != nil {
log.FromContext(ctx).Errorf("Can't close old connection: %v", closeErr)
} else {
request.GetConnection().State = networkservice.State_UP
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we should set State_UP after closing.
Maybe State_DOWN?

It may also be worth moving eventFactoryServer.state into else block. In this case we can left eventFactoryServer.state == established condition:

if eventFactoryServer.state == established && 
                request.GetConnection().GetState() == networkservice.State_RESELECT_REQUESTED &&
		eventFactoryServer.request != nil && eventFactoryServer.request.Connection != nil {
		log.FromContext(ctx).Info("Closing connection due to RESELECT_REQUESTED state")
		_, closeErr := next.Server(withEventFactoryCtx).Close(withEventFactoryCtx, eventFactoryServer.request.Connection)
		if closeErr != nil {
			log.FromContext(ctx).Errorf("Can't close old connection: %v", closeErr)
		} else {
			request.GetConnection().State = networkservice.State_DOWN
	                eventFactoryServer.state = closed
		}
	}

Copy link
Member Author

@denis-tingaikin denis-tingaikin Jul 10, 2023

Choose a reason for hiding this comment

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

  1. we may lost eventFactoryServer.state == established
  2. we don't need to request a networkservice with DOWN state if we closed previous connection

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