Skip to content
Open
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
10 changes: 5 additions & 5 deletions pkg/operator/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func NewController() (*Controller, error) {
controller.mcLabelsAcrossMCP = map[string]bool{}

// Initial event to bootstrap CR if it doesn't exist.
controller.workqueue.AddRateLimited(wqKey{kind: wqKindTuned, name: tunedv1.TunedDefaultResourceName})
controller.workqueue.Add(wqKey{kind: wqKindTuned, name: tunedv1.TunedDefaultResourceName})

controller.clients.Kube, err = kubeset.NewForConfig(controller.kubeconfig)
if err != nil {
Expand Down Expand Up @@ -280,7 +280,7 @@ func (c *Controller) sync(key wqKey) error {
if change {
klog.V(2).Infof("sync(): Pod %s/%s label(s) change is Node %s wide", key.namespace, key.name, nodeName)
// Trigger a Profile update
c.workqueue.AddRateLimited(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: nodeName})
c.workqueue.Add(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: nodeName})
}
return nil

Expand All @@ -291,7 +291,7 @@ func (c *Controller) sync(key wqKey) error {
if err != nil {
if errors.IsNotFound(err) {
// Trigger Profile update/deletion for this node; syncProfile() will handle the deletion and also update internal data structures
c.workqueue.AddRateLimited(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: key.name})
c.workqueue.Add(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: key.name})
return nil
}
return fmt.Errorf("failed to process Node %s change: %v", key.name, err)
Expand All @@ -300,7 +300,7 @@ func (c *Controller) sync(key wqKey) error {
// We need to update Profile associated with the Node
klog.V(2).Infof("sync(): Node %s label(s) changed", key.name)
// Trigger a Profile update
c.workqueue.AddRateLimited(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: key.name})
c.workqueue.Add(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: key.name})
}
return nil

Expand Down Expand Up @@ -472,7 +472,7 @@ func (c *Controller) enqueueProfileUpdates() error {
}
for _, profile := range profileList {
// Enqueue Profile updates into the operator's workqueue
c.workqueue.AddRateLimited(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: profile.Name})
c.workqueue.Add(wqKey{kind: wqKindProfile, namespace: ntoconfig.WatchNamespace(), name: profile.Name})
}
return nil
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/operator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package operator
import (
"context"
"fmt"
"reflect"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
Expand Down Expand Up @@ -60,13 +61,21 @@ func (c *Controller) validateTunedCRs() error {
}
}

oldStatus := tuned.Status

tuned = tuned.DeepCopy() // Make sure we do not modify objects in cache

if len(tuned.Status.Conditions) == 0 {
tuned.Status.Conditions = initializeTunedStatusConditions()
}
tuned.Status.Conditions = computeStatusConditions(tunedValid, message, tuned.Status.Conditions)

// Update the status subresource only if there is a semantic change in it.
if reflect.DeepEqual(oldStatus, tuned.Status) {
klog.V(2).Infof("validateTunedCRs(): no need to update status of Tuned %s", tuned.Name)
continue
}

_, err = c.clients.Tuned.TunedV1().Tuneds(ntoconfig.WatchNamespace()).UpdateStatus(context.TODO(), tuned, metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("failed to update Tuned %s status: %v", tuned.Name, err)
Expand Down