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

Refactored pkg/scheduler/utils to podinfo and heap packages. #76990

Closed
wants to merge 3 commits into from

Conversation

hprateek43
Copy link
Contributor

@hprateek43 hprateek43 commented Apr 24, 2019

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.

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 24, 2019
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/kubelet sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 24, 2019
@k8s-ci-robot k8s-ci-robot requested review from andrewsykim, bowei and a team April 24, 2019 06:58
@hprateek43
Copy link
Contributor Author

@misterikkit Can you review this PR and let me know the changes ?

@hprateek43
Copy link
Contributor Author

@lavalamp @derekwaynecarr Can you review this request?

@lavalamp
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

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

drop this commit

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?

Copy link
Contributor Author

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

@@ -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=
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liggitt Dropped

Copy link

@misterikkit misterikkit left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 6, 2019
@hprateek43
Copy link
Contributor Author

@bowei @andrewsykim @bsalamat Can you review and approve this PR?

@hprateek43
Copy link
Contributor Author

@derekwaynecarr @vishh @dchen1107 @dashpole @sjenning Can one of you review this PR and give an approval ?

@derekwaynecarr
Copy link
Member

kubelet changes lgtm.

/approve
/lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deads2k, derekwaynecarr, hprateek43
To complete the pull request process, please assign ravisantoshgudimetla
You can assign the PR to them by writing /assign @ravisantoshgudimetla in a comment when ready.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@hprateek43
Copy link
Contributor Author

/assign @ravisantoshgudimetla

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package util
package channels
Copy link
Contributor

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.

Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Contributor

@draveness draveness Aug 12, 2019

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

Copy link
Member

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"
Copy link
Contributor

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"
Copy link
Contributor

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.

Copy link
Member

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"
Copy link
Contributor

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"
Copy link
Contributor

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

Copy link
Member

@alculquicondor alculquicondor left a 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 {
Copy link
Member

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"
Copy link
Member

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
Copy link
Member

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}
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Member

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

@hprateek43
Copy link
Contributor Author

@alculquicondor @draveness Can you suggest the right PR titles to split this PR?

@alculquicondor
Copy link
Member

Your call. If something is very off, I will request a change.

@alejandrox1
Copy link
Contributor

/remove-area e2e-test-framework
/remove-sig testing

@k8s-ci-robot k8s-ci-robot removed area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Sep 29, 2019
@neolit123
Copy link
Member

/remove-area kubeadm

@danwinship
Copy link
Contributor

/remove-sig network

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed sig/network Categorizes an issue or PR as relevant to SIG Network. labels Dec 12, 2019
@k8s-ci-robot
Copy link
Contributor

@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.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 11, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 10, 2020
@alculquicondor
Copy link
Member

/close
This is quite stale now.
Perhaps the pod utils can be moved to a new package once #90039 lands

@k8s-ci-robot
Copy link
Contributor

@alculquicondor: Closed this PR.

In response to this:

/close
This is quite stale now.
Perhaps the pod utils can be moved to a new package once #90039 lands

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/apiserver area/cloudprovider area/code-generation area/dependency Issues or PRs related to dependency changes area/kubectl area/kubelet area/release-eng Issues or PRs related to the Release Engineering subproject area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/auth Categorizes an issue or PR as relevant to SIG Auth. sig/cli Categorizes an issue or PR as relevant to SIG CLI. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[scheduler cleanup phase 2]: Rename pkg/scheduler/util to pkg/scheduler/internal/podinfo