-
Notifications
You must be signed in to change notification settings - Fork 19
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
add sriov token server chain element #249
add sriov token server chain element #249
Conversation
this attempts to provide basis for NSE to inject dedicated VF for every client connection. Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
47040c8
to
7eed26f
Compare
pkg/tools/tokens/tokens.go
Outdated
tokens[nameIDs[0]] = strings.Split(nameIDs[1], ",") | ||
} | ||
return tokens | ||
} | ||
|
||
// GetTokensFromEnv returns stored token ids from env for given tokenKey | ||
func GetTokensFromEnv(envs []string, tokenKey string) map[string][]string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it return map[string][]string
instead of just []string
?
Do we actually need this method instead of using FromEnv(envs)[tokenKey]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case of token server chain element, we should just retrieve tokens for only one token key and also to make compatible with tokenElement#tokens, I added this method. are you not liking it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. What do you think about doing like this: #249 (comment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
} | ||
|
||
func (s *tokenServer) Request(ctx context.Context, request *networkservice.NetworkServiceRequest) (*networkservice.Connection, error) { | ||
if mechanism := kernel.ToMechanism(request.GetConnection().GetMechanism()); mechanism != nil || mechanism.GetPCIAddress() == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that it would be better to check here for mechanism.Parameters[resourcepool.TokenIDKey] == ""
to prevent allocating new tokens on refresh Requests.
It looks like mechanism.GetPCIAddress() == ""
does the same, but probably checking for token ID would be more meaningful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, changed it to use token id check.
@pperiyasamy |
func NewServer(tokenKey string) networkservice.NetworkServiceServer { | ||
return &tokenServer{ | ||
tokenName: tokenKey, | ||
config: createTokenElement(tokens.GetTokensFromEnv(os.Environ(), tokenKey)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config: createTokenElement(tokens.GetTokensFromEnv(os.Environ(), tokenKey)), | |
config: createTokenElement(map[string][]string{ | |
tokenKey: tokens.FromEnv(os.Environ())[tokenKey], | |
}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: Periyasamy Palanisamy <periyasamy.palanisamy@est.tech>
yes @Bolodya1997 done for both client and server. |
@denis-tingaikin are we ok to merge this change ? |
LGTM |
…k-sriov@main PR link: networkservicemesh/sdk-sriov#249 Commit: cc4115c Author: Denis Tingaikin Date: 2021-08-31 18:06:40 +0300 Message: - Merge pull request #249 from Nordix/sriov-token-server-elem Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
…k-sriov@main PR link: networkservicemesh/sdk-sriov#249 Commit: cc4115c Author: Denis Tingaikin Date: 2021-08-31 18:06:40 +0300 Message: - Merge pull request #249 from Nordix/sriov-token-server-elem Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
Thanks @denis-tingaikin ! |
this attempts to provide basis for NSE to inject dedicated VF
for every client connection.
Fixes #246
Signed-off-by: Periyasamy Palanisamy periyasamy.palanisamy@est.tech