-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
Check if time is nil before logging #121554
Check if time is nil before logging #121554
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Hi @kaisoz. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
@@ -180,3 +180,12 @@ func (t Time) MarshalQueryParameter() (string, error) { | |||
|
|||
return t.UTC().Format(time.RFC3339), nil | |||
} | |||
|
|||
// String returns the string representation of the wrapped time.Time | |||
func (t *Time) String() string { |
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 was previously reported in #105981 but closed because of #105981 (comment)
almost identical fixes were previously proposed in #108436 and #105982 and declined because of #105982 (comment) and #105981 (comment)
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.
Looks like this can't be fixed, but people will keep trying...
@kaisoz: can you change this PR so that instead of adding a String
method, a comment gets added why there is no String implementation ("historic reasons") and why it cannot be added now (see #105981 (comment))?
shouldn't we fix the job controller by not logging the timestamp if it is nil? |
That then would have to be done in all places where a |
The fix in |
I don't think it is.
If it was done in advance before all |
Makes sense. Still, the function So, I'm wondering if it's preferable to prevent passing nil in to avoid potential performance increase due to handling the panics. |
This only occurs at -v4 or higher, which is "Debug level verbosity". Does it matter at that level? |
As simple fix at the call site might be:
|
I just read the thread @pohly . So should I go ahead with your code suggestion or the comment you propose in here? IMO I'd go with the nil check since this panic in the logs might mislead the developer while debugging |
Yeah, I missed that it is -v4. So, I'm happy with any of the fixes. |
Let's go with this |
@pohly, could we add a method to the |
would that go to a different PR @alculquicondor or this one? |
I was wondering about that myself. But it needs to be a bit more generic (sic!):
@kaisoz: klog changes need to go into https://github.com/kubernetes/klog/pulls |
ahh obviously 😅 so then I'll implement the change @alculquicondor suggested 👍🏻 |
682194b
to
58d431d
Compare
58d431d
to
ddf084d
Compare
The linter error is a false positive. The @kaisoz: can you submit a PR against logcheck? I can accept it and do a release. |
|
/retest |
#122733 was merged, now the tests should pass. /retest |
ddf084d
to
9a3f1a3
Compare
/lgtm |
LGTM label has been added. Git tree hash: ca36ee06facf2e3a2754f9aac6b8571d7663bee0
|
Tests now pass @pohly , I had to rebase master. Now it is ready to be approved 👍 |
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.
/lgtm
/approve
/assign @mikedanese |
@mikedanese any progress on this? Should we re-assign? |
Let's see whether @andrewsykim has time. It's a small change, just needs someone to approve. /assign @andrewsykim |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kaisoz, liggitt, pohly 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 |
This PR may require API review. If so, when the changes are ready, complete the pre-review checklist and request an API review. Status of requested reviews is tracked in the API Review project. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The Job controller logs a panic when logging a nil
pod.deletionTimestamp
. This PR fixes this by logging it only if it's not nil.Which issue(s) this PR fixes:
Fixes #121392
Special notes for your reviewer:
Does this PR introduce a user-facing change?