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

api: add PreferredAllocator interface #535

Merged
merged 1 commit into from
Dec 29, 2020
Merged

Conversation

uniemimu
Copy link
Contributor

@uniemimu uniemimu commented Dec 28, 2020

This adds a GetPreferredAllocator interface so that plugins can
optionally implement the API.

Signed-off-by: Ukri Niemimuukko ukri.niemimuukko@intel.com

@codecov-io
Copy link

codecov-io commented Dec 28, 2020

Codecov Report

Merging #535 (4c92093) into master (5d80f2d) will decrease coverage by 0.06%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #535      +/-   ##
==========================================
- Coverage   57.00%   56.93%   -0.07%     
==========================================
  Files          31       31              
  Lines        2114     2120       +6     
==========================================
+ Hits         1205     1207       +2     
- Misses        839      841       +2     
- Partials       70       72       +2     
Impacted Files Coverage Δ
pkg/deviceplugin/api.go 27.77% <ø> (ø)
pkg/deviceplugin/manager.go 79.59% <66.66%> (-3.02%) ⬇️
pkg/deviceplugin/server.go 82.97% <80.00%> (-1.08%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d80f2d...4c92093. Read the comment docs.

Copy link
Contributor

@rojkov rojkov left a comment

Choose a reason for hiding this comment

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

Overall looks good. With a couple of minor changes would be perfect.

pkg/deviceplugin/api.go Outdated Show resolved Hide resolved
Comment on lines 58 to 60
postAllocate func(*pluginapi.AllocateResponse) error
preStartContainer func(*pluginapi.PreStartContainerRequest) error
preferredAllocation func(*pluginapi.PreferredAllocationRequest) (*pluginapi.PreferredAllocationResponse, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

These closure declarations have become too lengthy. Let's declare new functional types postAllocateFunc, preStartContainerFunc and getPreferredAllocationFunc in this file and use them instead of func(...).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see c87b0b5

Copy link
Contributor

Choose a reason for hiding this comment

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

could you use the functional types in this file too?

Comment on lines 58 to 60
postAllocate func(*pluginapi.AllocateResponse) error
preStartContainer func(*pluginapi.PreStartContainerRequest) error
preferredAllocation func(*pluginapi.PreferredAllocationRequest) (*pluginapi.PreferredAllocationResponse, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

could you use the functional types in this file too?

@@ -22,6 +22,10 @@ import (
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
)

type postAllocateFunc func(*pluginapi.AllocateResponse) error
type preStartContainerFunc func(*pluginapi.PreStartContainerRequest) error
type preferredAllocationFunc func(*pluginapi.PreferredAllocationRequest) (*pluginapi.PreferredAllocationResponse, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to rename preferredAllocationFunc to getPreferredAllocationFunc for consistency.

Also all the other variables, parameters and struct fields preferredAllocation should be better renamed to become a verb to signal they contain a func, that is to getPreferedAllocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would not have preferred to prefix every preferred with get since not even the pluginapi gets it everywhere, but I get it, preferred or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree. The interface name doesn't need to be prefixed indeed. Could you please revert it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer I got the gets before preferred preferably right now

@uniemimu uniemimu requested a review from rojkov December 29, 2020 12:06
@uniemimu uniemimu changed the title api: add PreferredAllocator interface api: add GetPreferredAllocator interface Dec 29, 2020
This adds a PreferredAllocator interface so that plugins can
optionally implement the API.

Signed-off-by: Ukri Niemimuukko <ukri.niemimuukko@intel.com>
Copy link
Contributor

@rojkov rojkov left a comment

Choose a reason for hiding this comment

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

Thanks!

@rojkov rojkov changed the title api: add GetPreferredAllocator interface api: add PreferredAllocator interface Dec 29, 2020
Copy link
Member

@bart0sh bart0sh left a comment

Choose a reason for hiding this comment

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

/lgtm

@rojkov rojkov merged commit 231df24 into intel:master Dec 29, 2020
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.

None yet

5 participants