Skip to content

PlacementDecision events are recorded even when there are no changes #1323

@haoqing0110

Description

@haoqing0110

Describe the bug
The scheduling controller records Kubernetes Events for PlacementDecision even when there are no actual changes, causing unnecessary event accumulation.

Current Behavior

File: pkg/placement/controllers/scheduling/scheduling_controller.go
Function: createOrUpdatePlacementDecision()
Lines: 711-754

updated, err := placementDecisionPatcher.PatchStatus(ctx, newPlacementDecision, newPlacementDecision.Status, existPlacementDecision.Status)
if updated {
return err // Early return when status is updated
}

// Return value ignored - cannot tell if labels actually changed
_, err = placementDecisionPatcher.PatchLabelAnnotations(ctx, newPlacementDecision, newPlacementDecision.ObjectMeta, existPlacementDecision.ObjectMeta)
if err != nil {
return err
}

// ❌ PROBLEM: Events are ALWAYS recorded here, even when nothing changed
c.eventsRecorder.Eventf(..., "DecisionUpdate", "DecisionUpdated", ...)
c.eventsRecorder.Eventf(..., "ScoreUpdate", "ScoreUpdated", ...)

To Reproduce
Steps to reproduce the behavior:

Expected behavior
A clear and concise description of what you expected to happen.

Environment ie: OCM version, Kubernetes version and provider:

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions