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

Task 2: Schedule DaemonSet Pods by default scheduler. #59862

Merged
merged 1 commit into from
Mar 11, 2018

Conversation

k82cn
Copy link
Member

@k82cn k82cn commented Feb 14, 2018

Signed-off-by: Da K. Ma klaus1982.cn@gmail.com

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
part of #59194
kubernetes/enhancements#548

Release note:

When ScheduleDaemonSetPods is enabled, the DaemonSet controller will delegate Pods scheduling to default scheduler.

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 14, 2018
@k82cn k82cn changed the title Task 3: Schedule DaemonSet Pods by default scheduler. WIP: Task 3: Schedule DaemonSet Pods by default scheduler. Feb 14, 2018
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 14, 2018
@k82cn
Copy link
Member Author

k82cn commented Feb 14, 2018

/cc @kow3ns @bsalamat

@k82cn
Copy link
Member Author

k82cn commented Feb 16, 2018

@bsalamat @kow3ns , would you help to review whether this solution is OK: in this PR, I just 'hack' nodeShouldRunDaemonPod to return 'correct' value, e.g. wantToRun==shouldSchedule==true. And I'd like to simply it to one return value when graduating to beta.

Copy link
Member

@bsalamat bsalamat left a comment

Choose a reason for hiding this comment

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

Thanks, @k82cn!
Your change looks correct to me and given that we want to keep the old behavior and enable the new behavior with a flag, your change is OK, but in the future when we remove the scheduling logic of the DS controller, we can refactor and simplify the logic.

// Predicates checks if a DaemonSet's pod can be scheduled on a node using GeneralPredicates
// and PodToleratesNodeTaints predicate
func Predicates(pod *v1.Pod, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
var predicateFails []algorithm.PredicateFailureReason
critical := utilfeature.DefaultFeatureGate.Enabled(features.ExperimentalCriticalPodAnnotation) && kubelettypes.IsCriticalPod(pod)

// If NoDaemonSetScheduler is enable, only check nodeSelector and nodeAffinity.
Copy link
Member

Choose a reason for hiding this comment

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

s/enable/enabled/

@@ -1327,11 +1342,48 @@ func NewPod(ds *extensions.DaemonSet, nodeName string) *v1.Pod {
return newPod
}

// nodeSelectPredicates are the predicates that used to select node candidates for DaemonSet
func nodeSelectPredicates(pod *v1.Pod, meta algorithm.PredicateMetadata, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest renaming to nodeSelectionPredicates.

@@ -1327,11 +1342,48 @@ func NewPod(ds *extensions.DaemonSet, nodeName string) *v1.Pod {
return newPod
}

// nodeSelectPredicates are the predicates that used to select node candidates for DaemonSet
Copy link
Member

Choose a reason for hiding this comment

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

Please change to:
nodeSelectionPredicates runs a set of predicates that select candidate nodes for the DaemonSet.


// If NoDaemonSetScheduler is enable, only check nodeSelector and nodeAffinity.
if utilfeature.DefaultFeatureGate.Enabled(features.NoDaemonSetScheduler) {
// EssentialPredicates includes PodFitsHost, PodFitsHostPorts and PodMatchNodeSelector
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to run PodFitsHostPorts and actually your function does not run it. Please remove it from the comment.

@janetkuo janetkuo self-assigned this Feb 23, 2018
@k82cn k82cn changed the title WIP: Task 3: Schedule DaemonSet Pods by default scheduler. Task 3: Schedule DaemonSet Pods by default scheduler. Feb 25, 2018
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 25, 2018
@janetkuo
Copy link
Member

Please add a release note.

Copy link
Member

@janetkuo janetkuo left a comment

Choose a reason for hiding this comment

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

Is #60163 planned to be solved in this PR? Never mind I saw you opened #60386

// Clearup hostname, default scheduler will handle it.
hostname = ""
podTemplate = template.DeepCopy()
podTemplate.Spec.Affinity = util.AppendDaemonSetPodNodeAffinity(
Copy link
Member

Choose a reason for hiding this comment

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

Please combine this and #59798 into one PR (ok to be separate commits)

Copy link
Member Author

Choose a reason for hiding this comment

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

sure; let me combine them :)

// Predicates checks if a DaemonSet's pod can be scheduled on a node using GeneralPredicates
// and PodToleratesNodeTaints predicate
func Predicates(pod *v1.Pod, nodeInfo *schedulercache.NodeInfo) (bool, []algorithm.PredicateFailureReason, error) {
var predicateFails []algorithm.PredicateFailureReason
critical := utilfeature.DefaultFeatureGate.Enabled(features.ExperimentalCriticalPodAnnotation) && kubelettypes.IsCriticalPod(pod)

// If NoDaemonSetScheduler is enabled, only check nodeSelector and nodeAffinity.
Copy link
Member

Choose a reason for hiding this comment

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

So we can't remove all predicates in DS controller even when switching to default scheduler?

Copy link
Member Author

Choose a reason for hiding this comment

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

As daemonset can use NodeAffinity and NodeSelector to define a subset of cluster to stat the Daemon Pods, we re-use those predicates.

The advantage is that we can choose which predicate we'd like to re-use according to DaemonSet's requirement instead of keep it align with default scheduler when a new feature introduced.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 28, 2018
@k82cn k82cn changed the title Task 3: Schedule DaemonSet Pods by default scheduler. Task 2: Schedule DaemonSet Pods by default scheduler. Feb 28, 2018
@k82cn k82cn changed the title Task 2: Schedule DaemonSet Pods by default scheduler. Task 3: Schedule DaemonSet Pods by default scheduler. Feb 28, 2018
@yastij
Copy link
Member

yastij commented Feb 28, 2018

@k82cn @bsalamat - is this one making it for 1.10 ?

@k82cn k82cn force-pushed the k8s_59194_3 branch 2 times, most recently from 8f13c7e to 3b9650b Compare February 28, 2018 12:20
@janetkuo
Copy link
Member

janetkuo commented Mar 8, 2018

/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, 2018
@janetkuo
Copy link
Member

janetkuo commented Mar 9, 2018

/assign @smarterclayton
Would you approve the change? Thanks!


if utilfeature.DefaultFeatureGate.Enabled(features.ScheduleDaemonSetPods) {
podTemplate = template.DeepCopy()
podTemplate.Spec.Affinity = util.ReplaceDaemonSetPodHostnameNodeAffinity(
Copy link
Contributor

Choose a reason for hiding this comment

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

will this deal with existing daemonset pods during migration? or the daemonset have to be recreated/rescaled?

Copy link
Member

Choose a reason for hiding this comment

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

This only affects Daemon pod creation. Existing pods won't be affected. Existing DaemonSet might be affected when, for example, their pods are killed/dead or new nodes are added.

@smarterclayton
Copy link
Contributor

Feature name approved

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: janetkuo, k82cn, smarterclayton

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 9, 2018
@janetkuo janetkuo added this to the v1.10 milestone Mar 9, 2018
@k82cn
Copy link
Member Author

k82cn commented Mar 10, 2018

/kind feature
/priority critial-urgent

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 10, 2018
@k82cn
Copy link
Member Author

k82cn commented Mar 10, 2018

/priority critical-urgent

@k8s-ci-robot k8s-ci-robot added the priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. label Mar 10, 2018
@k82cn
Copy link
Member Author

k82cn commented Mar 10, 2018

and ping for milestone approve :)

@k8s-github-robot
Copy link

[MILESTONENOTIFIER] Milestone Pull Request: Up-to-date for process

@janetkuo @k82cn @smarterclayton

Pull Request Labels
  • sig/apps sig/scheduling: Pull Request will be escalated to these SIGs if needed.
  • priority/critical-urgent: Never automatically move pull request out of a release milestone; continually escalate to contributor and SIG through all available channels.
  • kind/feature: New functionality.
Help

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

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/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. 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.

10 participants