Skip to content

chore: strict validation metrics and benchmarking#14026

Merged
andy-fong merged 18 commits into
kgateway-dev:mainfrom
chandler-solo:chandler/14009guess
Jun 17, 2026
Merged

chore: strict validation metrics and benchmarking#14026
andy-fong merged 18 commits into
kgateway-dev:mainfrom
chandler-solo:chandler/14009guess

Conversation

@chandler-solo

@chandler-solo chandler-solo commented May 13, 2026

Copy link
Copy Markdown
Contributor

Description

This PR builds on the strict-validation cache work from #14253.

It adds kgateway validation metrics so Envoy validation work can be attributed by caller (route_full, route_matcher, backend, traffic_policy, backend_config_policy) and result. The exported metrics include validation calls, cache hits/misses, valid/invalid-xDS results, invocation errors, and validation duration.

It also extends the load-test framework to collect validation metrics, run attached-route load tests in both standard and strict validation modes, and add a startup benchmark suite for controller rollout timing.

Change Type

/kind feature
/kind cleanup

Changelog

Added kgateway validation metrics for Envoy validation calls, cache behavior, results, and duration by validation caller.

Additional Notes

@chandler-solo chandler-solo added the work in progress Indicates that a PR should not merge because it is a work in progress label May 13, 2026
@gateway-bot gateway-bot added do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels May 13, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been marked as stale because of no activity in the last 30 days. It will be closed in the next 5 days unless it is tagged "no stalebot" or other activity occurs.

@github-actions github-actions Bot added the stale Issues that are stale. These will not be prioritized without further engagement on the issue. label Jun 13, 2026
Signed-off-by: David L. Chandler <[email protected]>
Changed:
- Added cached validator wrapper with LRU caching and validation metrics in pkg/validator/cache.go and pkg/validator/metrics.go.
- Wrapped the default setup validator with the cache in setup.go.
- Added in-process generated matcher validation and kept Envoy matcher-only validation as fallback in validate.go.
- Added caller labels for backend, route, traffic policy, and backend config policy validation.
- Added load-test validation metric scraping/logging around incremental route readiness.
- Added unit coverage for validator caching and matcher validation.

Signed-off-by: David L. Chandler <[email protected]>
Signed-off-by: David L. Chandler <[email protected]>
@gateway-bot gateway-bot added kind/feature Categorizes issue or PR as related to a new feature. release-note and removed do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 15, 2026
@chandler-solo
chandler-solo marked this pull request as ready for review June 15, 2026 21:43
Copilot AI review requested due to automatic review settings June 15, 2026 21:43
@chandler-solo chandler-solo changed the title [WIP] strict validation benchmarking and optimization [WIP] chore: strict validation metrics, benchmarking and optimization Jun 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds instrumentation and benchmarking around strict validation to attribute Envoy validation work by caller/result and to improve performance by short-circuiting common generated matcher checks before invoking Envoy validation. It also extends the e2e load-test framework to collect and report these validation metrics, and introduces a controller rollout startup benchmark.

Changes:

  • Added validator metrics (calls, cache hits/misses, results, duration) labeled by validation caller and result.
  • Added generated-matcher prechecks for strict route validation, with fallback to matcher-only Envoy validation when needed.
  • Extended load-testing to restart the controller after baseline setup, collect validation metrics deltas, and added a standalone startup benchmark suite/test plus CI wiring.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/e2e/tests/startup_benchmark_test.go Adds a dedicated e2e test entrypoint for the startup benchmark.
test/e2e/tests/kgateway_tests.go Registers the startup benchmark suite in the main e2e runner.
test/e2e/features/loadtesting/types.go Extends load-test result schema to include restart/translation timing and validation metrics snapshots/deltas.
test/e2e/features/loadtesting/startup_suite.go Implements controller rollout restart/startup measurement and diagnostics collection.
test/e2e/features/loadtesting/README.md Documents the new startup benchmark and validation-mode load-test runs.
test/e2e/features/loadtesting/loadtest_manager.go Adds Prometheus scraping/parsing to collect kgateway validation metrics.
test/e2e/features/loadtesting/attachedroutes_suite.go Restarts controller post-baseline, captures validation metrics before/after incremental route, and logs deltas.
pkg/validator/metrics.go Introduces Prometheus metrics for validation calls/cache/results/duration with caller/result labels.
pkg/validator/cache.go Records validation metrics for cache hits/misses and outcomes/durations.
pkg/kgateway/translator/irtranslator/validate.go Adds strict-mode generated matcher prechecks and sets validation caller contexts for route validation.
pkg/kgateway/translator/irtranslator/route_test.go Adds unit tests covering matcher prechecks (skip Envoy matcher-only when safe; reject invalid generated regex early).
pkg/kgateway/translator/irtranslator/backend.go Tags backend validation calls with a caller label.
pkg/kgateway/extensions2/plugins/trafficpolicy/validate.go Tags traffic policy validation calls with a caller label.
pkg/kgateway/extensions2/plugins/backendconfigpolicy/validate.go Tags backend config policy validation calls with a caller label.
Makefile Adds load-test knobs for validation mode and go test args/timeouts.
.github/actions/kube-gateway-api-load-tests/action.yaml Runs load tests in both standard and strict validation modes in CI.

Comment thread test/e2e/features/loadtesting/startup_suite.go
Comment thread test/e2e/features/loadtesting/types.go Outdated
Comment on lines +107 to +111
func (m ValidationMetrics) Delta(base ValidationMetrics) ValidationMetrics {
out := ValidationMetrics{
Calls: m.Calls - base.Calls,
CacheHits: m.CacheHits - base.CacheHits,
CacheMisses: m.CacheMisses - base.CacheMisses,
Comment thread test/e2e/features/loadtesting/types.go
Signed-off-by: David L. Chandler <[email protected]>
parts of it if necessary. with caching this complexity is not worth
the cost, I'm pretty sure.

Signed-off-by: David L. Chandler <[email protected]>
@chandler-solo chandler-solo changed the title [WIP] chore: strict validation metrics, benchmarking and optimization [WIP] chore: strict validation metrics and benchmarking Jun 16, 2026
@chandler-solo chandler-solo changed the title [WIP] chore: strict validation metrics and benchmarking chore: strict validation metrics and benchmarking Jun 16, 2026
@chandler-solo chandler-solo removed the work in progress Indicates that a PR should not merge because it is a work in progress label Jun 16, 2026
Signed-off-by: David L. Chandler <[email protected]>
@github-actions github-actions Bot removed the stale Issues that are stale. These will not be prioritized without further engagement on the issue. label Jun 16, 2026
@andy-fong
andy-fong added this pull request to the merge queue Jun 17, 2026
Merged via the queue into kgateway-dev:main with commit 9c122cd Jun 17, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants