New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emit K8S events to the postgresql CR as feedback to the requestor / user #896
Conversation
Thanks for this interesting PR. There was already an internal request to extend the status, but events would also improve the user experience, I guess. So far it doesn't work properly for me. Getting this error: Could you also update the clusterrole here. |
@FxKu In general this works for me, but with the Postgresql reference passed along the various functions quite a lot there might be a call to the event function that does not get the input it expects... Since events are logged (by the operator) along with the other logs, can you narrow this down to a certain action ?
Done. I melted this into last commit. |
it's for all the events 😃 at the end of each error output I see also: Btw: Unit tests in |
@FxKu Urgh sorry about that, I might have missed /messed-up something when I cherry-picked some commits from my local dev branch to this PR - I'll look into it. |
…o cluster via its constructor to enable it to emit events this way
…ce the user interacts with to provide some feedback
As I said, I expect that there might be more cases that events should be generated for (to properly allow users to follow the life-cycle of their clusters and there might still be bugs). But you not seeing any events at all seems strange. |
Thanks for the update. It's interesting: When updating my operator deployment I can see events for running clusters. But when I create a new cluster I get these Operator logs when it's working (maybe that helps): |
@FxKu yeah I observe the same errors now. Very strange that it complains about
for new clusters. |
@FxKu apparently one has to get a proper reference to use when sending events. I added this with commit 633e001 now ... and heureka, we have many many more events:
|
Tested it and it works now. Very nice new feature. Thanks a lot @frittentheke |
👍 |
1 similar comment
👍 |
@@ -1136,6 +1163,7 @@ func (c *Cluster) Switchover(curMaster *v1.Pod, candidate spec.NamespacedName) e | |||
// close the label waiting channel no sooner than the waiting goroutine terminates. | |||
close(podLabelErr) | |||
|
|||
c.eventRecorder.Eventf(c.GetReference(), v1.EventTypeNormal, "Switchover", "Switchover from %q to %q FAILED: %v", curMaster.Name, candidate, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this should be wrapped in if err != nil {}
FAILED: <nil>
is technically correct, but unexpected when the switchover was successful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened issue #1134
Currently the only "feedback" the user or creator of a postgresql custom resource receives is the status. While the operator does produce quite a bit of log, this is not suitable to point users to in order for them to find issues with their particular cluster.
This PR shall enable to operator to (also) send events which are promoted by the Kubernetes documentation (https://kubernetes.io/docs/tasks/debug-application-cluster/#example-debugging-pending-pods) to help debugging issues with a resource and to search for messages from controllers handling this resource.
As this shall be a first cut, I might not have added enough events or even have added events that are too noisy. My intention was to report back certain aspects of the life-cycle: