-
Notifications
You must be signed in to change notification settings - Fork 125
OCPBUGS-43994: UPSTREAM: <carry>: kube-apiserver: Only log each HTTP request once #2451
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
base: master
Are you sure you want to change the base?
Conversation
@tchap: This pull request references Jira Issue OCPBUGS-43994, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. 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 openshift-eng/jira-lifecycle-plugin repository. |
@tchap: the contents of this pull request could not be automatically validated. The following commits could not be validated and must be approved by a top-level approver:
Comment |
/jira refresh |
@tchap: This pull request references Jira Issue OCPBUGS-43994, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: 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 openshift-eng/jira-lifecycle-plugin repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tchap The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
3 similar comments
/retest |
/retest |
/retest |
} | ||
defer func() { | ||
if logFunc != nil { | ||
logFunc() |
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.
so, previously, the request was first logged here
@tchap please also find the pr that introduced this change and let's add a description to the commit pointing to the original pr with which the new changes should be squashed during the next rebase. |
@p0lyn0mial Is this any kind of standardized process documented anywhere, or should I just add a generic comment? |
@bertinatto ^^ |
We don't have a standarized process, but historically we either:
That way, the person doing the rebase will easily notice that the carry patch can/should be squashed. |
kube-apiserver now logs each HTTP request twice since there is an extra logging call when finishing the request. This duplicity is now removed.
10c8973
to
c068b2f
Compare
@tchap: the contents of this pull request could not be automatically validated. The following commits could not be validated and must be approved by a top-level approver:
Comment |
return withLogging(handler, pred, func() bool { | ||
return klog.V(withLoggingLevel).Enabled() | ||
}, isTerminatingFn) | ||
return withLogging(handler, pred, func(ctx context.Context) bool { |
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.
wait, why so many changes in this file ? should we simply remove the code we discussed previously ?
} | ||
logger := klog.FromContext(ctx) | ||
return logger.V(withLoggingLevel).Enabled() || (isTerminating && logger.V(1).Enabled()) | ||
}) |
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.
@p0lyn0mial I ended up refactoring the logic and private interfaces a bit, but the overall approach is not exactly bullet-proof.
There is now a single predicate function that merges previous shouldLogRequest
and isTerminatingFn
. This means withLogging
is now much more clear and simple.
I added tests and use contextual logging internally that is handy for testing.
The issue really is that when you check respLogger.Log
, it contains anyway klog.V(withLoggingLevel)
, but isTerminating
flag is not passed there, so I am afraid the current implementation contains a bug anyway and isTerminating
is pretty much ignored. So what I did was to check all the conditions initially here and remove .V
call from .Log
. This makes all the tests pass just fine.
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.
Another approach would be to keep the isTerminating
field in the logger and repeat the terminating check in Log
as well...
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.
I need to check but if rl.isTerminating
is/was unused then maybe we can drop the entire patch. Assuming our issue was:
if klog.V(3).Enabled() || (rl.isTerminating && klog.V(1).Enabled()) {...}
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.
This isTerminatingFunc
is actually set up and passed to this machinery in https://github.com/openshift/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/server/config.go#L1155
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.
yeah, I think that the patch was introduced in b052cde
But given that shouldLogRequest is always true when the loglevel is 3 (hardcoded value) and the fact that rl.isTerminating is unused beyond httplog what is the point of the original patch/pr ?
If we were to drop it, I think there would be no change in the behavior. am I right?
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.
Otherwise we can just drop the original patch, which would mean no logging when terminating. Which is not happening right now anyway, but the question is whether we want to drop the intent.
I think the patch is very old. I think that the purpose was to find requests during server termination - not a feature users were using.
I think that we could simply drop the patch and test manually that when loglevel is 3 there are no duplicates during server shutdown.
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.
I did push one last commit, but I guess the plan is to close this and also remove the original carry this is fixing then?
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.
I think so, given that the behaviour will not change after removing the PR, right?. Unless there are some other parts that depend on the original PR.
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.
I don't think anything depends on it, I've reverted the commit just to test it.
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.
could you also test manually that httplog logs requests when appropriate loglevel is set and there are no duplicates ?
you can also open a new PR so that we get a signal from the CI.
|
||
// Log is intended to be called once at the end of your request handler, via defer | ||
func (rl *respLogger) Log() { | ||
func (rl *respLogger) Log(ctx context.Context) { |
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.
There is a change of interface, but it doesn't seem to be really used publicly as this is an unexported object.
/retest |
2 similar comments
/retest |
/retest |
@tchap: the contents of this pull request could not be automatically validated. The following commits could not be validated and must be approved by a top-level approver:
Comment |
@tchap: The following tests failed, say
Full PR test history. Your PR dashboard. 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 understand the commands that are listed here. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
kube-apiserver now logs each HTTP request twice since there is an extra logging call when finishing the request. This duplicity is now removed.
Which issue(s) this PR fixes:
N/A
Special notes for your reviewer:
N/A
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
N/A