Skip to content

Commit dd667ae

Browse files
committed
fix(olm): Fix the issue with missing events due to rate limit
Event recorder has a rate limit (defaultSpamBurst) 25 events per 10 minutes. After the limit is reached, refill rate reduces to 1 event per 5 minutes which causes some events to get lost. Currently implementation allows CSV to be stuck in Pending phase for a long time if there are some missing requirements. As a result, during sync cycle, CSV continues to spam `CSVReasonRequirementsNotMet` events. Now, the code is fixed to not send any identical events that match current state of CSV. Signed-off-by: Vu Dinh <[email protected]>
1 parent 5542420 commit dd667ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/controller/operators/olm/operator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -884,23 +884,23 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
884884

885885
if !met {
886886
logger.Info("requirements were not met")
887-
out.SetPhaseWithEvent(v1alpha1.CSVPhasePending, v1alpha1.CSVReasonRequirementsNotMet, "one or more requirements couldn't be found", now, a.recorder)
887+
out.SetPhaseWithEventIfChanged(v1alpha1.CSVPhasePending, v1alpha1.CSVReasonRequirementsNotMet, "one or more requirements couldn't be found", now, a.recorder)
888888
syncError = ErrRequirementsNotMet
889889
return
890890
}
891891

892892
// Check for CRD ownership conflicts
893893
if syncError = a.crdOwnerConflicts(out, a.csvSet(out.GetNamespace(), v1alpha1.CSVPhaseAny)); syncError != nil {
894894
if syncError == ErrCRDOwnerConflict {
895-
out.SetPhaseWithEventIfChanged(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonOwnerConflict, syncError.Error(), now, a.recorder)
895+
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonOwnerConflict, syncError.Error(), now, a.recorder)
896896
}
897897
return
898898
}
899899

900900
// Check for APIServices ownership conflicts
901901
if syncError = a.apiServiceOwnerConflicts(out); syncError != nil {
902902
if syncError == ErrAPIServiceOwnerConflict {
903-
out.SetPhaseWithEventIfChanged(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonOwnerConflict, syncError.Error(), now, a.recorder)
903+
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonOwnerConflict, syncError.Error(), now, a.recorder)
904904
}
905905
return
906906
}
@@ -943,7 +943,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
943943
} else {
944944
// Set phase to failed if it's been a long time since the last transition (5 minutes)
945945
if metav1.Now().Sub(out.Status.LastTransitionTime.Time) >= 5*time.Minute {
946-
out.SetPhaseWithEventIfChanged(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonInstallCheckFailed, fmt.Sprintf("install timeout"), now, a.recorder)
946+
out.SetPhaseWithEvent(v1alpha1.CSVPhaseFailed, v1alpha1.CSVReasonInstallCheckFailed, fmt.Sprintf("install timeout"), now, a.recorder)
947947
}
948948
}
949949

0 commit comments

Comments
 (0)