External event recorder adhere to EventRecorder#161
Merged
hiddeco merged 3 commits intofluxcd:mainfrom Oct 19, 2021
Merged
Conversation
5a494b1 to
8ab2c39
Compare
8ab2c39 to
763ba5c
Compare
a895fbe to
1510ec0
Compare
hiddeco
reviewed
Oct 18, 2021
hiddeco
reviewed
Oct 18, 2021
d778a96 to
405f475
Compare
hiddeco
approved these changes
Oct 18, 2021
Member
hiddeco
left a comment
There was a problem hiding this comment.
Happy with this @darkowlzz, LGTM 🥇
Update external event recorder to be compatible with the upstream k8s EventRecorder interface. Since the EventRecorder interface methods don't return any error, add a logger to the external event recorder to log any errors. Add an event type constant for trace events. Update `controller.Events.EventWithMetaf()` to send the available metadata information to the kubernetes event recorder with `AnnotatedEventf()`. Update the tests to work with the function signature changes. Signed-off-by: Sunny <darkowlzz@protonmail.com>
Since events.Recorder implements the k8s EventRecorder interface, there is no need of the controller.Events any more. The reconcilers can embed the k8s EventRecorder and use a events.Recorder recorder. Update the events.Recorder to embed a k8s event recorder to pass events to k8s along with an external recorder. The trace events are passed to k8s recorder as a normal event since it only accepts normal and warning event types. Update tests to use testenv with suite_test. Signed-off-by: Sunny <darkowlzz@protonmail.com>
405f475 to
c16e4d9
Compare
Contributor
Author
|
Rebased and added object information in the recorder logger. The error log from the retry test contains the object info, name/namespace: E1019 00:36:16.462960 2396418 recorder.go:195] "msg"="unable to record event" "error"="POST http://127.0.0.1:33683 giving up after 3 attempt(s): unexpected HTTP status 500 Internal Server Error" "name"="webapp" "namespace"="gitops-system" |
Member
|
For the logs to be compatible with |
Signed-off-by: Sunny <darkowlzz@protonmail.com>
c16e4d9 to
e418a53
Compare
Contributor
Author
|
Added "name"="webapp" "namespace"="gitops-system" "reconciler kind"="ConfigMap" |
stefanprodan
approved these changes
Oct 19, 2021
Member
stefanprodan
left a comment
There was a problem hiding this comment.
LGTM
Thanks @darkowlzz ☕
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
controller.Events.This change updates the external event recorder to be compatible with the k8s EventRecorder interface and embed the k8s event recorder. Since the
events.Recorderimplements the k8s EventRecorder, it can be directly used in reconcilers that embed the k8s EventRecorder interface. This makes thecontroller.Eventsredundant. The k8s event recorder is embedded in theevents.Recorderto be able to post events to k8s and any external recorders.This also introduces a new event type
EventTypeTraceto map with the severity type trace.Since the kubernetes API only accepts Normal and Warning event types. Sending a Trace event results in:
E1018 10:37:56.133861 1768805 event.go:334] Unsupported event type: 'Trace'In order to keep the trace events only in k8s, the trace events are passed to k8s as Normal events. Trace events are not passed to the external event recorders, refer #139.
Since the
EventRecorderinterface methods don't return any error, the external event recorder has a logger to log any event recording related errors.Replacing
corev1.ObjectReferencewithruntime.Objectdue to the function signature change required updating the existing tests objects to beruntime.Objectcompatible.Closes #134