Skip to content

Commit f1dda9f

Browse files
authored
Add a few debug logs (#179)
1 parent 41d810a commit f1dda9f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

pkg/ext-proc/backend/endpointslice_reconciler.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
discoveryv1 "k8s.io/api/discovery/v1"
99
"k8s.io/apimachinery/pkg/runtime"
1010
"k8s.io/client-go/tools/record"
11-
"k8s.io/klog/v2"
11+
klog "k8s.io/klog/v2"
1212
ctrl "sigs.k8s.io/controller-runtime"
1313
"sigs.k8s.io/controller-runtime/pkg/builder"
1414
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -52,13 +52,14 @@ func (c *EndpointSliceReconciler) updateDatastore(
5252
podMap := make(map[Pod]bool)
5353

5454
for _, endpoint := range slice.Endpoints {
55-
klog.V(4).Infof("Zone: %v \n endpoint: %+v \n", c.Zone, endpoint)
55+
klog.V(2).Infof("Zone: %v \n endpoint: %+v \n", c.Zone, endpoint)
5656
if c.validPod(endpoint) {
5757
pod := Pod{
5858
Name: endpoint.TargetRef.Name,
5959
Address: endpoint.Addresses[0] + ":" + strconv.Itoa(int(inferencePool.Spec.TargetPortNumber)),
6060
}
6161
podMap[pod] = true
62+
klog.V(2).Infof("Storing pod %v", pod)
6263
c.Datastore.pods.Store(pod, true)
6364
}
6465
}
@@ -70,6 +71,7 @@ func (c *EndpointSliceReconciler) updateDatastore(
7071
return false
7172
}
7273
if _, ok := podMap[pod]; !ok {
74+
klog.V(2).Infof("Removing pod %v", pod)
7375
c.Datastore.pods.Delete(pod)
7476
}
7577
return true
@@ -81,7 +83,7 @@ func (c *EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) error {
8183
inferencePoolAvailable := func(object client.Object) bool {
8284
_, err := c.Datastore.getInferencePool()
8385
if err != nil {
84-
klog.Warningf("Skipping reconciling EndpointSlice because the InferencePool is not available yet: %v", err)
86+
klog.V(2).Infof("Skipping reconciling EndpointSlice because the InferencePool is not available yet: %v", err)
8587
}
8688
return err == nil
8789
}
@@ -93,7 +95,13 @@ func (c *EndpointSliceReconciler) SetupWithManager(mgr ctrl.Manager) error {
9395
return false
9496
}
9597

96-
return endpointSlice.ObjectMeta.Labels[serviceOwnerLabel] == c.ServiceName
98+
gotLabel := endpointSlice.ObjectMeta.Labels[serviceOwnerLabel]
99+
wantLabel := c.ServiceName
100+
if gotLabel != wantLabel {
101+
namesapcedName := endpointSlice.ObjectMeta.Namespace + "/" + endpointSlice.ObjectMeta.Name
102+
klog.V(2).Infof("Skipping EndpointSlice %v because its service owner label %v doesn't match the pool service name %v", namesapcedName, gotLabel, wantLabel)
103+
}
104+
return gotLabel == wantLabel
97105
}
98106

99107
return ctrl.NewControllerManagedBy(mgr).

pkg/ext-proc/backend/inferencepool_reconciler.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"k8s.io/apimachinery/pkg/runtime"
88
"k8s.io/apimachinery/pkg/types"
99
"k8s.io/client-go/tools/record"
10-
"k8s.io/klog/v2"
10+
klog "k8s.io/klog/v2"
1111
ctrl "sigs.k8s.io/controller-runtime"
1212
"sigs.k8s.io/controller-runtime/pkg/client"
1313
)
@@ -42,8 +42,10 @@ func (c *InferencePoolReconciler) Reconcile(ctx context.Context, req ctrl.Reques
4242
}
4343

4444
func (c *InferencePoolReconciler) updateDatastore(serverPool *v1alpha1.InferencePool) {
45-
if c.Datastore.inferencePool == nil ||
46-
serverPool.ObjectMeta.ResourceVersion != c.Datastore.inferencePool.ObjectMeta.ResourceVersion {
45+
pool, _ := c.Datastore.getInferencePool()
46+
if pool == nil ||
47+
serverPool.ObjectMeta.ResourceVersion != pool.ObjectMeta.ResourceVersion {
48+
klog.Infof("Updating inference pool to %v/%v", serverPool.ObjectMeta.Namespace, serverPool.ObjectMeta.Name)
4749
c.Datastore.setInferencePool(serverPool)
4850
}
4951
}

0 commit comments

Comments
 (0)