Skip to content

feat: Load the SchedulerConfig from a configuration file/text and make it easier to add plugins #881

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 6 commits into
base: main
Choose a base branch
from

Conversation

shmuelk
Copy link
Contributor

@shmuelk shmuelk commented May 28, 2025

This PR adds the ability to:

  1. Define the SchedulerConfig to be used using yaml text either in-line as an argument or from a file
  2. Add additional plugins with the need to modify existing code.

This PR implements issue #839.

This PR adds a configuration of the form:

plugin_definitions:
- name: lowQueue
  plugin_name: low-queue
  parameters:
    threshold: 10
profile_picker:
  plugin:
    plugin_name: all-profiles
scheduler_profiles:
- name: default
  plugins:
  - reference: lowQueue
  - plugin:
      plugin_name: prefix-cache
      parameters:
        hash-block-size: 32
    weight: 50
  - plugin:
      plugin_name: max-score

The plugin_definitions section enables a plugin instance to be used in multiple SchedulerProfiles, its use is optional. It is an array and the fields of each element are:

  • name: provides a name by which the plugin instance can be referenced in the profile_picker and scheduler_profile sections.
  • plugin_name: names the plugin to instantiate.
  • parameters: passed unparsed to the named plugin's factory function when creating the instance.

The profile_picker section defines the ProfilePicker plugin to be used. Its fields are:

  • reference: names a plugin instance by the name it was given in the plugin_definitions section.
  • plugin: defines, in-line a plugin to instantiated. The plugin field has in turn the following sub-fields:
    • plugin_name: names the plugin to instantiate.
    • parameters: passed unparsed to the named plugin's factory function when creating the instance.
      Either the reference field or the plugin field should be specified.

The scheduler_profiles section defines the set of SchedulerProfiles that will be in the created SchedulerConfig. It is and array and each element has the following fields:

  • name: provides a name for the SchedulerProfile
  • plugins: The array of Plugins to be associated with this SchedulerProfile. Each element in this array has the following fields:
    • reference: names a plugin instance by the name it was given in the plugin_definitions section.
    • plugin: defines, in-line a plugin to instantiated. The plugin field has in turn the following sub-fields:
      • plugin_name: names the plugin to instantiate.
      • parameters: passed unparsed to the named plugin's factory function when creating the instance.
    • weight: the weight to be used if the plugin is a Scorer
      Either the reference field or the plugin field should be specified.

To enable the instantiation of plugins from the configuration file/text a singleton/static plugin registry was added. Each plugin was modified to add an init() function and a factory function. The init() function simply registers the plugin's factory function in the registry.

Copy link

netlify bot commented May 28, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 8582491
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/6837161eb97f3d0008cc74da
😎 Deploy Preview https://deploy-preview-881--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 28, 2025
@k8s-ci-robot k8s-ci-robot requested review from danehans and robscott May 28, 2025 11:50
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: shmuelk
Once this PR has been reviewed and has the lgtm label, please assign arangogutierrez 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 added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 28, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @shmuelk. Thanks for your PR.

I'm waiting for a kubernetes-sigs 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 28, 2025
@ahg-g
Copy link
Contributor

ahg-g commented May 30, 2025

/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 May 30, 2025
@k8s-ci-robot
Copy link
Contributor

@shmuelk: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-gateway-api-inference-extension-verify-main 8582491 link true /test pull-gateway-api-inference-extension-verify-main
pull-gateway-api-inference-extension-test-unit-main 8582491 link true /test pull-gateway-api-inference-extension-test-unit-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

"sigs.k8s.io/yaml"
)

type Config struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend to treat this similar to CRDs so that we version it, and also place this under https://github.com/kubernetes-sigs/gateway-api-inference-extension/tree/main/api/config

See examples:

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this need to be a generic config api for epp, we need to encapsulate the plugins configuration in its own struct so we can accommodate other parameters (most flags should move here basically)

}

// Load config either from supplied text or from a file
func LoadConfig(configText []byte, fileName string, log logr.Logger) (*Config, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Defining it similar to a CRD would allow us to use the decoder pkg from k8s, see this example: https://github.com/kubernetes-sigs/jobset/blob/a7a669590b3483715c193e0af53dbb5f4f066b03/pkg/config/config.go#L19

@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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 the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

3 participants