Skip to content

[WIP] Zap logging#281

Closed
n3wscott wants to merge 2 commits into
knative:masterfrom
n3wscott:zap_logging
Closed

[WIP] Zap logging#281
n3wscott wants to merge 2 commits into
knative:masterfrom
n3wscott:zap_logging

Conversation

@n3wscott
Copy link
Copy Markdown
Contributor

@n3wscott n3wscott commented Jul 25, 2018

Related: #274

And I had to rewrite a bit of the controller for flow....

This might be too large to merge and we might want to refactor how Serving is doing the base controller class so we can leverage the shared code a little better. Please give comments.

@google-prow-robot google-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 25, 2018
@google-prow-robot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: n3wscott
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: evankanderson

If they are not already assigned, you can assign the PR to them by writing /assign @evankanderson in a comment when ready.

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

The pull request process is described here

Details 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

@n3wscott
Copy link
Copy Markdown
Contributor Author

todo, merge with 540e451

@google-prow-robot
Copy link
Copy Markdown

@n3wscott: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-knative-eventing-go-coverage c199bfd link /test pull-knative-eventing-go-coverage
pull-knative-eventing-unit-tests c199bfd link /test pull-knative-eventing-unit-tests
pull-knative-eventing-build-tests c199bfd link /test pull-knative-eventing-build-tests
pull-knative-eventing-integration-tests c199bfd link /test pull-knative-eventing-integration-tests

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@n3wscott n3wscott changed the title Zap logging [WIP] Zap logging Jul 25, 2018
@google-prow-robot google-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 25, 2018
@n3wscott
Copy link
Copy Markdown
Contributor Author

/assign @grantr

Grant, Please take a look because this will change how the Feed controller is written when it gets there.

Copy link
Copy Markdown
Contributor

@grantr grantr left a comment

Choose a reason for hiding this comment

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

Yay logging! Thanks for working on this @n3wscott. Seems like this is going to block on #287, so I haven't reviewed it fully but I have some comments.

return channelsv1alpha.SchemeGroupVersion.WithKind("Flow")

default:
panic(fmt.Sprintf("Unsupported object type %T", obj))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If a type is added or renamed to any of these groups, this switch needs to be updated. I'm concerned about that coupling. If an object ever gets in the queue that this switch doesn't know about, the panic here will cause the controller to crash loop.

IIUC, the purpose of this switch is to enable the following:

cntrl.NewControllerRef(obj)

The alternative without the switch is:

metav1.NewControllerRef(obj, foov1alpha1.SchemeGroupVersion.WithKind("Bar"))

I think I'd prefer to make the calling code more explicit and eliminate the panic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the point of not passing in the kind is you don't want/need to know what it is. Plus unit tests should catch the panic when a new type is added

return channelsv1alpha.SchemeGroupVersion.WithKind("ClusterBus")
// Feeds
case *feedsv1alpha.ClusterEventType:
return channelsv1alpha.SchemeGroupVersion.WithKind("ClusterEventType")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This and following should be feedsv1alpha

return channelsv1alpha.SchemeGroupVersion.WithKind("EventSource")
// Flows
case *flowsv1alpha.Flow:
return channelsv1alpha.SchemeGroupVersion.WithKind("Flow")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be flowsv1alpha1.

// to status with this stale state.
} else if _, err := c.updateStatus(flow); err != nil {
glog.Warningf("Failed to update flow status: %v", err)
logger.Warnf("Failed to update flow status: %v", zap.Error(err))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Instead of using format directives, uselogger.Warning("Failed to update flow status", zap.Error(err)) so the error is logged as a structured field.

I'd argue this should be usinglogger.Error instead of logger.Warning, but there might be disagreement about that.

@n3wscott n3wscott closed this Aug 3, 2018
creydr pushed a commit to creydr/knative-eventing that referenced this pull request Jul 31, 2023
…tive#281)

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants