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 timeout/expire chain elements #1404

Merged
merged 2 commits into from
Dec 29, 2022

Conversation

glazychev-art
Copy link
Contributor

@glazychev-art glazychev-art commented Dec 23, 2022

Signed-off-by: Artem Glazychev artem.glazychev@xored.com

Description

Main changes:

  1. networkservice timeout: at the time of the call Close() on timeout, the token may already be expired. Therefore, we need to call Close() in advance - (tokenTimeout - requestTimeout)
  2. registry expire: since we now have tokens in the registry, we must follow the same logic as in the networkservice (see above). Expiration time selection has been extended. Now it is - min(peertoken.ExpirationTime, token.ExpirationTime, nse.ExpirationTIme) - registerTimeout.
  3. grpcmetadata.NewNetworkServiceEndpointRegistryClient - grpc.Header was added to Unregister() to process an updated path on the way back (like here - https://github.com/networkservicemesh/sdk/blob/main/pkg/registry/common/grpcmetadata/nse_client.go#L47-L48)
  4. registry authorize and updatepath were placed before begin, because in case of an event that triggers an eventFactory, we don't need to re-authorize.
  5. registry begin - when updating the context, we need to keep a copy of path, since we access it by reference (we should not be able to accidentally change it after begin)

Issue link

#1398

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 functionallity
  • Documentation
  • Refactoring
  • CI

@glazychev-art glazychev-art force-pushed the expiration branch 10 times, most recently from aed2dbe to dc57328 Compare December 26, 2022 09:28
@glazychev-art glazychev-art marked this pull request as ready for review December 26, 2022 09:55
@glazychev-art glazychev-art marked this pull request as draft December 26, 2022 13:03
@glazychev-art glazychev-art marked this pull request as ready for review December 26, 2022 13:19
Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
@glazychev-art glazychev-art marked this pull request as draft December 27, 2022 13:22
@glazychev-art glazychev-art marked this pull request as ready for review December 27, 2022 13:32
Comment on lines -541 to -544
if withNSEExpiration {
builder = builder.SetRegistryExpiryDuration(time.Second / 2)
}

Copy link
Member

Choose a reason for hiding this comment

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

Why do we change this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now rely mostly on the token rather than registryExpirationDuration. Therefore, below we create a token with the expiration we need.

Copy link
Member

Choose a reason for hiding this comment

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

Got it

@@ -32,35 +32,38 @@ import (
)

type expireNSEServer struct {
nseExpiration time.Duration
ctx context.Context
defaultNseExpiration time.Duration
Copy link
Member

Choose a reason for hiding this comment

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

Should we get rid of default expiration? Seems like the update path is going to always put the expiration time for nses after these changes.

Suggested change
defaultNseExpiration time.Duration

For unit tests, we can add injectexpirationtime chain element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally agree
But should we consider the situation where the user hasn't updatepath?

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
@denis-tingaikin denis-tingaikin merged commit d41eaac into networkservicemesh:main Dec 29, 2022
nsmbot pushed a commit to networkservicemesh/sdk-kernel that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-ipam-vl3 that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-admission-webhook-k8s that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-registry-proxy-dns that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-remote-vlan that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vfio that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-registry-memory that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-map-ip-k8s that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-cluster-info-k8s that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-k8s that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsc-init that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr-proxy that referenced this pull request Dec 29, 2022
…k@main

PR link: networkservicemesh/sdk#1404

Commit: d41eaac
Author: Artem Glazychev
Date: 2022-12-29 08:57:32 +0700
Message:
  - Fix timeout/expire chain elements (#1404)
* Fix timeout/expire chain elements

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>

* Remove default expiration for registry

Signed-off-by: Artem Glazychev <artem.glazychev@xored.com>
Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
zolug added a commit to Nordix/Meridio that referenced this pull request Jul 10, 2023
With networkservicemesh/sdk#1404
NSE expiration time is controlled by NSM's MaxTokenLifetime
parameter (defaults to 10 minutes).

Introduce a custom chain function to ensure LB/Proxy NSEs are
registered using 1 minute lifetime like before.
zolug added a commit to Nordix/Meridio that referenced this pull request Jul 10, 2023
With networkservicemesh/sdk#1404
NSE expiration time is controlled by NSM's MaxTokenLifetime
parameter (defaults to 10 minutes).

Introduce a custom chain function to ensure LB/Proxy NSEs are
registered using 1 minute lifetime like before.
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