Skip to content
Open
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
4 changes: 2 additions & 2 deletions pkg/controller/ps/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (r *PerconaServerMySQLReconciler) reconcileCRStatus(ctx context.Context, cr
mysqlStatus.State = apiv1.StateInitializing

log.Info(fmt.Sprintf("Async replication not ready: %s", msg))
r.Recorder.Event(cr, corev1.EventTypeWarning, "AsyncReplicationNotReady", msg)
r.Recorder.Event(cr, corev1.EventTypeNormal, "AsyncReplicationNotReady", msg)
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this event from Warning to Normal may be inappropriate. This event is triggered when async replication is not ready, causing the state to be set to StateInitializing (line 105). While the code continues with normal flow, this represents a condition where the system is not yet operational. In Kubernetes, Warning events typically indicate issues or non-ready states that administrators should be aware of. Consider whether this transient failure condition should remain as EventTypeWarning to maintain visibility into operational issues.

Suggested change
r.Recorder.Event(cr, corev1.EventTypeNormal, "AsyncReplicationNotReady", msg)
r.Recorder.Event(cr, corev1.EventTypeWarning, "AsyncReplicationNotReady", msg)

Copilot uses AI. Check for mistakes.
}
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func (r *PerconaServerMySQLReconciler) reconcileCRStatus(ctx context.Context, cr

if status.State != initialState {
log.Info("Cluster state changed", "previous", initialState, "current", status.State)
r.Recorder.Event(cr, corev1.EventTypeWarning, "ClusterStateChanged", fmt.Sprintf("%s -> %s", initialState, status.State))
r.Recorder.Event(cr, corev1.EventTypeNormal, "ClusterStateChanged", fmt.Sprintf("%s -> %s", initialState, status.State))
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing this event from Warning to Normal is problematic because it fires for all state transitions, including transitions to error states. For example, if the state changes from Ready to Error (e.g., line 194 sets state to StateError on full cluster crash), this would generate a Normal event for what is actually a critical problem. The event type should either remain as Warning, or the code should conditionally use Warning for transitions to error/initializing states and Normal only for transitions to ready states.

Suggested change
r.Recorder.Event(cr, corev1.EventTypeNormal, "ClusterStateChanged", fmt.Sprintf("%s -> %s", initialState, status.State))
eventType := corev1.EventTypeNormal
if status.State == apiv1.StateError || status.State == apiv1.StateInitializing {
eventType = corev1.EventTypeWarning
}
r.Recorder.Event(cr, eventType, "ClusterStateChanged", fmt.Sprintf("%s -> %s", initialState, status.State))

Copilot uses AI. Check for mistakes.
}
return nil
}
Expand Down
Loading