Skip to content

Commit a58f421

Browse files
committed
address reviewer feedback
Signed-off-by: Luke Van Drie <lukevandrie@google.com>
1 parent 862f97b commit a58f421

5 files changed

Lines changed: 19 additions & 82 deletions

File tree

cmd/epp/runner/runner.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -664,23 +664,6 @@ func (r *Runner) parseConfigurationPhaseTwo(ctx context.Context, rawConfig *conf
664664
r.parsers = handlers.NewParsers(cfg.ParserConfig)
665665
logger.Info("loaded configuration from file/text successfully")
666666

667-
var loadProducer *inflightload.InFlightLoadProducer
668-
for _, p := range handle.GetAllPlugins() {
669-
if prod, ok := p.(*inflightload.InFlightLoadProducer); ok {
670-
loadProducer = prod
671-
break
672-
}
673-
}
674-
675-
if loadProducer != nil {
676-
key := attrconcurrency.InFlightLoadDataKey.WithNonEmptyProducerName(loadProducer.TypedName().Name)
677-
r.dlRuntime.RegisterAttributeProvider(key.String(), func(eid string) fwkdl.Cloneable {
678-
return &attrconcurrency.InFlightLoad{
679-
Tokens: loadProducer.GetTokens(eid),
680-
Requests: loadProducer.GetRequests(eid),
681-
}
682-
})
683-
}
684667

685668
return cfg, nil
686669
}

pkg/epp/datalayer/runtime.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ type Runtime struct {
5959

6060
collectors *collectorManager // per-endpoint poller, keyed by namespaced name
6161
logger logr.Logger // Set in Configure; used where no context is available (e.g. ReleaseEndpoint).
62-
63-
provMu sync.RWMutex
64-
providers map[string]func(endpointID string) fwkdl.Cloneable
6562
}
6663

6764
const (
@@ -83,7 +80,6 @@ func NewRuntime(pollingInterval time.Duration) *Runtime {
8380
extractors: newExtractorMap(),
8481
collectors: newCollectorManager(),
8582
logger: logr.Discard(),
86-
providers: make(map[string]func(endpointID string) fwkdl.Cloneable),
8783
}
8884
}
8985

@@ -226,16 +222,6 @@ func (r *Runtime) Register(reg fwkdl.PendingRegistration) error {
226222
return nil
227223
}
228224

