Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions cmd/epp/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import (
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/requestcontrol"
testresponsereceived "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/requestcontrol/plugins/test/responsereceived"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/multi/prefix"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/multi/slo_aware_router"
Expand Down Expand Up @@ -289,7 +289,7 @@ func (r *Runner) Run(ctx context.Context) error {

scheduler := scheduling.NewSchedulerWithConfig(r.schedulerConfig)

saturationDetector := saturationdetector.NewDetector(eppConfig.SaturationDetectorConfig, setupLog)
saturationDetector := staticthresholdcontroller.NewDetector(eppConfig.SaturationDetectorConfig, setupLog)

// --- Admission Control Initialization ---
var admissionController requestcontrol.AdmissionController
Expand Down Expand Up @@ -512,23 +512,23 @@ func (r *Runner) deprecatedConfigurationHelper(cfg *config.Config, logger logr.L
if _, ok := os.LookupEnv(EnvSdQueueDepthThreshold); ok {
logger.Info("Configuring Saturation Detector using environment variables is deprecated and will be removed in next version")
cfg.SaturationDetectorConfig.QueueDepthThreshold =
env.GetEnvInt(EnvSdQueueDepthThreshold, saturationdetector.DefaultQueueDepthThreshold, logger)
env.GetEnvInt(EnvSdQueueDepthThreshold, staticthresholdcontroller.DefaultQueueDepthThreshold, logger)
if cfg.SaturationDetectorConfig.QueueDepthThreshold <= 0 {
cfg.SaturationDetectorConfig.QueueDepthThreshold = saturationdetector.DefaultQueueDepthThreshold
cfg.SaturationDetectorConfig.QueueDepthThreshold = staticthresholdcontroller.DefaultQueueDepthThreshold
}
}
if _, ok := os.LookupEnv(EnvSdKVCacheUtilThreshold); ok {
logger.Info("Configuring Saturation Detector using environment variables is deprecated and will be removed in next version")
cfg.SaturationDetectorConfig.KVCacheUtilThreshold = env.GetEnvFloat(EnvSdKVCacheUtilThreshold, saturationdetector.DefaultKVCacheUtilThreshold, logger)
cfg.SaturationDetectorConfig.KVCacheUtilThreshold = env.GetEnvFloat(EnvSdKVCacheUtilThreshold, staticthresholdcontroller.DefaultKVCacheUtilThreshold, logger)
if cfg.SaturationDetectorConfig.KVCacheUtilThreshold <= 0 || cfg.SaturationDetectorConfig.KVCacheUtilThreshold >= 1 {
cfg.SaturationDetectorConfig.KVCacheUtilThreshold = saturationdetector.DefaultKVCacheUtilThreshold
cfg.SaturationDetectorConfig.KVCacheUtilThreshold = staticthresholdcontroller.DefaultKVCacheUtilThreshold
}
}
if _, ok := os.LookupEnv(EnvSdMetricsStalenessThreshold); ok {
logger.Info("Configuring Saturation Detector using environment variables is deprecated and will be removed in next version")
cfg.SaturationDetectorConfig.MetricsStalenessThreshold = env.GetEnvDuration(EnvSdMetricsStalenessThreshold, saturationdetector.DefaultMetricsStalenessThreshold, logger)
cfg.SaturationDetectorConfig.MetricsStalenessThreshold = env.GetEnvDuration(EnvSdMetricsStalenessThreshold, staticthresholdcontroller.DefaultMetricsStalenessThreshold, logger)
if cfg.SaturationDetectorConfig.MetricsStalenessThreshold <= 0 {
cfg.SaturationDetectorConfig.MetricsStalenessThreshold = saturationdetector.DefaultMetricsStalenessThreshold
cfg.SaturationDetectorConfig.MetricsStalenessThreshold = staticthresholdcontroller.DefaultMetricsStalenessThreshold
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ package config

import (
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling"
)

// Config is the configuration loaded from the text based configuration
type Config struct {
SchedulerConfig *scheduling.SchedulerConfig
SaturationDetectorConfig *saturationdetector.Config
SaturationDetectorConfig *staticthresholdcontroller.Config
DataConfig *datalayer.Config
}
12 changes: 6 additions & 6 deletions pkg/epp/config/loader/configloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/config"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/profile"
Expand Down Expand Up @@ -211,11 +211,11 @@ func loadFeatureConfig(gates configapi.FeatureGates) map[string]bool {
return config
}

func buildSaturationConfig(apiConfig *configapi.SaturationDetector) *saturationdetector.Config {
cfg := &saturationdetector.Config{
QueueDepthThreshold: saturationdetector.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: saturationdetector.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: saturationdetector.DefaultMetricsStalenessThreshold,
func buildSaturationConfig(apiConfig *configapi.SaturationDetector) *staticthresholdcontroller.Config {
cfg := &staticthresholdcontroller.Config{
QueueDepthThreshold: staticthresholdcontroller.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: staticthresholdcontroller.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: staticthresholdcontroller.DefaultMetricsStalenessThreshold,
}

if apiConfig != nil {
Expand Down
22 changes: 11 additions & 11 deletions pkg/epp/config/loader/configloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
configapi "sigs.k8s.io/gateway-api-inference-extension/apix/config/v1alpha1"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datalayer"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/plugins"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/picker"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/profile"
Expand Down Expand Up @@ -339,7 +339,7 @@ func TestBuildSaturationConfig(t *testing.T) {
tests := []struct {
name string
input *configapi.SaturationDetector
expected *saturationdetector.Config
expected *staticthresholdcontroller.Config
}{
{
name: "Valid Configuration",
Expand All @@ -348,7 +348,7 @@ func TestBuildSaturationConfig(t *testing.T) {
KVCacheUtilThreshold: 0.9,
MetricsStalenessThreshold: metav1.Duration{Duration: 500 * time.Millisecond},
},
expected: &saturationdetector.Config{
expected: &staticthresholdcontroller.Config{
QueueDepthThreshold: 20,
KVCacheUtilThreshold: 0.9,
MetricsStalenessThreshold: 500 * time.Millisecond,
Expand All @@ -357,10 +357,10 @@ func TestBuildSaturationConfig(t *testing.T) {
{
name: "Nil Input (Defaults)",
input: nil,
expected: &saturationdetector.Config{
QueueDepthThreshold: saturationdetector.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: saturationdetector.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: saturationdetector.DefaultMetricsStalenessThreshold,
expected: &staticthresholdcontroller.Config{
QueueDepthThreshold: staticthresholdcontroller.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: staticthresholdcontroller.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: staticthresholdcontroller.DefaultMetricsStalenessThreshold,
},
},
{
Expand All @@ -370,10 +370,10 @@ func TestBuildSaturationConfig(t *testing.T) {
KVCacheUtilThreshold: 1.5,
MetricsStalenessThreshold: metav1.Duration{Duration: -10 * time.Second},
},
expected: &saturationdetector.Config{
QueueDepthThreshold: saturationdetector.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: saturationdetector.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: saturationdetector.DefaultMetricsStalenessThreshold,
expected: &staticthresholdcontroller.Config{
QueueDepthThreshold: staticthresholdcontroller.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: staticthresholdcontroller.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: staticthresholdcontroller.DefaultMetricsStalenessThreshold,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package saturationdetector

package staticthresholdcontroller

import (
"time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ limitations under the License.
// - Predictive saturation based on trends.
// - Hysteresis bands or other smoothing techniques to prevent rapid
// oscillations of the saturation signal.
package saturationdetector
package staticthresholdcontroller

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package saturationdetector
package staticthresholdcontroller

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions pkg/epp/server/runserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/datastore"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/handlers"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/requestcontrol"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller"
)

// ExtProcServerRunner provides methods to manage an external process server.
Expand All @@ -58,7 +58,7 @@ type ExtProcServerRunner struct {
RefreshPrometheusMetricsInterval time.Duration
MetricsStalenessThreshold time.Duration
Director *requestcontrol.Director
SaturationDetector *saturationdetector.Detector
SaturationDetector *staticthresholdcontroller.Detector
UseExperimentalDatalayerV2 bool // Pluggable data layer feature flag

// This should only be used in tests. We won't need this once we do not inject metrics in the tests.
Expand Down
12 changes: 6 additions & 6 deletions test/integration/epp/hermetic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import (
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metadata"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/metrics"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/requestcontrol"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationdetector"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller"
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like the use of the word controller in the name here. The EPP is a K8S controller for several CRDs (and growing). I think that is the only context for use of the word controller in a name.

Is the plan for this new extension point to control saturation or just detect saturation and let other components decide what to do?

Also as the word static is used in the name here, is there an intention to a dynamic threshold plugin?

Copy link
Contributor

Choose a reason for hiding this comment

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

++ agree with @shmuelk's comments.
why do we rename from detector to controller? that is confusing when reading this code in the context of k8s.

Copy link
Contributor Author

@LukeAVanDrie LukeAVanDrie Dec 17, 2025

Choose a reason for hiding this comment

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

@shmuelk Thanks for the feedback. I agree that "Controller" is overloaded in the K8s ecosystem and we should avoid confusion with CRD reconcilers. However, I want to move away from "Detector" because the scope of this component is expanding. In the legacy implementation, it was a passive observer returning a boolean. I have some new implementations that act as a closed-loop control systems. They manage internal state and actively calculate dispatch rates or concurrency limits based on feedback variables.

Roadmap:

  • Static Thresholds: (This PR) Throttles based on statically configured metric thresholds.
  • Static Concurrency: Throttles based on statically configured concurrency limits per-pod.
  • Adaptive/Dynamic Concurrency (exploratory/stretch goal): A feedback loop that auto-tune limits.

So, we have a component that actively manages request flow (via its process variable, "saturation") and is somewhat steeped in control theory. This is how I landed on "Controller."

To avoid overloading this term, I suggest renaming this extension point to "SaturationRegulator". This preserves the semantics distinguishing it from passive observation. The path would look like: pkg/epp/saturationregulator/framework/plugins/staticthresholdregulator/regulator.go.

"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework"
"sigs.k8s.io/gateway-api-inference-extension/pkg/epp/scheduling/framework/plugins/multi/prefix"
Expand Down Expand Up @@ -1233,12 +1233,12 @@ func BeforeSuite() func() {
schedulerConfig := scheduling.NewSchedulerConfig(profileHandler, map[string]*framework.SchedulerProfile{"default": defaultProfile})
scheduler := scheduling.NewSchedulerWithConfig(schedulerConfig)

sdConfig := &saturationdetector.Config{
QueueDepthThreshold: saturationdetector.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: saturationdetector.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: saturationdetector.DefaultMetricsStalenessThreshold,
sdConfig := &staticthresholdcontroller.Config{
QueueDepthThreshold: staticthresholdcontroller.DefaultQueueDepthThreshold,
KVCacheUtilThreshold: staticthresholdcontroller.DefaultKVCacheUtilThreshold,
MetricsStalenessThreshold: staticthresholdcontroller.DefaultMetricsStalenessThreshold,
}
detector := saturationdetector.NewDetector(sdConfig, logger.WithName("saturation-detector"))
detector := staticthresholdcontroller.NewDetector(sdConfig, logger.WithName("saturation-detector"))
serverRunner.SaturationDetector = detector
locator := requestcontrol.NewDatastorePodLocator(serverRunner.Datastore)
admissionController := requestcontrol.NewLegacyAdmissionController(detector, locator)
Expand Down