Skip to content

Commit

Permalink
[nvidiadriver-controller] skip DaemonSet update events if there is no…
Browse files Browse the repository at this point in the history
… change in metadata.generation

This avoids unecessary reconciliations when the spec is unchanged.

Signed-off-by: Christopher Desiniotis <[email protected]>
  • Loading branch information
cdesiniotis committed Sep 22, 2023
1 parent 83b6bca commit d2bdba1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/nvidiadriver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"

Expand Down Expand Up @@ -173,7 +174,11 @@ func (r *NVIDIADriverReconciler) SetupWithManager(mgr ctrl.Manager) error {
return reconcileRequests
}

err = c.Watch(source.Kind(mgr.GetCache(), &gpuv1.ClusterPolicy{}), handler.EnqueueRequestsFromMapFunc(mapFn))
err = c.Watch(
source.Kind(mgr.GetCache(), &gpuv1.ClusterPolicy{}),
handler.EnqueueRequestsFromMapFunc(mapFn),
predicate.GenerationChangedPredicate{},
)
if err != nil {
return err
}
Expand Down

0 comments on commit d2bdba1

Please sign in to comment.