229-
// RegisterAttributeProvider registers a provider function for a dynamic attribute.
230-
func (r *Runtime) RegisterAttributeProvider(key string, provider func(endpointID string) fwkdl.Cloneable) {
231-
r.provMu.Lock()
232-
defer r.provMu.Unlock()
233-
if r.providers == nil {
234-
r.providers = make(map[string]func(endpointID string) fwkdl.Cloneable)
235-
}
236-
r.providers[key] = provider
237-
}
238-
239225
// registerSource dispatches src to the matching variant manager. g enforces
240226
// per-Configure-call GVK uniqueness for NotificationSources. src may be a
241227
// PollingDispatcher (not a DataSource), so the parameter is plugin.Plugin.
@@ -386,17 +372,6 @@ func (r *Runtime) NewEndpoint(ctx context.Context, endpointMetadata *fwkdl.Endpo
386372
logger = logger.WithValues("endpoint", endpointMetadata.GetNamespacedName())
387373

388374
endpoint := fwkdl.NewEndpoint(endpointMetadata, nil)
389-
eid := endpointMetadata.GetNamespacedName().String()
390-
391-
r.provMu.RLock()
392-
for key, provider := range r.providers {
393-
endpoint.GetAttributes().Put(key, &fwkdl.DynamicAttribute{
394-
Get: func() fwkdl.Cloneable {
395-
return provider(eid)
396-
},
397-
})
398-
}
399-
r.provMu.RUnlock()
400375

401376
dispatchers := make([]fwkdl.PollingDispatcher, 0, r.dispatchers.Count())
402377
for _, d := range r.dispatchers.Dispatchers() {

pkg/epp/datalayer/runtime_endpoint_dispatch_test.go

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ import (
3030
"github.com/llm-d/llm-d-router/pkg/epp/framework/plugins/datalayer/source/notifications"
3131
)
3232

33-
type dummy struct {
34-
Text string
35-
}
36-
37-
func (d *dummy) Clone() fwkdl.Cloneable {
38-
if d == nil {
39-
return nil
40-
}
41-
return &dummy{Text: d.Text}
42-
}
43-
4433
// TestNewEndpointDispatchesEventWithNoPollers verifies that endpoint lifecycle
4534
// events are dispatched to EndpointSource even when no PollingDataSource is configured.
4635
// Regression test for: endpoint-notification-source silently drops events when
@@ -112,26 +101,3 @@ func TestUpdateEndpointDispatchesEvent(t *testing.T) {
112101
assert.Equal(t, fwkdl.EventAddOrUpdate, events[0].Type)
113102
assert.Equal(t, "5.6.7.8", events[0].Endpoint.GetMetadata().Address)
114103
}
115-
116-
func TestRuntimeRegisterAttributeProvider(t *testing.T) {
117-
r := NewRuntime(1)
118-
119-
r.RegisterAttributeProvider("test-key", func(endpointID string) fwkdl.Cloneable {
120-
return &dummy{Text: endpointID + "-value"}
121-
})
122-
123-
pod := &fwkdl.EndpointMetadata{
124-
NamespacedName: types.NamespacedName{Name: "pod1", Namespace: "default"},
125-
Address: "1.2.3.4",
126-
}
127-
128-
endpoint := r.NewEndpoint(context.Background(), pod)
129-
assert.NotNil(t, endpoint)
130-
131-
val, ok := endpoint.GetAttributes().Get("test-key")
132-
assert.True(t, ok)
133-
134-
dVal, ok := val.(*dummy)
135-
assert.True(t, ok)
136-
assert.Equal(t, "default/pod1-value", dVal.Text)
137-
}

pkg/epp/framework/plugins/requestcontrol/dataproducer/inflightload/producer.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,29 @@ func (p *InFlightLoadProducer) RegisterDependencies(r datalayer.Registrar) error
175175
})
176176
}
177177

178-
// Extract handles endpoint deletion events to prune stateful trackers.
178+
// Extract handles endpoint lifecycle events to manage dynamic attributes.
179179
func (p *InFlightLoadProducer) Extract(ctx context.Context, event datalayer.EndpointEvent) error {
180-
if event.Type != datalayer.EventDelete || event.Endpoint == nil || event.Endpoint.GetMetadata() == nil {
180+
if event.Endpoint == nil || event.Endpoint.GetMetadata() == nil {
181181
return nil
182182
}
183183

184184
id := event.Endpoint.GetMetadata().NamespacedName.String()
185185

186-
p.DeleteEndpoint(id)
187-
log.FromContext(ctx).V(logutil.DEFAULT).Info("Cleaned up in-flight load for deleted endpoint", "endpoint", id)
186+
switch event.Type {
187+
case datalayer.EventDelete:
188+
p.DeleteEndpoint(id)
189+
log.FromContext(ctx).V(logutil.DEFAULT).Info("Cleaned up in-flight load for deleted endpoint", "endpoint", id)
190+
case datalayer.EventAddOrUpdate:
191+
event.Endpoint.GetAttributes().Put(p.dk.String(), &datalayer.DynamicAttribute{
192+
Get: func() datalayer.Cloneable {
193+
return &attrconcurrency.InFlightLoad{
194+
Tokens: p.GetTokens(id),
195+
Requests: p.GetRequests(id),
196+
}
197+
},
198+
})
199+
log.FromContext(ctx).V(logutil.DEFAULT).Info("Injected dynamic attribute into endpoint", "key", p.dk.String(), "endpoint", id)
200+
}
188201
return nil
189202
}
190203

test/integration/epp/dynamic_attributes_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ plugins:
4848
headroom: 0.0
4949
- type: mock-metrics-source
5050
requestHandler:
51-
parser:
52-
pluginRef: passthrough-parser
51+
parsers:
52+
- pluginRef: passthrough-parser
5353
dataLayer:
5454
sources:
5555
- pluginRef: mock-metrics-source

0 commit comments

Comments
 (0)