Skip to content

Move datasource/extractor validations to datalayer runtime.#2357

Open
elevran wants to merge 1 commit intokubernetes-sigs:mainfrom
elevran:add_extraction_validation
Open

Move datasource/extractor validations to datalayer runtime.#2357
elevran wants to merge 1 commit intokubernetes-sigs:mainfrom
elevran:add_extraction_validation

Conversation

@elevran
Copy link
Contributor

@elevran elevran commented Feb 17, 2026

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Following up on comments in #2228:

  • Extractors declare their expected input type (unchanged)
  • DataSource declare their output type and expected Extractor type (new)
  • Compatibility validation utility functions and tests in plugins/datalayer/source (new, moved)
  • Datalayer WithConfig() validates compatbility before calling AddExtractor (new)
  • DataSource can optionaly implement validating interface method to perform specific compatibility checks (new)
  • Current DataSource checks on AddExtractor and their tests are not changed to minimize the code changes.

Notes (relating to comments on #2228)

  • The metric names used in Produces() and other Plugin's Consumes() are already in the metrics Extractor under the framework.
  • Morphing Metrics (or MetadataState) as generic Attributes is not done (low impact, large changeset).

Which issue(s) this PR fixes:
Fixes #2234
Replaces #2336

Does this PR introduce a user-facing change?:

NONE

- Extractors declare their expected input type (unchanged)
- DataSource declare their output type and expected Extractor type (new)
- Compatibility validation utility functions and tests in plugins/datalayer/source (new, moved)
- Datalayer WithConfig() validates compatbility before calling AddExtractor (new)
- DataSource can optionaly implement validating interface method to perform specific compatibility checks (new)
- Current DataSource checks on AddExtractor and their tests are not changed to minimize the code changes.

Signed-off-by: Etai Lev Ran <elevran@gmail.com>
@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Feb 17, 2026
@netlify
Copy link

netlify bot commented Feb 17, 2026

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

Name Link
🔨 Latest commit 4b16fab
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/69944b91629d170008da2b1a
😎 Deploy Preview https://deploy-preview-2357--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 Feb 17, 2026
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

The full list of commands accepted by this bot can be found here.

Details 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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 17, 2026
@elevran elevran closed this Feb 17, 2026
@elevran elevran reopened this Feb 17, 2026
@k8s-ci-robot
Copy link
Contributor

@elevran: The following test 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-test-unit-main 4b16fab 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.

Details

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.


// ValidateInputTypeCompatible checks if the extractor's expected input type is
// compatible with the DataSource's output type.
func ValidateInputTypeCompatible(dataSourceOutput, extractorInput reflect.Type) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we expect that those validation checks will be run by anyone other than the runtime? Do we expect the plugins to execute them for example or llm-d main? If not, then this belongs more in the runtime pkg.

Copy link
Contributor Author

@elevran elevran Feb 17, 2026

Choose a reason for hiding this comment

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

if by runtime you mean pkg/epp/datalayer then it was moved here based on previous feedback (avoid framework from importing packages outside).
I prefer to leave it here to allow framework/*/source implementations to call these if needed.
datalayer.WithConfig() will only call these when working with configuration files (e.g., not in tests or when the datalayer is configured directly - not in code) so we leave it up open for failures in some cases.

Copy link
Contributor

@ahg-g ahg-g Feb 17, 2026

Choose a reason for hiding this comment

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

if by runtime you mean pkg/epp/datalayer then it was moved here based on previous feedback (avoid framework from importing packages outside).

Yes, but the main question was: do we expect any logic other than runtime to call it in the first place? if not, why make it part of the interface?

The initial implementation was expecting the plugins to invoke it, but then we discussed that this validation logic should be executed by the runtime (which processes the config and instantiates the plugins), the plugins themselves are not supposed to call it, and so this logic can live in the epp/datalayer as private functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See comments below on calling on addExtractor vs calling on ExtractNotification/Extract.
Let me know which approach you prefer

  • leave in framework and validate on adding an extractor (withConfig calling it is redundant in that case); or
  • validate on every extraction

Will change to whichever is preferred.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we only need to validate once, the runtime does that before calling AddExtractor (which I think we should remove as well, see the other comment)

// the data source output type.
func (dataSrc *HTTPDataSource) AddExtractor(extractor fwkdl.Extractor) error {
if err := datalayer.ValidateExtractorType(dataSrc.outputType, extractor.ExpectedInputType()); err != nil {
if err := source.ValidateInputTypeCompatible(dataSrc.OutputType(), extractor.ExpectedInputType()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we call it here still? the datalayer runtime calls it already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when dispatching to an extractor we can trust it to be of the right type (it was validated) or we need to verify the interface at runtime and fail if incompatible.

Copy link
Contributor

@ahg-g ahg-g Feb 17, 2026

Choose a reason for hiding this comment

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

I am not following, the epp/datalayer already calls this before it runs AddExtractor, why does the plugin itself has to do it again? The plugin already defined what it produces and what it expects, the runtime is the entity responsible for enforcement when setting things up.

I also think the source should not expose an AddExtractor interface, the runtime is the one that should maintain which extractors are configured for which source and invoke them, the runtime

  1. maintains the source <-> extractor mapping
  2. runs the iteration that we currently force all plugins to execute inside the Collect function to invoke Extract on each extractor. To enable this, the Collect interface changes to return the data, that the datalayer runtime pass that to the extract call when it iterates over the extractors.

Copy link
Contributor

Choose a reason for hiding this comment

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

The idea is to move all mechanical logic to be done by the runtime (validations, maintaining source<->extractor mapping as per the config, invoking the extractors on each collect etc.), the plugins are focused on implementing the plugin specific logic only.

return fmt.Errorf("extractor %s does not implement NotificationExtractor", ext.TypedName())
extractorType := reflect.TypeOf(ext)
expectedType := reflect.TypeOf((*fwkdl.NotificationExtractor)(nil)).Elem()
if err := source.ValidateExtractorCompatible(extractorType, expectedType); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we have to call it here still? The validation is done by the runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto.
Do we validate once on adding the extractor (regardless of if by config or not) or do we validate on every call to Extarct (and if there are multiple extractors, I presume we would want log a message and continue, but not spam the log file...?)

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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

Clean up data layer after moving all plugins and interfaces to a common location

3 participants