Skip to content

Commit be989bf

Browse files
Move test object yamls to test/artifacts directory in ext-proc, make start manager in main blocking
1 parent a58b77c commit be989bf

File tree

4 files changed

+23
-47
lines changed

4 files changed

+23
-47
lines changed

pkg/ext-proc/main.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,8 @@ func main() {
131131
// Start metrics handler
132132
metricsSvr := startMetricsHandler(*metricsPort, cfg)
133133

134-
// Start the controller manager. Blocking and will return when shutdown is complete.
135-
klog.Infof("Starting controller manager")
136-
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
137-
klog.Fatalf("Error starting controller manager: %v", err)
138-
}
139-
klog.Info("Controller manager shutting down")
134+
// Start manager, blocking
135+
runner.StartManager()
140136

141137
// Gracefully shutdown servers
142138
if healthSvr != nil {

pkg/ext-proc/server/runserver.go

+15-10
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type ExtProcServerRunner struct {
3030
Scheme *runtime.Scheme
3131
Config *rest.Config
3232
Datastore *backend.K8sDatastore
33+
manager *ctrl.Manager
3334
}
3435

3536
// Setup creates the reconcilers for pools, models, and endpointSlices and starts the manager.
@@ -39,6 +40,7 @@ func (r *ExtProcServerRunner) Setup() {
3940
if err != nil {
4041
klog.Fatalf("Failed to create controller manager: %v", err)
4142
}
43+
r.manager = &mgr
4244

4345
// Create the controllers and register them with the manager
4446
if err := (&backend.InferencePoolReconciler{
@@ -77,16 +79,6 @@ func (r *ExtProcServerRunner) Setup() {
7779
}).SetupWithManager(mgr); err != nil {
7880
klog.Fatalf("Failed setting up EndpointSliceReconciler: %v", err)
7981
}
80-
81-
// Start the controller manager. Blocking and will return when shutdown is complete.
82-
errChan := make(chan error)
83-
klog.Infof("Starting controller manager")
84-
go func() {
85-
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
86-
klog.Error(err, "Error running manager")
87-
errChan <- err
88-
}
89-
}()
9082
}
9183

9284
// Start starts the Envoy external processor server in a goroutine.
@@ -123,3 +115,16 @@ func (r *ExtProcServerRunner) Start(
123115
}()
124116
return svr
125117
}
118+
119+
func (r *ExtProcServerRunner) StartManager() {
120+
if r.manager == nil {
121+
klog.Fatalf("Runner has no manager setup to run: %v", r)
122+
}
123+
// Start the controller manager. Blocking and will return when shutdown is complete.
124+
klog.Infof("Starting controller manager")
125+
mgr := *r.manager
126+
if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
127+
klog.Fatalf("Error starting controller manager: %v", err)
128+
}
129+
klog.Info("Controller manager shutting down")
130+
}

pkg/ext-proc/test/hermetic_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,13 @@ func setUpHermeticServer(t *testing.T, cfg *rest.Config, pods []*backend.PodMetr
326326
}
327327
runner.Setup()
328328

329+
// Start the controller manager in go routine, not blocking
330+
go func() {
331+
runner.StartManager()
332+
}()
333+
329334
// Unmarshal CRDs from file into structs
330-
manifestsPath := filepath.Join("..", "..", "..", "examples", "poc", "manifests", "inferencepool-with-model-hermetic.yaml")
335+
manifestsPath := filepath.Join(".", "artifacts", "inferencepool-with-model-hermetic.yaml")
331336
docs, err := readDocuments(manifestsPath)
332337
if err != nil {
333338
log.Fatalf("Can't read object manifests at path %v, %v", manifestsPath, err)

pkg/manifests/inferencepool-with-model-hermetic.yaml

-30
This file was deleted.

0 commit comments

Comments
 (0)