From f24d917d3c69a4b08cee99148e74bbda74614601 Mon Sep 17 00:00:00 2001 From: Rob Scott Date: Thu, 2 Sep 2021 15:46:14 -0700 Subject: [PATCH] Adding more detailed logging for Topology Hints --- pkg/controller/endpointslice/endpointslice_controller.go | 1 + pkg/controller/endpointslice/topologycache/topologycache.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/controller/endpointslice/endpointslice_controller.go b/pkg/controller/endpointslice/endpointslice_controller.go index 7800e984737..d023b8347cb 100644 --- a/pkg/controller/endpointslice/endpointslice_controller.go +++ b/pkg/controller/endpointslice/endpointslice_controller.go @@ -543,6 +543,7 @@ func (c *Controller) checkNodeTopologyDistribution() { c.topologyCache.SetNodes(nodes) serviceKeys := c.topologyCache.GetOverloadedServices() for _, serviceKey := range serviceKeys { + klog.V(2).Infof("Queuing %s Service after Node change due to overloading", serviceKey) c.queue.Add(serviceKey) } } diff --git a/pkg/controller/endpointslice/topologycache/topologycache.go b/pkg/controller/endpointslice/topologycache/topologycache.go index 7ea9afb2e84..5e91b0f6a64 100644 --- a/pkg/controller/endpointslice/topologycache/topologycache.go +++ b/pkg/controller/endpointslice/topologycache/topologycache.go @@ -20,7 +20,7 @@ import ( "math" "sync" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" discovery "k8s.io/api/discovery/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/klog/v2" @@ -132,6 +132,7 @@ func (t *TopologyCache) AddHints(si *SliceInfo) ([]*discovery.EndpointSlice, []* // cache. func (t *TopologyCache) SetHints(serviceKey string, addrType discovery.AddressType, allocatedHintsByZone EndpointZoneInfo) { if len(allocatedHintsByZone) == 0 { + klog.V(2).Infof("No hints allocated for zones, removing them from %s EndpointSlices for %s Service", addrType, serviceKey) t.RemoveHints(serviceKey, addrType) return } @@ -184,6 +185,7 @@ func (t *TopologyCache) SetNodes(nodes []*v1.Node) { if !ok || zone == "" || nodeCPU.IsZero() { cpuByZone = map[string]*resource.Quantity{} sufficientNodeInfo = false + klog.Warningf("Can't get CPU or zone information for %s node", node.Name) break } @@ -199,6 +201,7 @@ func (t *TopologyCache) SetNodes(nodes []*v1.Node) { defer t.lock.Unlock() if totalCPU.IsZero() || !sufficientNodeInfo || len(cpuByZone) < 2 { + klog.V(2).Infof("Insufficient node info for topology hints (%d zones, %s CPU, %t)", len(cpuByZone), totalCPU.MilliValue(), sufficientNodeInfo) t.sufficientNodeInfo = false t.cpuByZone = nil t.cpuRatiosByZone = nil @@ -219,6 +222,7 @@ func (t *TopologyCache) SetNodes(nodes []*v1.Node) { // threshold, a nil value will be returned. func (t *TopologyCache) getAllocations(numEndpoints int) map[string]Allocation { if t.cpuRatiosByZone == nil || len(t.cpuRatiosByZone) < 2 || len(t.cpuRatiosByZone) > numEndpoints { + klog.V(2).Infof("Insufficient info to allocate endpoints (%d endpoints, %d zones)", numEndpoints, len(t.cpuRatiosByZone)) return nil }