-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Improve logging of predicates #10818
Comments
cc @fabriziopandini @chrischdi (just fyi, I think it's not very important, but it would be good for debuggability) |
Let's try to solve for one controller first, then we can try to get help in replicating the solution for the remaining controllers |
@fabriziopandini: GuidelinesPlease ensure that the issue body includes answers to the following questions:
For more details on the requirements of such an issue, please see here and ensure that they are met. If this request no longer meets these requirements, the label can be removed In response to this:
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-sigs/prow repository. |
I was debugging something related to pausing resource for CAPIBM and thinking of adding additional values in predicate logging for debugging locally and in the meantime came across this issue, |
Feel free! I would recommend implementing it for one controller first, so we can get consensus on how to implement it (before implementing it for everything) |
/assign |
I just tried to debug on kind value being empty string, Seems like on update events on few occasion the value is empty
Even this is not consistent, Seen empty most of the time. |
@Karthik-K-N I just talked to Christian and Fabrizio and we have an idea on how to solve the issue with kind. The problem in general is that kind is usually never set for typed objects, only for unstructured. We have to use Basically we would modify all predicates to take an additional scheme as parameter, e.g. ResourceHasFilterLabel(logger logr.Logger, labelValue string) would become ResourceHasFilterLabel(scheme *runtime.Scheme, logger logr.Logger, labelValue string) We would call it like this in our setup funcs predicates.ResourceHasFilterLabel(mgr.GetScheme(), predicateLog, r.WatchFilterValue) Inside of the predicate we would pass the scheme to where we have access to the object and then do the following: func processIfLabelMatch(scheme *runtime.Scheme, log logr.Logger, obj client.Object, labelValue string) bool {
// Return early if no labelValue was set.
if labelValue == "" {
return true
}
if gvk, err := apiutil.GVKForObject(obj, scheme); err == nil {
log = log.WithValues(gvk.Kind, klog.KObj(obj))
}
if labels.HasWatchLabel(obj, labelValue) {
log.V(6).Info("Resource matches label, will attempt to map resource")
return true
}
log.V(4).Info("Resource does not match label, will not attempt to map resource")
return false
} In general I would like all of our predicate logs to have at least the following k/v pairs:
I would like to at least drop the "namespace" k/v pair as it is redundant. If you're interested in implementing this. I would suggest let's start with one predicate first (e.g. ResourceNotPaused + also affects at least ResourceNotPausedAndHasFilterLabel or maybe another one not sure. Ideally let's pick a predicate that doesn't affect a lot of other predicates :)) |
Sure @sbueringer , Thanks for the detailed explanation, I will submit a PR with change for one predicate, My only earlier concern was predicate signature change. |
Yup, same. Talked to Fabrizio and Christian. We would be fine with it. It's an easy change to adopt to, as folks can always just pass in mgr.GetScheme in the places where Predicates are used (sorry I think I missed your comment on the PR somehow :)) |
Sure, Thanks for confirmation. I will go ahead with it. Will submit PR soon. |
@sbueringer so should I make the similar changes for rest of the predicates or should we wait? |
Feel free to go ahead. |
@Karthik-K-N Please also follow-up on: #11188 (comment) |
Sure will do that as well. Thank you. |
This should be the last remaining task of this issue I think |
Hi, Yes, I am about to start on it, I will submit a PR in couple of days. Apologies for the delay. |
No worries and no rush :) Just wanted to let folks know that this is the last part missing and this issue is otherwise done :) Thx for working on it! |
This is completed via PR #11283 @sbueringer Can this issue be closed or is anything pending? |
All good. Thank you very much!! /close |
@sbueringer: Closing this issue. In response to this:
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-sigs/prow repository. |
The logger we use in predicates today only contain an absolute minimum amount of k/v pairs, e.g.
Some notes:
I think we have to improve our predicate logs, otherwise they are not really useful.
(I noticed this when trying to debug predicates of a controller, which is very very hard if there is no way to determine which log belongs to which controller)
In general we should compare the logs of our predicates with the logs of a regular controller and figure out which additional k/v pairs we need + we should make sure kind is logged correctly
Tasks:
<kind>: <namespace>/<name>
(currently we often have an empty kind string + namespace + name k/v pairs)The text was updated successfully, but these errors were encountered: