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

bugfix: Give kube-scheduler permission to update/patch pod status #611

Merged
merged 2 commits into from
Jun 28, 2019

Conversation

cofyc
Copy link
Contributor

@cofyc cofyc commented Jun 27, 2019

What problem does this PR solve?

kube-scheduler needs this permission to update/patch pod status. This is required to record pod schedule status in pod object.

The condition of v1.PodScheduled is used in scheduling queue to sort active pods: https://github.com/kubernetes/kubernetes/blob/v1.12.5/pkg/scheduler/core/scheduling_queue.go#L205-L227

// podTimeStamp returns pod's last schedule time or its creation time if the
// scheduler has never tried scheduling it.
func podTimestamp(pod *v1.Pod) *metav1.Time {
	_, condition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
	if condition == nil {
		return &pod.CreationTimestamp
	}
	if condition.LastProbeTime.IsZero() {
		return &condition.LastTransitionTime
	}
	return &condition.LastProbeTime
}


// activeQComp is the function used by the activeQ heap algorithm to sort pods.
// It sorts pods based on their priority. When priorities are equal, it uses
// podTimestamp.
func activeQComp(pod1, pod2 interface{}) bool {
	p1 := pod1.(*v1.Pod)
	p2 := pod2.(*v1.Pod)
	prio1 := util.GetPodPriority(p1)
	prio2 := util.GetPodPriority(p2)
	return (prio1 > prio2) || (prio1 == prio2 && podTimestamp(p1).Before(podTimestamp(p2)))
}

This permission is also in builtin scheduler cluster role. View full permission of builtin scheduler cluster role: kubectl get clusterrole system:kube-scheduler -o yaml.

What is changed and how does it work?

Check List

Code changes

  • Has Helm charts change

Does this PR introduce a user-facing change?:

Give tidb-scheduler (kube-scheduler) permission to update pod status. This fixes some scheduling issues.

@cofyc cofyc requested review from weekface, xiaojingchen and aylei June 27, 2019 06:41
@weekface
Copy link
Contributor

/run-e2e-tests

2 similar comments
@cofyc
Copy link
Contributor Author

cofyc commented Jun 27, 2019

/run-e2e-tests

@gregwebs
Copy link
Contributor

/run-e2e-tests

Copy link
Contributor

@aylei aylei left a comment

Choose a reason for hiding this comment

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

LGTM

@cofyc
Copy link
Contributor Author

cofyc commented Jun 28, 2019

/run-e2e-tests

@cofyc cofyc merged commit 6533a04 into pingcap:master Jun 28, 2019
yahonda pushed a commit that referenced this pull request Dec 27, 2021
Signed-off-by: Ran <huangran@pingcap.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants