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

refactor coscheduling to use controller-runtime client #652

Conversation

Huang-Wei
Copy link
Contributor

@Huang-Wei Huang-Wei commented Oct 24, 2023

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

As #485 stated, we're migrating all plugins and controllers to use controller-runtime client. With the migration's completion, we should be able to eliminate all typed clients along with its generated bits.

This PR aims to migrate coscheduling.

Which issue(s) this PR fixes:

Part of #485

Special notes for your reviewer:

This PR also polished existing tests.

Does this PR introduce a user-facing change?

migrate coscheduling to use controller-runtime client 

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Oct 24, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Huang-Wei

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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 24, 2023
@netlify
Copy link

netlify bot commented Oct 24, 2023

Deploy Preview for kubernetes-sigs-scheduler-plugins canceled.

Name Link
🔨 Latest commit c0e0cbf
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-scheduler-plugins/deploys/653ff865df791e0009674693

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 24, 2023
@Huang-Wei
Copy link
Contributor Author

cc @denkensk @zwpaper for review.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 24, 2023
@PiotrProkop
Copy link
Contributor

LGTM will wait for @denkensk or @zwpaper to add proper lgtm label.

Copy link
Member

@zwpaper zwpaper left a comment

Choose a reason for hiding this comment

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

it also LGTM, only have a question

pg, err := pgMgr.pgLister.PodGroups(pod.Namespace).Get(pgName)
if err != nil {
var pg v1alpha1.PodGroup
if err := pgMgr.client.Get(context.Background(), types.NamespacedName{Namespace: pod.Namespace, Name: pgName}, &pg); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's basically the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to reuse context.

pg, err := pgMgr.pgLister.PodGroups(pod.Namespace).Get(pgName)
if err != nil {
var pg v1alpha1.PodGroup
if err := pgMgr.client.Get(context.Background(), types.NamespacedName{Namespace: pod.Namespace, Name: pgName}, &pg); err != nil {
Copy link
Contributor

@kerthcet kerthcet Oct 30, 2023

Choose a reason for hiding this comment

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

nit: can we unified to use context.TODO? Furthermore, maybe we can pass in the context

Copy link
Contributor Author

@Huang-Wei Huang-Wei Oct 30, 2023

Choose a reason for hiding this comment

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

yes and yes. Regarding "pass in the context", for some of the functions, we may want scheduler framework to provide a NewWithContext() signature to pass the context all the way down; otherwise, each scheduler framework consumer has to implement this NewWithContext() wrapper.

@Huang-Wei
Copy link
Contributor Author

@zwpaper @kerthcet I refactored a bit to pass in context in places where context obj is derivable. However for some places like Less(), it's still infeasible w/o changes in scheduler framework for now #652 (comment)

@kerthcet
Copy link
Contributor

LGTM.

@zwpaper
Copy link
Member

zwpaper commented Oct 31, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 31, 2023
@k8s-ci-robot k8s-ci-robot merged commit 40c0fee into kubernetes-sigs:master Oct 31, 2023
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants