vsantwana commented on code in PR #978: URL: https://github.com/apache/flink-kubernetes-operator/pull/978#discussion_r2094969483
########## flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EventUtils.java: ########## @@ -104,6 +107,33 @@ public static Event findExistingEvent( .get(); } + public static boolean createWithAnnotationsIfNotExists( + KubernetesClient client, + HasMetadata target, + long eventTime, + EventRecorder.Type type, + String reason, + String message, + EventRecorder.Component component, + Consumer<Event> eventListener, + @Nullable String messageKey, + @Nullable Map<String, String> annotations) { + String eventName = + generateEventName( + target, type, reason, messageKey != null ? messageKey : message, component); + Event existing = findExistingEvent(client, target, eventName); + + if (existing != null) { + return false; + } else { + Event event = buildEvent(target, type, reason, message, component, eventName); + setAnnotations(event, annotations); + setEventTime(event, Instant.ofEpochMilli(eventTime)); + createOrReplaceEvent(client, event).ifPresent(eventListener); + return true; + } + } + public static boolean createIfNotExists( KubernetesClient client, HasMetadata target, Review Comment: I ha thought about it but I did not do it because of the event time. In our case we had decided to set the exception time as event time, but I am not aware of how should it happen for other k8s events, so I kept them separate with the cost of duplicated code. cc @gyfora -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org