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

Pass InformerFactory/SharedLister instead of individual informers/listers in scheduler config logic #85150

Merged
merged 1 commit into from Nov 13, 2019

Conversation

ahg-g
Copy link
Member

@ahg-g ahg-g commented Nov 12, 2019

What type of PR is this?

/kind cleanup

What this PR does / why we need it:
We pass around a lot of parameters representing the various informers the scheduler uses, which makes the scheduler config logic quite messy. This PR replaces that with a two parameters: SharedInformerFactory and the scheduler's SharedLister.

The PR also removes the redundant ConfigFactoryArgs struct.

Which issue(s) this PR fixes:
Part of #72547

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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-priority Indicates a PR lacks a `priority/foo` label and requires one. 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 Nov 12, 2019
@ahg-g
Copy link
Member Author

ahg-g commented Nov 12, 2019

/cc @alculquicondor @ahmad-diaa

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 12, 2019
@ahg-g ahg-g changed the title Pass InformerFactory instead of individual informers in scheduler config logic Pass InformerFactory/SharedLister instead of individual informers/listers in scheduler config logic Nov 12, 2019
c.nodeLister,
c.podLister,
c.informerFactory.Core().V1().Nodes().Lister(),
c.informerFactory.Core().V1().Pods().Lister(),
Copy link
Member

Choose a reason for hiding this comment

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

c.podInformer.Lister()?

Copy link
Member

Choose a reason for hiding this comment

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

This seems to be the only place were we use pod informer (other than tests). Maybe we can just create it here, instead of cmd/kube-scheduler/app/options/options.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch.

It is used when registering the handlers in scheduler.go, this is what feeds the scheduler's cache.

@@ -651,3 +579,19 @@ func (b *binder) Bind(binding *v1.Binding) error {
klog.V(3).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name)
return b.Client.CoreV1().Pods(binding.Namespace).Bind(binding)
}

// GetPodDisruptionBudgetLister returns pdb lister from the given informer factory. Returns nil if PodDisruptionBudget feature is disabled.
func GetPodDisruptionBudgetLister(informerFactory informers.SharedInformerFactory) (pdbLister policylisters.PodDisruptionBudgetLister) {
Copy link
Member

Choose a reason for hiding this comment

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

prefer non-named return values.
And does it need to be exported?

Copy link
Member Author

Choose a reason for hiding this comment

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

this one does not, the other one does, so thought I would be consistent.

}

// GetCSINodeLister returns CSINode lister from the given informer factory. Returns nil if CSINodeInfo feature is disabled.
func GetCSINodeLister(informerFactory informers.SharedInformerFactory) (csiNodeLister storagelistersv1beta1.CSINodeLister) {
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@ahg-g ahg-g force-pushed the ahg-informer branch 3 times, most recently from 64be6b3 to 3f8ecb6 Compare November 12, 2019 20:27
PluginConfigProducerRegistry: pluginConfigProducerRegistry,
})
snapshot := nodeinfosnapshot.NewEmptySnapshot()
return &Configurator{
Copy link
Member

Choose a reason for hiding this comment

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

This is missing enableNonPreempting, but it's hard to see if there's anything else missing. Can you think of a way of avoiding this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unit tests is supposed to capture this if this is a parameter that is actually tested. It seems that we don't quite care about the actual parameters in this test file.

@alculquicondor
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 12, 2019
@alculquicondor
Copy link
Member

/test pull-kubernetes-integration

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2019
@alculquicondor
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 13, 2019
@ahg-g
Copy link
Member Author

ahg-g commented Nov 13, 2019

/milestone v1.17

@k8s-ci-robot k8s-ci-robot added this to the v1.17 milestone Nov 13, 2019
@k8s-ci-robot k8s-ci-robot merged commit e0c483b into kubernetes:master Nov 13, 2019
@ahg-g ahg-g deleted the ahg-informer branch January 10, 2020 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. 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.

None yet

3 participants