Skip to content
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

Add initial eventing machinery #56

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

hasheddan
Copy link
Contributor

@hasheddan hasheddan commented Aug 3, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds event recorder and emits warning events on errors.

Signed-off-by: hasheddan georgedanielmangum@gmail.com

Which issue(s) this PR fixes:

Fixes #41

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Profile controller will emit warning events on failure to get profile path or save profile to disk

Adds event recorder and emits warning events on errors.

Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 3, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hasheddan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 3, 2020
@@ -133,6 +133,7 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V
github.com/go-logr/logr v0.1.0 h1:M1Tv3VzNlEHg6uyACnRdtrploV2P7wZqH8BoQMtz0cg=
github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
github.com/go-logr/zapr v0.1.0/go.mod h1:tabnROwaDl0UNxkVeFRbY8bwB37GwRv0P8lg6aAiEnk=
github.com/go-logr/zapr v0.1.1 h1:qXBXPDdNncunGs7XeEpsJt8wCjYBygluzfdLO0G5baE=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmmm not sure how these go.sum changes happened. make-verify passed locally for me though 🤔

@@ -116,11 +119,13 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error)
profilePath, err := getProfilePath(name, profile)
if err != nil {
logger.Error(err, "cannot get profile path")
r.record.Event(profile, event.Warning(event.Reason("cannot get profile path"), err))
Copy link
Member

Choose a reason for hiding this comment

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

What's your thoughts on adding this into a new implementation of logger?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And having a combined logger / eventer? So it would look something like logger.Event()?

Copy link
Member

Choose a reason for hiding this comment

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

Logging an error automatically throws an event? Sound good! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I'm not sure we will always want to have our logging and eventing tied together in that manner. @pjbgf did you have a specific use case in mind?

Copy link
Member

Choose a reason for hiding this comment

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

The idea was just to remove repetition as I can easily imagine those two lines being used quite frequently together.
I thought more like an EventLogger that implemented the same interface as logger but had an extra side effect.
Thinking a bit more about it, this would violate SRP and probably would make things a bit more complex for new contributors to understand.

Let's keep it simple for now, if needs be we can always review and refactor. ;)

/lgtm

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Aug 3, 2020
@saschagrunert
Copy link
Member

/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 4, 2020
@k8s-ci-robot k8s-ci-robot merged commit 034f0be into kubernetes-sigs:master Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surface events for seccomp profiles created via ConfigMaps
4 participants