-
Notifications
You must be signed in to change notification settings - Fork 39.4k
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
Refactored pkg/scheduler/utils to podinfo and heap packages. #76990
Conversation
Hi @hprateek43. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@misterikkit Can you review this PR and let me know the changes ? |
@lavalamp @derekwaynecarr Can you review this request? |
You should get a scheduler-specific review, e.g. @bsalamat or @misterikkit. I'm not sure why the go.sum files all changed; also, the commits seem arranged sub-optimally (consider using fetch & rebase rather than merge?). |
go.mod
Outdated
@@ -157,6 +157,7 @@ require ( | |||
github.com/storageos/go-api v0.0.0-20180912212459-343b3eff91fc | |||
github.com/stretchr/testify v1.2.2 | |||
github.com/syndtr/gocapability v0.0.0-20160928074757-e7cb7fa329f4 // indirect | |||
github.com/tools/godep v0.0.0-20180126220526-ce0bfadeb516 // indirect |
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.
drop this commit
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.
Yeah, this shouldn't be included in the PR. Is the change needed at all?
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.
@misterikkit @liggitt Squashed and rebased. Dropped commits as per recommendation
staging/src/k8s.io/api/go.sum
Outdated
@@ -30,11 +30,14 @@ github.com/spf13/pflag v1.0.1 h1:aCvUg6QPl3ibpQUxyLkrEkCHtPqYJL4x9AuhqVqFis4= | |||
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= | |||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | |||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | |||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
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.
drop this commit as well
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.
@liggitt Dropped
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
@bowei @andrewsykim @bsalamat Can you review and approve this PR? |
@derekwaynecarr @vishh @dchen1107 @dashpole @sjenning Can one of you review this PR and give an approval ? |
kubelet changes lgtm. /approve |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deads2k, derekwaynecarr, hprateek43 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @ravisantoshgudimetla |
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package util | |||
package channels |
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.
channels
may not be a good name for package, channel
would be better as a package name 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.
I would be more generic and name it something like asyncwork
or parallelwork
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.
@draveness @alculquicondor What package name would your suggest to go with?
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 prefer errchannel.New
to channel.NewErrorChannel
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.
being more specific, as @draveness suggested, reads well too.
@@ -25,6 +25,7 @@ import ( | |||
"fmt" | |||
|
|||
"k8s.io/client-go/tools/cache" | |||
podinfo "k8s.io/kubernetes/pkg/scheduler/internal/podinfo" |
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.
does goimports add this automatically or it's a typo.
@@ -28,7 +28,7 @@ import ( | |||
"k8s.io/klog" | |||
"k8s.io/kubernetes/pkg/scheduler/apis/config" | |||
"k8s.io/kubernetes/pkg/scheduler/internal/cache" | |||
schedutil "k8s.io/kubernetes/pkg/scheduler/util" | |||
channels "k8s.io/kubernetes/pkg/scheduler/internal/channels" |
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 think goimports only add alias when the package name is v1
, it's the first time I saw this and looks weird.
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, that's also my understanding. Please remove this unnecessary alias.
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/util/workqueue" | ||
"k8s.io/kubernetes/pkg/scheduler/algorithm" | ||
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates" | ||
priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util" | ||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/api" | ||
schedutil "k8s.io/kubernetes/pkg/scheduler/internal/channels" |
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 do you think of keeping the original name of the package? rename it to schedutil
does not sound like a good idea.
@@ -22,17 +22,19 @@ import ( | |||
"math" | |||
"sync" | |||
|
|||
"k8s.io/kubernetes/pkg/scheduler/internal/channels" |
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.
This should be grouped with imports in L29-L37
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.
My general feeling is that this PR can be broken up into at least 2.
For example:
PR1: move Get*(v1.Pod)
into a new podinfo package
PR2: move heap into its own package
PR3: move SortableList into its own package.
arguably, heap and sortable list can live in the same package named. Arguably, heap and sortable list could be in the same package named "datastructures" or "containers".
@@ -91,6 +90,16 @@ func init() { | |||
signalToResource[evictionapi.SignalPIDAvailable] = resourcePids | |||
} | |||
|
|||
func getPodPriority(pod *v1.Pod) int32 { |
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.
@hprateek43 I would suggest that you open a PR just for moving this function to pkg/api/pod/util.go
prior to merging this. Another alternative could be pkg/apis/scheduling/helpers.go
, depending on which one introduces less risk of circular dependencies.
@@ -18,17 +18,16 @@ package priorities | |||
|
|||
import ( | |||
"context" | |||
"k8s.io/kubernetes/pkg/scheduler/internal/channels" |
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.
move to next import block
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |||
limitations under the License. | |||
*/ | |||
|
|||
package util | |||
package channels |
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 be more generic and name it something like asyncwork
or parallelwork
@@ -198,7 +198,7 @@ func (f *FakeExtender) selectVictimsOnNodeByExtender( | |||
// and get cached node info by given node name. | |||
nodeInfoCopy := f.cachedNodeNameToInfo[node.GetName()].Clone() | |||
|
|||
potentialVictims := util.SortableList{CompFunc: util.MoreImportantPod} | |||
potentialVictims := podinfo.SortableList{CompFunc: podinfo.MoreImportantPod} |
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.
It feels like SortableList shouldn't belong to the podinfo package.
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.
@alculquicondor Can you suggest a package to move it into?
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 about internal/collections
or more specific internal/sortablelist
@alculquicondor @draveness Can you suggest the right PR titles to split this PR? |
Your call. If something is very off, I will request a change. |
/remove-area e2e-test-framework |
/remove-area kubeadm |
/remove-sig network |
@hprateek43: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/close |
@alculquicondor: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What type of PR is this?
kind cleanup
What this PR does / why we need it:
#71863 is an active open request for scheduler cleanup. I have picked up that request and moved the generic util package into more meaningful internal packages podinfo and heap. Necessary changes in the scheduler and kubelet eviction packages have been made to support those changes.
Fixes #71863
Special notes for your reviewer:
The previous PR used schedulerinternalpodinfo as the package reference.The name was found to be too long by members in the previous thread and has been reduced to just podinfo. Let me know if we need any refactoring to rename this to something more meaningful. Also the package is in /pkg/scheduler/internal/podinfo and /pkg/scheduler/internal/heap, so the word internal in path can be a potential break. Comment if we can move them to more meaningful areas.