diff --git a/internal/controller/cordonnode_controller.go b/internal/controller/cordonnode_controller.go index d7630b0..dbd75c3 100644 --- a/internal/controller/cordonnode_controller.go +++ b/internal/controller/cordonnode_controller.go @@ -36,9 +36,9 @@ func (r *CordonNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) } // Process the CordonNode and cordon nodes - nodesCordoned, err := r.cordonNodes(cordonNode) - if err != nil { - return reconcile.Result{}, err + nodesCordoned := r.cordonNodes(cordonNode) + if nodesCordoned == 0 { + return reconcile.Result{}, nil } // Update the status @@ -50,7 +50,7 @@ func (r *CordonNodeReconciler) Reconcile(ctx context.Context, req ctrl.Request) return reconcile.Result{}, nil } -func (r *CordonNodeReconciler) cordonNodes(cordonNode *khaosv1alpha1.CordonNode) (int, error) { +func (r *CordonNodeReconciler) cordonNodes(cordonNode *khaosv1alpha1.CordonNode) int { nodesCordoned := 0 for _, nodeName := range cordonNode.Spec.NodesToCordon { @@ -71,7 +71,7 @@ func (r *CordonNodeReconciler) cordonNodes(cordonNode *khaosv1alpha1.CordonNode) nodesCordoned++ } - return nodesCordoned, nil + return nodesCordoned } func (r *CordonNodeReconciler) SetupWithManager(mgr ctrl.Manager) error { diff --git a/internal/controller/eventsentropy_controller.go b/internal/controller/eventsentropy_controller.go index b2f60b7..81ff2f9 100644 --- a/internal/controller/eventsentropy_controller.go +++ b/internal/controller/eventsentropy_controller.go @@ -53,7 +53,10 @@ func (r *EventsEntropyReconciler) createRandomEvents(eventsEntropy *khaosv1alpha } // Set the reference to the EventsEntropy - controllerutil.SetControllerReference(eventsEntropy, event, r.Scheme) + if err := controllerutil.SetControllerReference(eventsEntropy, event, r.Scheme); err != nil { + r.Log.Error(err, "Failed to set controller reference for event") + return + } // Create the event if err := r.Create(context.Background(), event); err != nil {