From b6536f292ba586e023d345520fc5ddc5c957ecd1 Mon Sep 17 00:00:00 2001 From: Feruzjon Muyassarov Date: Thu, 30 May 2024 13:37:04 +0300 Subject: [PATCH] resmgr: don't log about NRT CR updates when object isn't created Signed-off-by: Feruzjon Muyassarov --- pkg/agent/node-resource-topology.go | 13 +------------ pkg/resmgr/resource-manager.go | 9 +++++---- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/pkg/agent/node-resource-topology.go b/pkg/agent/node-resource-topology.go index f8b753773..a21ecc6dc 100644 --- a/pkg/agent/node-resource-topology.go +++ b/pkg/agent/node-resource-topology.go @@ -67,24 +67,13 @@ func (a *Agent) updateNrtCR(policy string, zones []*policyapi.TopologyZone) erro } } - // delete existing CR if we got no data from policy // XXX TODO Deletion should be handled differently: // 1. add expiration timestamp to nrt.NodeResourceTopology // 2. GC CRs that are past their expiration time (for instance by NFD) // 3. make sure we refresh our CR (either here or preferably/easier // by triggering in resmgr an updateTopologyZones() during longer // periods of inactivity) - if len(zones) == 0 { - if cr != nil { - err := cli.Delete(ctx, a.nodeName, metav1.DeleteOptions{}) - if err != nil && !errors.IsNotFound(err) { - return fmt.Errorf("failed to delete node resource topology CR: %w", err) - } - } - return nil - } - - // otherwise update CR if one exists + // update CR if one exists if cr != nil { cr.Attributes = nrt.AttributeList{ nrt.AttributeInfo{ diff --git a/pkg/resmgr/resource-manager.go b/pkg/resmgr/resource-manager.go index 078e9f7db..b827c75ad 100644 --- a/pkg/resmgr/resource-manager.go +++ b/pkg/resmgr/resource-manager.go @@ -271,10 +271,11 @@ func (m *resmgr) startControllers() error { // updateTopologyZones updates the 'topology zone' CRDs. func (m *resmgr) updateTopologyZones() { - m.Info("updating topology zones...") - err := m.agent.UpdateNrtCR(m.policy.ActivePolicy(), m.policy.GetTopologyZones()) - if err != nil { - m.Error("failed to update topology zones: %v", err) + if zones := m.policy.GetTopologyZones(); len(zones) != 0 { + m.Info("updating topology zones...") + if err := m.agent.UpdateNrtCR(m.policy.ActivePolicy(), zones); err != nil { + m.Error("failed to update topology zones: %v", err) + } } }