Skip to content

KEP-5229: Implement API dispatcher #132523

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

macsko
Copy link
Member

@macsko macsko commented Jun 25, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR adds an APIDispatcher component that will be responsible for queueing and asynchronous execution of API calls during scheduling. This component could be then connected to scheduler's cache or used directly, if needed.

This PR focuses on adding the dispatcher. Further PRs will connect the dispatcher to scheduler and make use of it.

Customizability is achieved by using APICall interface that could be implemented in any way. apiCallRelevances passed to the dispatcher's constructor will allow to set any relevance hierarchy.

Which issue(s) this PR is related to:

Fixes: #132489
KEP: kubernetes/enhancements#5229

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

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


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. 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 Jun 25, 2025
@k8s-ci-robot
Copy link
Contributor

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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jun 25, 2025
@k8s-ci-robot k8s-ci-robot requested review from dom4ha and sttts June 25, 2025 07:53
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 25, 2025
@macsko macsko changed the title KEP-5229: Implement API dispatcher WIP: KEP-5229: Implement API dispatcher Jun 25, 2025
@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 Jun 25, 2025
@macsko
Copy link
Member Author

macsko commented Jun 25, 2025

/hold

@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 Jun 25, 2025
@macsko
Copy link
Member Author

macsko commented Jun 25, 2025

/cc @sanposhiho @dom4ha

This PR is not yet completed but the discussion could start.

@k8s-ci-robot k8s-ci-robot requested a review from sanposhiho June 25, 2025 07:55
@macsko macsko force-pushed the add_api_dispatcher branch from f9f67a7 to 31f084d Compare June 25, 2025 08:04
@lmktfy
Copy link

lmktfy commented Jun 26, 2025

Are we 100% sure this doesn't need a changelog entry? I think it's useful to changelog this PR in its own right.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 26, 2025
@macsko
Copy link
Member Author

macsko commented Jun 26, 2025

Are we 100% sure this doesn't need a changelog entry? I think it's useful to changelog this PR in its own right.

Yes, it needs an entry. I'll add it when the PR won't be WIP.

@macsko macsko force-pushed the add_api_dispatcher branch from 31f084d to f844906 Compare June 26, 2025 12:12
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 26, 2025
@macsko macsko force-pushed the add_api_dispatcher branch from f844906 to b1caf2d Compare June 26, 2025 12:16
@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Jun 26, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: macsko
Once this PR has been reviewed and has the lgtm label, please assign sttts for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2025
@macsko macsko force-pushed the add_api_dispatcher branch from b1caf2d to 153b9e8 Compare June 26, 2025 12:22
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jun 26, 2025
@macsko macsko force-pushed the add_api_dispatcher branch from 153b9e8 to 99fb477 Compare June 27, 2025 07:53
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 27, 2025
@macsko macsko changed the title WIP: KEP-5229: Implement API dispatcher KEP-5229: Implement API dispatcher Jun 27, 2025
@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 Jun 27, 2025
@macsko macsko force-pushed the add_api_dispatcher branch from 99fb477 to e524109 Compare June 27, 2025 08:39
Comment on lines +161 to +177
// removeFromQueue removes the objectUID from the queue and returns the recreated queue.
func removeFromQueue(queue *buffer.Ring[types.UID], objectUID types.UID) *buffer.Ring[types.UID] {
newQueue := buffer.NewRing[types.UID](buffer.RingOptions{
InitialSize: queue.Len(),
NormalSize: queue.Cap(),
})
for {
uid, ok := queue.ReadOne()
if !ok {
break
}
if uid != objectUID {
newQueue.WriteOne(uid)
}
}
return newQueue
}
Copy link
Member Author

Choose a reason for hiding this comment

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

The choice of data structure for the queue involves a trade-off based on these requirements:

  • Fast, FIFO-ordered inserts and pops.
  • Efficient removal of an occasional item from the middle of the queue.

We have a few options:

  1. Queue based on slice (buffer.Ring): Offers the best performance for standard FIFO operations. But, removing an element from the middle requires recreating (in buffer.Ring) or shifting (if we do our own) the underlying slice.
  2. Linked list ( container/list): Provides efficient deletion from the middle of the queue. But, standard push/pop operations have lower performance.
  3. Something other?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. 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. release-note-none Denotes a PR that doesn't merit a release note. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

KEP-5229: Implement async API Queue
3 participants