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

Inject resources when sriovToken label exists in annotations field #21

Merged
merged 4 commits into from
Sep 23, 2021

Conversation

mardim91
Copy link
Contributor

Signed-off-by: Dimitrios Markou dimitrios.markou@est.tech

@mardim91
Copy link
Contributor Author

@edwarnicke can you please give me approval for the workflows to run ?
This PR is solving this issue : #17

Signed-off-by: Dimitrios Markou <dimitrios.markou@est.tech>
main.go Outdated
@@ -164,7 +167,38 @@ func (s *admissionWebhookServer) createVolumesPatch(p string, volumes []corev1.V
return jsonpatch.NewOperation("add", path.Join(p, "volumes"), volumes)
}

func parseInterfacePools(v string, logger *zap.SugaredLogger) map[string]int {

Choose a reason for hiding this comment

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

Probably this one would be better?

Suggested change
func parseInterfacePools(v string, logger *zap.SugaredLogger) map[string]int {
func parseSRIOVLabels(v string, logger *zap.SugaredLogger) map[string]int {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok I will fix that. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Bolodya1997
Copy link

@mardim91
Did you get a chance to test it in live? Doesn't device plugin mark device as free after the init container shutdown?

@mardim91
Copy link
Contributor Author

@mardim91
Did you get a chance to test it in live? Doesn't device plugin mark device as free after the init container shutdown?

@Bolodya1997 Yes I have tested it live. The initContainer terminates but device plugin doesn't mark the device as free because the devices are allocated per Pod and not per Container so everything works as it should be.

@Bolodya1997
Copy link

@denis-tingaikin
cc

Signed-off-by: Dimitrios Markou <dimitrios.markou@est.tech>
@edwarnicke
Copy link
Member

@mardim91
Did you get a chance to test it in live? Doesn't device plugin mark device as free after the init container shutdown?

@Bolodya1997 Yes I have tested it live. The initContainer terminates but device plugin doesn't mark the device as free because the devices are allocated per Pod and not per Container so everything works as it should be.

@mardim91 OK... that is both incredibly cool and unexpected :) Kudos to you for catching that :) Question though... is that the contract for DevicePlugin, or just how it happens to be implemented. I'm trying to understand whether we have a risk to manage around the behavior possibly changing in the future.

@edwarnicke
Copy link
Member

@denis-tingaikin Thoughts?

@mardim91
Copy link
Contributor Author

@mardim91
Did you get a chance to test it in live? Doesn't device plugin mark device as free after the init container shutdown?

@Bolodya1997 Yes I have tested it live. The initContainer terminates but device plugin doesn't mark the device as free because the devices are allocated per Pod and not per Container so everything works as it should be.

@mardim91 OK... that is both incredibly cool and unexpected :) Kudos to you for catching that :) Question though... is that the contract for DevicePlugin, or just how it happens to be implemented. I'm trying to understand whether we have a risk to manage around the behavior possibly changing in the future.

@edwarnicke I think is the contract and not how it happens to be implemented. I am saying that because before using nsm I have tested the same thing with SRIOVDevicePlugin and the behaviour was exactly the same.

u := (*nsurl.NSURL)(networkService)
labels := u.Labels()
if _, ok := labels["sriovToken"]; ok {
interfacePools := strings.Split(labels["sriovToken"], ",")
Copy link
Member

Choose a reason for hiding this comment

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

@Bolodya1997 Do we have a const for sriovToken?

Copy link
Contributor Author

@mardim91 mardim91 Sep 22, 2021

Choose a reason for hiding this comment

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

@denis-tingaikin we have this:

https://github.com/networkservicemesh/sdk-sriov/blob/main/pkg/networkservice/common/token/client.go#L41

but the constant starts with a lower case letter so it is not exported and golang doesn't allow to use it. So I did no change.

Copy link
Member

Choose a reason for hiding this comment

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

It sounds to me like the const should be exported to avoid hardcoded strings in other places.
@Bolodya1997 Thoughts?

Choose a reason for hiding this comment

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

It is actually mostly a contract than dependency, because the most common usage of this constant is manually using it in .yaml file - in such case there is no way to import it.
But it can be changed to exported to be used here as a dependency, probably it would be better to do such thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@denis-tingaikin @Bolodya1997 If there is no other objection maybe we can proceed with the merging of the PR as it is and when the variable gets exported correctly then we can change the "sriovToken" string in a later PR. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

@mardim91 I think it should be easy to export the constant from the package. Could you open the PR for sdk-sriov? We will consider it as soon as possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@denis-tingaikin I can do that yes. The only thing that I will do is upper case the vars

Copy link
Member

Choose a reason for hiding this comment

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

@mardim91 Finally I think it can be considered by separate PRs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@denis-tingaikin What do you mean it can be considered by separate PRs ? I didn't get that

main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@denis-tingaikin
Copy link
Member

Added some cosmetic comments, in general looks good.

Signed-off-by: Dimitrios Markou <dimitrios.markou@est.tech>
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
Signed-off-by: Dimitrios Markou <dimitrios.markou@est.tech>
@edwarnicke
Copy link
Member

@denis-tingaikin Has your feedback been responded to? Is this good to go?

@denis-tingaikin
Copy link
Member

@edwarnicke LGTM

@denis-tingaikin denis-tingaikin merged commit 33072e8 into networkservicemesh:main Sep 23, 2021
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.

4 participants