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

Make daemon.NodeShouldRunDaemonPod function public #108485

Merged
merged 1 commit into from
Mar 15, 2022

Conversation

BigDarkClown
Copy link
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

This PR makes the NodeShouldRunDaemonPod function from k8s.io/kubernetes/pkg/controller/daemon public.

I want to use that function in Cluster Autoscaler repository to better handle daemonsets during scale-ups. Currently the component uses only the scheduler logic to handle daemonsets which can lead to incorrect scale-up decisions.

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 3, 2022
@k8s-ci-robot
Copy link
Contributor

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

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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 3, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @BigDarkClown. 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 sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 3, 2022
// summary. Returned booleans are:
// * shouldRun:
// Returns true when a daemonset should run on the node if a daemonset pod is not already
// running on that node.
// * shouldContinueRunning:
// Returns true when a daemonset should continue running on a node if a daemonset pod is already
// running on that node.
func (dsc *DaemonSetsController) nodeShouldRunDaemonPod(node *v1.Node, ds *apps.DaemonSet) (bool, bool) {
func NodeShouldRunDaemonPod(node *v1.Node, ds *apps.DaemonSet) (bool, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

if you intend to use this in cluster-autoscaler, can you consider moving it to https://github.com/kubernetes/kubernetes/tree/master/staging/src/k8s.io/component-helpers/apps?

It sounds look like the Predicates function should not be exported though. The test framework can be refactored to use NodeShouldRunDaemonPod directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is the intent of moving the code to make it more clear there is an external dependency to anyone modifying this code (do "staging" repos have some sort of deprecation policy for function changes)?
Or is it just to avoid the technical issues related to directly importing k/k? Cluster Autoscaler already relies on a lot of code in kubernetes/kubernetes/pkg (pkg/scheduler is the big one, but it brings in a lot of transitive dependencies and we also use various consts and helpers directly in CA codebase).

Copy link
Member

Choose a reason for hiding this comment

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

Right, I know autoscaler already embeds a lot of k/k code.

There is no explicit deprecation policy for the component-helpers code, but we are more cautious on the dependencies they have. And it's location will make people think twice before changing the function prototype.

Also, there are active efforts to move anything that pkg/scheduler/framework depends on to component-helpers.
So this location should benefit you in the long run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code in component-helpers can have dependencies only on k8s.io/apimachinery, k8s.io/api and k8s.io/client-go. The functions here have transitive dependencies on k8s.io/kubernetes, so I don't think we are able to do that without a more major refactor.

Regarding the Predicates function, I've removed its use from e2e framework and instead of that used NodeShouldRunDaemonPod. I'm hesitant though to make this function private, as there may be more external dependencies on it. I'd propose to do this in another PR at least, to avoid having to revert the whole change.

Copy link
Member

Choose a reason for hiding this comment

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

can you make Predicates unexported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, done.

@MaciekPytel
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 3, 2022
@BigDarkClown
Copy link
Contributor Author

/retest

@BigDarkClown
Copy link
Contributor Author

/test pull-kubernetes-integration

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 7, 2022
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 7, 2022
@BigDarkClown
Copy link
Contributor Author

/test pull-kubernetes-e2e-gce-ubuntu-containerd

@BigDarkClown
Copy link
Contributor Author

/test pull-kubernetes-integration

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 8, 2022
@BigDarkClown
Copy link
Contributor Author

/assign @janetkuo
/assign @andrewsykim

@BigDarkClown
Copy link
Contributor Author

/assign @soltysh

@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 Mar 8, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BigDarkClown, janetkuo

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 Mar 15, 2022
@pacoxu
Copy link
Member

pacoxu commented Mar 15, 2022

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 15, 2022
@k8s-ci-robot k8s-ci-robot merged commit 02b1ec5 into kubernetes:master Mar 15, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.24 milestone Mar 15, 2022
@wking
Copy link
Contributor

wking commented Apr 27, 2022

#109685 floats an API change (bool to error return values). Folks involved in this pull may have opinions about whether that change is useful, and if it is, how complicated they feel a post-vendor-bump pivot would be for their consuming code.

wking added a commit to wking/kubernetes that referenced this pull request Apr 30, 2022
The previous boolean responses exposed "if", but not "why not?".
Returning errors for "why not?" makes it easy for anyone surprised by
the decision to figure out where their expectations began diverging
from reality.

It is unfortunate that this landed after
kubernetes/kubernetes@b2e2fb8d89d4 (Make daemon.NodeShouldRunDaemonPod
function public, 2022-03-03, kubernetes#108485), but the
transition should be easy for callers, with:

  shouldNotRun, shouldNotContinueRunning := NodeShouldRunDaemonPod(node, ds)
  shouldRun := shouldNotRun == nil
  shouldContinueRunning := shouldNotContinueRunning == nil

as a drop-in replacement for:

  shouldRun, shouldNotContinueRunning := NodeShouldRunDaemonPod(node, ds)
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. area/e2e-test-framework Issues or PRs related to refactoring the kubernetes e2e test framework area/test 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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants