@@ -20,8 +20,6 @@ import (
2020 "context"
2121 "encoding/json"
2222 "fmt"
23- "sort"
24- "strings"
2523
2624 corev1 "k8s.io/api/core/v1"
2725 "k8s.io/apimachinery/pkg/api/equality"
@@ -593,28 +591,19 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding
593591 oldRequiredByLen := len (existBinding .Spec .RequiredBy )
594592
595593 mergedRequiredBy := mergeBindingSnapshot (existBinding .Spec .RequiredBy , attachedBinding .Spec .RequiredBy )
596- parentsForEvent := formatBindingParents (mergedRequiredBy )
597594 multiParentAfter := len (mergedRequiredBy ) > 1
598595
599596 finalConflictResolution := effectiveConflictResolution (attachedBinding .Spec .ConflictResolution )
600597 finalPreserve := ptr .Deref (attachedBinding .Spec .PreserveResourcesOnDeletion , false )
601598
602- var conflictDetails []string
603599 conflictDetected := false
604600 shouldEmitAggregationEvent := false
605601
606602 // If the spec.Placement is nil, this means that existBinding is generated by the dependency mechanism.
607603 // If the spec.Placement is not nil, then it must be generated by PropagationPolicy.
608604 if existBinding .Spec .Placement == nil {
609- if oldRequiredByLen > 0 && oldConflictResolution != finalConflictResolution {
605+ if oldRequiredByLen > 0 && ( oldConflictResolution != finalConflictResolution || oldPreserve != finalPreserve ) {
610606 conflictDetected = true
611- conflictDetails = append (conflictDetails , fmt .Sprintf ("conflictResolution existing=%s incoming=%s" ,
612- oldConflictResolution , finalConflictResolution ))
613- }
614- if oldRequiredByLen > 0 && oldPreserve != finalPreserve {
615- conflictDetected = true
616- conflictDetails = append (conflictDetails , fmt .Sprintf ("preserveResourcesOnDeletion existing=%t incoming=%t" ,
617- oldPreserve , finalPreserve ))
618607 }
619608 existBinding .Spec .ConflictResolution = attachedBinding .Spec .ConflictResolution
620609 shouldEmitAggregationEvent = multiParentAfter
@@ -626,8 +615,9 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding
626615 existBinding .Spec .PreserveResourcesOnDeletion = attachedBinding .Spec .PreserveResourcesOnDeletion
627616
628617 if conflictDetected && d .EventRecorder != nil {
629- message := fmt .Sprintf ("[dep-agg] conflict on %s/%s from parents %s: %s" ,
630- existBinding .Namespace , existBinding .Name , strings .Join (parentsForEvent , "," ), strings .Join (conflictDetails , "; " ))
618+ // Keep the event message concise and consistent with other events' style.
619+ // Detailed differences and parent lists are omitted intentionally.
620+ message := "Dependency policy conflict detected during aggregation."
631621 d .EventRecorder .Eventf (existBinding , corev1 .EventTypeWarning , events .EventReasonDependencyPolicyConflict , message )
632622 }
633623
@@ -637,8 +627,8 @@ func (d *DependenciesDistributor) createOrUpdateAttachedBinding(attachedBinding
637627 }
638628
639629 if shouldEmitAggregationEvent && d .EventRecorder != nil {
640- message := fmt . Sprintf ( "[dep-agg] aggregated policy for %s/%s from parents %s: conflictResolution=%s preserveResourcesOnDeletion=%t" ,
641- existBinding . Namespace , existBinding . Name , strings . Join ( parentsForEvent , "," ), finalConflictResolution , finalPreserve )
630+ // Emit a short success message aligned with other event messages' tone.
631+ message := "Aggregated dependency policy successfully."
642632 d .EventRecorder .Eventf (existBinding , corev1 .EventTypeNormal , events .EventReasonDependencyPolicyAggregated , message )
643633 }
644634 return nil
@@ -734,23 +724,8 @@ func effectiveConflictResolution(value policyv1alpha1.ConflictResolution) policy
734724 return value
735725}
736726
737- func formatBindingParents (snapshots []workv1alpha2.BindingSnapshot ) []string {
738- if len (snapshots ) == 0 {
739- return nil
740- }
741-
742- parents := make ([]string , 0 , len (snapshots ))
743- for _ , snapshot := range snapshots {
744- if snapshot .Namespace != "" {
745- parents = append (parents , fmt .Sprintf ("%s/%s" , snapshot .Namespace , snapshot .Name ))
746- continue
747- }
748- parents = append (parents , snapshot .Name )
749- }
750-
751- sort .Strings (parents )
752- return parents
753- }
727+ // formatBindingParents was used to generate detailed event messages.
728+ // It's removed to keep event messages concise and to avoid unused code warnings.
754729
755730func generateBindingDependedLabels (bindingID , bindingNamespace , bindingName string ) map [string ]string {
756731 labelKey := generateBindingDependedLabelKey (bindingNamespace , bindingName )
0 commit comments