-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Conversation
@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 The 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. |
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 Once the patch is verified, the new status will be reflected by the 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. |
// 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
/ok-to-test |
/retest |
/test pull-kubernetes-integration |
/test pull-kubernetes-e2e-gce-ubuntu-containerd |
/test pull-kubernetes-integration |
/assign @janetkuo |
/assign @soltysh |
/lgtm |
[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 |
/release-note-none |
#109685 floats an API change ( |
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)
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PR makes the
NodeShouldRunDaemonPod
function fromk8s.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