-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Consolidate extended resources and hugepages in Scheduler #52137
Consolidate extended resources and hugepages in Scheduler #52137
Conversation
fyi @ConnorDoyle |
pkg/api/helper/helpers.go
Outdated
// default namespace, or it has the opaque integer resource prefix. | ||
func IsExtendedResourceName(name api.ResourceName) bool { | ||
// IsGenericResourceName returns true if the resource name is not in the | ||
// default namespace, or it has the opaque integer or hugepages resource prefix. |
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 don't like this refactoring.
Extended resources != Integer resources in the long run.
I suspect what you are looking for is IsIntegerResource
which I'd recommend composing
pkg/api/v1/helper/helpers.go
Outdated
@@ -29,11 +29,11 @@ import ( | |||
"k8s.io/kubernetes/pkg/api/helper" | |||
) | |||
|
|||
// IsExtendedResourceName returns true if the resource name is not in the | |||
// IsGenericResourceName returns true if the resource name is not in the |
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.
What is a generic resource? Instead have an integer resource list for first class resources and use that.
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.
+1, integer resource predicate can match all extended resources (for now) and the integral first-class resources including hugepages.
@ConnorDoyle was thinking about a more generic resource type that could possibly cover all the existing resource types and let us add new ones without the need to change scheduler's code. That's obviously a larger change and requires a design doc first. This PR is OK and fixes the duplication of code introduced when adding HugePages in the scheduler. The only issue is that I am not sure if "GenericResource" is a good name. |
I suggested this name, I am not married to the name, but I am not sure its worth a lot of investment to bikeshed around it versus remove the code duplication. Calling extended resources + native resources that require no special handling felt generic to me. |
+1 for avoiding code duplication. My only ask is to keep the separation between first class and extended resources explicit. It's OK to have an additional wrapper that helps avoid code duplication. |
Just to clarify which one is true: we do not want to combine HugePage with Extended resources? Or we want to combine Extended resources with HugePages but want to go with some other name than GenericResources? Or we want to combine Extended resources with HugePages but want to continue with the name Extended Resources? Because if the first one, that means, we would have to continue with HugePage field like this: https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/scheduler/schedulercache/node_info.go#L75 and I only see marginal improvements even w.r.t code duplication. |
As far as scheduler is concerned, I'd prefer combining |
I am wary of combining the concept of ExtendedResources with a subset of first-class resources in the code. This is mainly because Extended Resources are a documented concept and contributors who have read those docs will have trouble if they are conflated in the code. How about this plan of action (forgive if restating ground already covered):
In the future, more unification could be possible to moving some more of the first-class integral resources under the |
@ConnorDoyle SGTM |
@ConnorDoyle Currently IsIntegerResourceName includes standard integer resources and extended resources as shown here: https://github.com/kubernetes/kubernetes/blob/master/pkg/api/helper/helpers.go#L264 So just using IsIntegerResourceName could cause conflicts in Scheduler for resources (like Pods). So I am suggesting to add IsNonStandardIntegerResources as follows:
So that this way IsNonStandardIntegerResources could be used in Scheduler without causing any unintentional issues. |
OK. It seems weird to call hugepages "nonstandard" once they achieve GA but please don't block on this naming nit. |
Are you guys @bsalamat @derekwaynecarr @vishh ok with this? Or do we still want to go with other names(something like @bsalamat's suggestion of ScalarResources looks good too)? Let me know as I'd prefer to avoid further iterations on this? Or if I dont get any response, I'll go ahead with IsNonStandardIntegerResources. |
@aveshagarwal It is unfortunate that cluster objects (pods, configmaps, etc.) are called "resource" in K8s. If we plan to expand the concept and add other resources, like memory, to it in the future, I would suggest using |
ScalarResources or IntegerResources sounds better than NonStandardResources
personally.
…On Thu, Sep 14, 2017 at 11:04 AM, Bobby (Babak) Salamat < ***@***.***> wrote:
@aveshagarwal <https://github.com/aveshagarwal> It is unfortunate that
cluster objects (pods, configmaps, etc.) are called "resource" in K8s. If
we plan to expand the concept and add other resources, like memory, to it
in the future, I would suggest using ScalarResource. Otherwise,
NonStandardResource is fine for lack of a better name.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#52137 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGvIKOilVUN84vyYEDI_krpSfqby-82Eks5siWq5gaJpZM4PQlt->
.
|
10dcb74
to
a898673
Compare
I have updated this PR to consolidate extended and hugepages resources as scalar resources. PTAL. @sjenning @derekwaynecarr can you check the bug fix commit to make sure its correct? |
/test pull-kubernetes-e2e-gce-bazel |
/test pull-kubernetes-e2e-gce-bazel |
/test pull-kubernetes-e2e-gce-bazel |
/release-note-none This is only visible in scheduler, and is to avoid code duplication introduced due to separate handling of hugepages from extended resources. |
ExtendedResources map[v1.ResourceName]int64 | ||
HugePages map[v1.ResourceName]int64 | ||
AllowedPodNumber int | ||
// OIRs and HugePages |
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 would just write ScalarResources to cover other scalar resources we add in the future.
if r.ExtendedResources == nil { | ||
r.ExtendedResources = map[v1.ResourceName]int64{} | ||
func (r *Resource) SetScalar(name v1.ResourceName, quantity int64) { | ||
// Lazily allocate opaque integer or hugepages resource map. |
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.
Similarly, I would just say: // Lazily allocate scalar resource map.
pkg/api/helper/helpers.go
Outdated
@@ -265,6 +265,11 @@ func IsIntegerResourceName(str string) bool { | |||
return integerResources.Has(str) || IsExtendedResourceName(api.ResourceName(str)) | |||
} | |||
|
|||
// Extended and Hugepages resources |
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.
s/Hugepages/HugePage/
pkg/api/helper/helpers.go
Outdated
@@ -265,6 +265,11 @@ func IsIntegerResourceName(str string) bool { | |||
return integerResources.Has(str) || IsExtendedResourceName(api.ResourceName(str)) | |||
} | |||
|
|||
// Extended and Hugepages resources | |||
func IsScalarResourceName(name api.ResourceName) bool { |
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.
Do we need this function 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.
In my understanding, helper/helpers.go and v1/helper/helpers.go have been kept in sync previously, Isn't that case any more?
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.
They don't look exactly in sync, but if that's the convention, it is fine.
a898673
to
ae05a6d
Compare
@bsalamat updated PR, PTAL. |
/lgtm |
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.
/lgtm
/unassign |
@smarterclayton can you approve this? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ConnorDoyle, aveshagarwal, bsalamat, smarterclayton Associated issue: 51732 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
2 similar comments
/retest Review the full test history for this PR. |
/retest Review the full test history for this PR. |
Automatic merge from submit-queue (batch tested with PRs 51902, 52718, 52687, 52137, 52697). If you want to cherry-pick this change to another branch, please follow the instructions here.. |
Fixes #51732
@bsalamat @derekwaynecarr @sjenning @kubernetes/sig-scheduling-pr-reviews