Skip to content

Commit af24cde

Browse files
committed
Make messages and variable names somewhat more consistent
Signed-off-by: Shmuel Kallner <kallner@il.ibm.com>
1 parent 335982f commit af24cde

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

pkg/epp/backend/metrics/fake.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type FakePodMetrics struct {
3838
}
3939

4040
func (fpm *FakePodMetrics) String() string {
41-
return fmt.Sprintf("Pod: %v; Metrics: %v", fpm.GetMetadata(), fpm.GetMetrics())
41+
return fmt.Sprintf("Metadata: %v; Metrics: %v", fpm.GetMetadata(), fpm.GetMetrics())
4242
}
4343

4444
func (fpm *FakePodMetrics) GetMetadata() *backend.Pod {
@@ -49,8 +49,8 @@ func (fpm *FakePodMetrics) GetMetrics() *MetricsState {
4949
return fpm.Metrics
5050
}
5151

52-
func (fpm *FakePodMetrics) UpdateMetadata(pod *datalayer.EndpointMetadata) {
53-
fpm.Pod = pod
52+
func (fpm *FakePodMetrics) UpdateMetadata(metadata *datalayer.EndpointMetadata) {
53+
fpm.Pod = metadata
5454
}
5555
func (fpm *FakePodMetrics) GetAttributes() *datalayer.Attributes {
5656
return fpm.Attributes

pkg/epp/backend/metrics/pod_metrics.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type PodMetricsClient interface {
5252
}
5353

5454
func (pm *podMetrics) String() string {
55-
return fmt.Sprintf("Pod: %v; Metrics: %v", pm.GetMetadata(), pm.GetMetrics())
55+
return fmt.Sprintf("Metadata: %v; Metrics: %v", pm.GetMetadata(), pm.GetMetrics())
5656
}
5757

5858
func (pm *podMetrics) GetMetadata() *datalayer.EndpointMetadata {
@@ -72,7 +72,7 @@ func (pm *podMetrics) UpdateMetadata(pod *datalayer.EndpointMetadata) {
7272
func (pm *podMetrics) startRefreshLoop(ctx context.Context) {
7373
pm.startOnce.Do(func() {
7474
go func() {
75-
pm.logger.V(logutil.DEFAULT).Info("Starting refresher", "pod", pm.GetMetadata())
75+
pm.logger.V(logutil.DEFAULT).Info("Starting refresher", "metadata", pm.GetMetadata())
7676
ticker := time.NewTicker(pm.interval)
7777
defer ticker.Stop()
7878
for {
@@ -83,7 +83,7 @@ func (pm *podMetrics) startRefreshLoop(ctx context.Context) {
8383
return
8484
case <-ticker.C: // refresh metrics periodically
8585
if err := pm.refreshMetrics(); err != nil {
86-
pm.logger.V(logutil.TRACE).Error(err, "Failed to refresh metrics", "pod", pm.GetMetadata())
86+
pm.logger.V(logutil.TRACE).Error(err, "Failed to refresh metrics", "metadata", pm.GetMetadata())
8787
}
8888
}
8989
}
@@ -114,7 +114,7 @@ func (pm *podMetrics) refreshMetrics() error {
114114
}
115115

116116
func (pm *podMetrics) stopRefreshLoop() {
117-
pm.logger.V(logutil.DEFAULT).Info("Stopping refresher", "pod", pm.GetMetadata())
117+
pm.logger.V(logutil.DEFAULT).Info("Stopping refresher", "metadata", pm.GetMetadata())
118118
pm.stopOnce.Do(func() {
119119
close(pm.done)
120120
})

pkg/epp/datalayer/endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func NewEndpoint(meta *EndpointMetadata, metrics *Metrics) *ModelServer {
6868
// String returns a representation of the ModelServer. For brevity, only names of
6969
// extended attributes are returned and not their values.
7070
func (srv *ModelServer) String() string {
71-
return fmt.Sprintf("Pod: %v; Metrics: %v; Attributes: %v", srv.GetMetadata(), srv.GetMetrics(), srv.Keys())
71+
return fmt.Sprintf("Metadata: %v; Metrics: %v; Attributes: %v", srv.GetMetadata(), srv.GetMetrics(), srv.Keys())
7272
}
7373

7474
func (srv *ModelServer) GetMetadata() *EndpointMetadata {

pkg/epp/datalayer/metrics/extractor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (ext *Extractor) Extract(ctx context.Context, data any, ep datalayer.Endpoi
153153
}
154154
}
155155

156-
logger := log.FromContext(ctx).WithValues("pod", ep.GetMetadata().NamespacedName)
156+
logger := log.FromContext(ctx).WithValues("endpoint", ep.GetMetadata().NamespacedName)
157157
if updated {
158158
clone.UpdateTime = time.Now()
159159
logger.V(logutil.TRACE).Info("Refreshed metrics", "updated", clone)

pkg/epp/datalayer/metrics/logger_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ func TestLogger(t *testing.T) {
7272

7373
logOutput := b.read()
7474
assert.Contains(t, logOutput, "Refreshing Prometheus Metrics {\"ReadyPods\": 2}")
75-
assert.Contains(t, logOutput, "Current Pods and metrics gathered {\"Fresh metrics\": \"[Pod: {NamespacedName:default/pod1 PodName: Address:1.2.3.4:5678")
75+
assert.Contains(t, logOutput, "Current Pods and metrics gathered {\"Fresh metrics\": \"[Metadata: {NamespacedName:default/pod1 PodName: Address:1.2.3.4:5678")
7676
assert.Contains(t, logOutput, "Metrics: {ActiveModels:map[modelA:1] WaitingModels:map[modelB:2] MaxActiveModels:5")
7777
assert.Contains(t, logOutput, "RunningQueueSize:3 WaitingQueueSize:7 KVCacheUsagePercent:42.5 KvCacheMaxTokenCapacity:2048")
78-
assert.Contains(t, logOutput, "Pod: {NamespacedName:default/pod2 PodName: Address:1.2.3.4:5679")
78+
assert.Contains(t, logOutput, "Metadata: {NamespacedName:default/pod2 PodName: Address:1.2.3.4:5679")
7979
assert.Contains(t, logOutput, "\"Stale metrics\": \"[]\"")
8080
}
8181

pkg/epp/datastore/datastore.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ func (ds *datastore) podResyncAll(ctx context.Context, reader client.Reader) err
343343
ds.pods.Range(func(k, v any) bool {
344344
ep := v.(datalayer.Endpoint)
345345
if exist := activePods[ep.GetMetadata().PodName]; !exist {
346-
logger.V(logutil.VERBOSE).Info("Removing pod", "pod", ep.GetMetadata())
346+
logger.V(logutil.VERBOSE).Info("Removing pod", "pod", ep.GetMetadata().PodName)
347347
ds.PodDelete(ep.GetMetadata().PodName)
348348
}
349349
return true

0 commit comments

Comments
 (0)