Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func (p *SriovNetworkNodePolicy) Apply(state *SriovNetworkNodeState, equalPriori
}
for _, iface := range state.Status.Interfaces {
if s.Selected(&iface) {
log.Info("Update interface", "name:", iface.Name)
log.V(2).Info("Update interface", "name:", iface.Name)
result := Interface{
PciAddress: iface.PciAddress,
Mtu: p.Spec.Mtu,
Expand Down
2 changes: 1 addition & 1 deletion controllers/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func updateDaemonsetNodeSelector(obj *uns.Unstructured, nodeSelector map[string]

func findNodePoolConfig(ctx context.Context, node *corev1.Node, c k8sclient.Client) (*sriovnetworkv1.SriovNetworkPoolConfig, []corev1.Node, error) {
logger := log.FromContext(ctx)
logger.Info("FindNodePoolConfig():")
logger.V(1).Info("FindNodePoolConfig():")
// get all the sriov network pool configs
npcl := &sriovnetworkv1.SriovNetworkPoolConfigList{}
err := c.List(ctx, npcl)
Expand Down
14 changes: 9 additions & 5 deletions controllers/sriovnetworknodepolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,11 @@
qHandler(q)
},
UpdateFunc: func(ctx context.Context, e event.UpdateEvent, q workqueue.RateLimitingInterface) {
reflect.DeepEqual(e.ObjectOld.GetLabels(), e.ObjectNew.GetLabels())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What the... ?!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reflect.DeepEqual returns a bool, but the return value was never assigned or checked -- it was called as a standalone statement and the result was thrown away. The code then unconditionally fell through to qHandler(q), enqueueing a reconcile on every single Node update regardless of whether labels changed.

This is almost certainly a bug. The intent was clearly to only reconcile when node labels change (since label changes affect which policies apply to which nodes). But as written, it was a no-op -- equivalent to not having the check at all.

if reflect.DeepEqual(e.ObjectOld.GetLabels(), e.ObjectNew.GetLabels()) {
return
}
log.Log.WithName("SriovNetworkNodePolicy").
Info("Enqueuing sync for create event", "resource", e.ObjectNew.GetName())
Info("Enqueuing sync for update event", "resource", e.ObjectNew.GetName())
qHandler(q)
},
DeleteFunc: func(ctx context.Context, e event.DeleteEvent, q workqueue.RateLimitingInterface) {
Expand Down Expand Up @@ -224,7 +226,7 @@
}
configData[node.Name] = string(config)

if data.ResourceList == nil || len(data.ResourceList) == 0 {

Check failure on line 229 in controllers/sriovnetworknodepolicy_controller.go

View workflow job for this annotation

GitHub Actions / build

S1009: should omit nil check; len() for []github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types.ResourceConfig is defined as zero (gosimple)

Check failure on line 229 in controllers/sriovnetworknodepolicy_controller.go

View workflow job for this annotation

GitHub Actions / build

S1009: should omit nil check; len() for []github.com/k8snetworkplumbingwg/sriov-network-device-plugin/pkg/types.ResourceConfig is defined as zero (gosimple)
// if we don't have policies we should add the disabled label for the device plugin
err = utils.LabelNode(ctx, node.Name, constants.SriovDevicePluginLabel, constants.SriovDevicePluginLabelDisabled, r.Client)
if err != nil {
Expand Down Expand Up @@ -306,8 +308,10 @@
if netPoolConfig != nil {
ns.Spec.System.RdmaMode = netPoolConfig.Spec.RdmaMode
}
j, _ := json.Marshal(ns)
logger.V(2).Info("SriovNetworkNodeState CR", "content", j)
if logger.V(2).Enabled() {
j, _ := json.Marshal(ns)
logger.V(2).Info("SriovNetworkNodeState CR", "content", j)
}
if err := r.syncSriovNetworkNodeState(ctx, dc, npl, ns, &node); err != nil {
logger.Error(err, "Fail to sync", "SriovNetworkNodeState", ns.Name)
return err
Expand Down Expand Up @@ -398,7 +402,7 @@
continue
}
if p.Selected(node) {
logger.Info("apply", "policy", p.Name, "node", node.Name)
logger.V(1).Info("apply", "policy", p.Name, "node", node.Name)
// Merging only for policies with the same priority (ppp == p.Spec.Priority)
// This boolean flag controls merging of PF configuration (e.g. mtu, numvfs etc)
// when VF partition is configured.
Expand Down
Loading