diff --git a/cmd/epp/runner/runner.go b/cmd/epp/runner/runner.go index 5ce4d8983..5c587c3a0 100644 --- a/cmd/epp/runner/runner.go +++ b/cmd/epp/runner/runner.go @@ -69,7 +69,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" @@ -330,7 +330,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 @@ -556,23 +556,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 } } } diff --git a/pkg/epp/config/config.go b/pkg/epp/config/config.go index d966e3c0b..5785d331e 100644 --- a/pkg/epp/config/config.go +++ b/pkg/epp/config/config.go @@ -17,12 +17,12 @@ limitations under the License. package config import ( - "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 } diff --git a/pkg/epp/config/loader/configloader.go b/pkg/epp/config/loader/configloader.go index 03126f3b9..e3a770203 100644 --- a/pkg/epp/config/loader/configloader.go +++ b/pkg/epp/config/loader/configloader.go @@ -29,7 +29,7 @@ import ( configapi "sigs.k8s.io/gateway-api-inference-extension/apix/config/v1alpha1" "sigs.k8s.io/gateway-api-inference-extension/pkg/epp/config" "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" @@ -203,11 +203,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 { diff --git a/pkg/epp/config/loader/configloader_test.go b/pkg/epp/config/loader/configloader_test.go index 82f57f4b2..360f89f44 100644 --- a/pkg/epp/config/loader/configloader_test.go +++ b/pkg/epp/config/loader/configloader_test.go @@ -31,7 +31,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" @@ -321,7 +321,7 @@ func TestBuildSaturationConfig(t *testing.T) { tests := []struct { name string input *configapi.SaturationDetector - expected *saturationdetector.Config + expected *staticthresholdcontroller.Config }{ { name: "Valid Configuration", @@ -330,7 +330,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, @@ -339,10 +339,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, }, }, { @@ -352,10 +352,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, }, }, } diff --git a/pkg/epp/saturationdetector/config.go b/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/config.go similarity index 93% rename from pkg/epp/saturationdetector/config.go rename to pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/config.go index 629c3a6a6..fdd99ba8e 100644 --- a/pkg/epp/saturationdetector/config.go +++ b/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/config.go @@ -5,7 +5,7 @@ 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, @@ -13,7 +13,8 @@ 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" diff --git a/pkg/epp/saturationdetector/saturationdetector.go b/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/controller.go similarity index 99% rename from pkg/epp/saturationdetector/saturationdetector.go rename to pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/controller.go index 0891207e9..998190ee6 100644 --- a/pkg/epp/saturationdetector/saturationdetector.go +++ b/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/controller.go @@ -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" diff --git a/pkg/epp/saturationdetector/saturationdetector_test.go b/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/controller_test.go similarity index 99% rename from pkg/epp/saturationdetector/saturationdetector_test.go rename to pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/controller_test.go index 833d0b245..9d9f7c28e 100644 --- a/pkg/epp/saturationdetector/saturationdetector_test.go +++ b/pkg/epp/saturationcontrol/framework/plugins/staticthresholdcontroller/controller_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package saturationdetector +package staticthresholdcontroller import ( "context" diff --git a/pkg/epp/server/runserver.go b/pkg/epp/server/runserver.go index d35e70c74..28e95b147 100644 --- a/pkg/epp/server/runserver.go +++ b/pkg/epp/server/runserver.go @@ -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. @@ -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. diff --git a/test/integration/epp/hermetic_test.go b/test/integration/epp/hermetic_test.go index a3557a6ed..18ca308af 100644 --- a/test/integration/epp/hermetic_test.go +++ b/test/integration/epp/hermetic_test.go @@ -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" "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" @@ -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)