Skip to content

Inject pkg/apis/core/v1 ResourceName helpers through ResourceNameQualifier from cmd/kube-scheduler#101489

Closed
ingvagabund wants to merge 1 commit intokubernetes:masterfrom
ingvagabund:resource-name-qualifier
Closed

Inject pkg/apis/core/v1 ResourceName helpers through ResourceNameQualifier from cmd/kube-scheduler#101489
ingvagabund wants to merge 1 commit intokubernetes:masterfrom
ingvagabund:resource-name-qualifier

Conversation

@ingvagabund
Copy link
Copy Markdown
Contributor

@ingvagabund ingvagabund commented Apr 26, 2021

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Removes k8s.io/kubernetes/pkg/apis/core/v1/helper from pkg/scheduler code base.

TBD

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Part of #91782 effort

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@ingvagabund: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

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 do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 26, 2021
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@ingvagabund: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Details

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-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. labels Apr 26, 2021
@k8s-ci-robot k8s-ci-robot requested review from ahg-g and chendave April 26, 2021 16:19
@k8s-ci-robot k8s-ci-robot added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 26, 2021
@ingvagabund
Copy link
Copy Markdown
Contributor Author

/hold
DO-NOT-MERGE yet

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 26, 2021
@ingvagabund ingvagabund removed the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Apr 26, 2021
@ingvagabund ingvagabund force-pushed the resource-name-qualifier branch from 722541c to a55bd7e Compare April 27, 2021 10:18
@k8s-ci-robot k8s-ci-robot added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Apr 27, 2021
@ingvagabund ingvagabund force-pushed the resource-name-qualifier branch from a55bd7e to 1731fd1 Compare April 27, 2021 10:25
@k8s-ci-robot k8s-ci-robot added area/test sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Apr 27, 2021
@ingvagabund ingvagabund force-pushed the resource-name-qualifier branch from 1731fd1 to 84b6bf8 Compare April 27, 2021 11:37
@ingvagabund
Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-integration

@ahg-g
Copy link
Copy Markdown
Member

ahg-g commented Apr 30, 2021

can you squash the commits apart from the ones coming from other PRs?

@ingvagabund
Copy link
Copy Markdown
Contributor Author

/retest

@ingvagabund
Copy link
Copy Markdown
Contributor Author

can you squash the commits apart from the ones coming from other PRs?

I created separate commits to make easier to understand the changes. Though, if it's not needed, I can squash.


// ResourceNameQualifier abstracts helpers qualifying
// of what kind a resource name is.
type ResourceNameQualifier interface {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

-1

Why is this not in component-helpers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will leave this for discussion. I don't have a strong opinion about where it should be.

@ahg-g
Copy link
Copy Markdown
Member

ahg-g commented May 4, 2021

I am not sure I like this approach, creating an interface for logic that is static and injecting it around is an overkill.

Why can't we move those helper functions as is to component helpers pkg?

@ingvagabund
Copy link
Copy Markdown
Contributor Author

Why can't we move those helper functions as is to component helpers pkg?

I was not able to address @liggitt 's comment in #95553 (comment):

If we expose these externally, they will start getting used by out of tree components using versions
of the component-helpers library which will lag the API server. Those components will think they are
using identical logic to the API server, but will be missing additions made to the helper functions.
That will cause those components to consider some data invalid which the API server considers valid.
That seems like a problem we don't have today that this move would introduce.

…ifier from cmd/kube-scheduler

Removes k8s.io/kubernetes/pkg/apis/core/v1/helper from pkg/scheduler code base.
@ingvagabund ingvagabund force-pushed the resource-name-qualifier branch from 518b963 to ac1bb3e Compare May 4, 2021 07:46
@ingvagabund
Copy link
Copy Markdown
Contributor Author

/retest

@ahg-g
Copy link
Copy Markdown
Member

ahg-g commented May 4, 2021

So an external component that imports the scheduler code would need to define its own implementation of ResourceNameQualifier, right? If so, that doesn't sound like a good tradeoff either.

But in any case, even if we want to be able to inject this behavior just so we can cut the dependency, I think plumbing it this way throughout the code base is too much for a functionality that is static and not actually supposed to be swappable. I suggest we define a global variable under the scheduler's component-helpers pkg that is set/registered before scheduler startup, just like metrics registration.

@ingvagabund
Copy link
Copy Markdown
Contributor Author

So an external component that imports the scheduler code would need to define its own implementation of ResourceNameQualifier, right? If so, that doesn't sound like a good tradeoff either.

Any external component can still import the k/k resource name helpers. Though yeah, it's still an ugly hack.

But in any case, even if we want to be able to inject this behavior just so we can cut the dependency, I think plumbing it this way throughout the code base is too much for a functionality that is static and not actually supposed to be swappable. I suggest we define a global variable under the scheduler's component-helpers pkg that is set/registered before scheduler startup, just like metrics registration.

With a global variable one has no guarantee the variable will always get set. If the metrics do not get registered, no metrics get collected. If the global variable for the resource name helpers does not get registered, the scheduler will either panic or will not correctly classify scalar resources. Meaning the validation might produce different conclusions. Wiring the code this way is not so much about allowing to swap the implementation as about making the compiler complain and make anyone importing the scheduler framework bits to see what's missing and initialize the resource name helper.

@ahg-g
Copy link
Copy Markdown
Member

ahg-g commented May 11, 2021

Any external component can still import the k/k resource name helpers. Though yeah, it's still an ugly hack.

But that defeats the purpose of this refactoring.

With a global variable one has no guarantee the variable will always get set. If the metrics do not get registered, no metrics get collected. If the global variable for the resource name helpers does not get registered, the scheduler will either panic or will not correctly classify scalar resources. Meaning the validation might produce different conclusions.

Failing silently is bad, crashing is probably better. But I don't understand how we "will not correctly classify scalar resources." if the global variable is not set?

Wiring the code this way is not so much about allowing to swap the implementation as about making the compiler complain and make anyone importing the scheduler framework bits to see what's missing and initialize the resource name helper.

I get that it is not about swapping implementation, which in my opinion is the problematic part: abstracting something that doesn't really need to be abstracted.

I suggested setting up a global variable, I admit it may not necessarily be a better alternative, but the current proposal caused significant changes, the interface is being passed in many places with negative net benefit for the scheduler code base. It would be a lot less of an issue if it is limited to few places (like the framework and have it accessible via the framework handle).

Is the goal to cut dependencies for the whole scheduler pkg or mainly the framework plugins?

@ingvagabund
Copy link
Copy Markdown
Contributor Author

Failing silently is bad, crashing is probably better. But I don't understand how we "will not correctly classify scalar resources." if the global variable is not set?

That depends on the default behavior. If the global variable is nil, scalar resources might just get ignored. Though, I still prefer crashing.

Is the goal to cut dependencies for the whole scheduler pkg or mainly the framework plugins?

I'd like to do it for the whole scheduler pkg. So third party repositories can import more than just the plugins. One might take the entire pkg/scheduler and just replace the queue implementation.

I suggested setting up a global variable

I don't have a better solution right now. I will take this path for the moment and update the PR accordingly.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@ingvagabund: PR needs rebase.

Details

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 18, 2021
ravisantoshgudimetla added a commit to ravisantoshgudimetla/kubernetes that referenced this pull request Jun 22, 2021
kubernetes#60525 introduced
Balanced attached node volumes feature gate to include volume
count for prioritizing nodes. The reason for introducing this
flag was its usefulness in Red Hat OpenShift Online environment
which is not being used any more. So, removing the flag
as it helps in maintainability of the scheduler code base
as mentioned at kubernetes#101489 (comment)
@k8s-triage-robot
Copy link
Copy Markdown

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Aug 22, 2021
@k8s-triage-robot
Copy link
Copy Markdown

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Sep 21, 2021
@k8s-triage-robot
Copy link
Copy Markdown

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

@k8s-triage-robot: Closed this PR.

Details

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

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/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/kubelet area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

9 participants